From c56d49cfe6c2f2af44444a48fd08d06eb08ccc63 Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Fri, 10 Mar 2017 15:08:12 +0800 Subject: [PATCH 001/244] [as5812_54t] Fix onlp_fani_percentage_set will set duty to wrong fan module issue --- .../onlp/builds/src/module/src/fani.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c index ab490eb8..4c43da33 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c @@ -352,8 +352,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) int fd, len, nbytes=10, local_id; char data[10] = {0}; char fullpath[70] = {0}; - int psu_id; - psu_type_t psu_type; VALIDATE(id); @@ -363,23 +361,28 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) if (p == 0){ return ONLP_STATUS_E_INVALID; } - - psu_id = local_id - FAN_1_ON_PSU1 + 1; - psu_type = get_psu_type(psu_id, NULL, 0); - - if (psu_type == PSU_TYPE_AC_3YPOWER_F2B || - psu_type == PSU_TYPE_AC_3YPOWER_B2F ) - { - return psu_ym2401_pmbus_info_set(psu_id, "psu_fan1_duty_cycle_percentage", p); - } /* get fullpath */ switch (local_id) { case FAN_1_ON_PSU1: case FAN_1_ON_PSU2: + { + int psu_id; + psu_type_t psu_type; + + psu_id = local_id - FAN_1_ON_PSU1 + 1; + psu_type = get_psu_type(psu_id, NULL, 0); + + if (psu_type == PSU_TYPE_AC_3YPOWER_F2B || + psu_type == PSU_TYPE_AC_3YPOWER_B2F ) { + return psu_ym2401_pmbus_info_set(psu_id, "psu_fan1_duty_cycle_percentage", p); + } + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, last_path[local_id].ctrl_speed); break; + } + default: sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, last_path[local_id].ctrl_speed); break; From f74d968cba3915f25f875c13a0a6c48d36c49dc9 Mon Sep 17 00:00:00 2001 From: "Oleksandr Shamray oleksandrs@mellanox.com" Date: Wed, 24 May 2017 10:36:27 +0000 Subject: [PATCH 002/244] Added onlp_sfp_dev_readb and onlp_sfp_dev_readw support to msn2100, msn2410 and msn2700 systems V2->v1 Comments pointed out by Vadim: - remove unnecessary braces; Signed-off-by: Oleksandr Shamray --- .../onlp/builds/src/module/src/sfpi.c | 51 +++++++++++++++++- .../onlp/builds/src/module/src/sfpi.c | 53 ++++++++++++++++++- .../onlp/builds/src/module/src/sfpi.c | 51 +++++++++++++++++- 3 files changed, 149 insertions(+), 6 deletions(-) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c index 51fa0147..6b799584 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c @@ -68,6 +68,13 @@ msn2100_sfp_get_port_path(int port, char *node_name) return sfp_node_path; } +static char* +msn2100_sfp_convert_i2c_path(int port, int devaddr) +{ + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); + return sfp_node_path; +} + /************************************************************ * * SFPI Entry Points @@ -150,7 +157,27 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + char* path = msn2100_sfp_convert_i2c_path(port, devaddr); + uint8_t data; + int fd; + int nrd; + + if (!path) + return ONLP_STATUS_E_MISSING; + + fd = open(path, O_RDONLY); + if (fd < 0) + return ONLP_STATUS_E_MISSING; + + lseek(fd, addr, SEEK_SET); + nrd = read(fd, &data, 1); + close(fd); + + if (nrd != 1) { + AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); + return ONLP_STATUS_E_INTERNAL; + } + return data; } int @@ -162,7 +189,27 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + char* path = msn2100_sfp_convert_i2c_path(port, devaddr); + uint16_t data; + int fd; + int nrd; + + if (!path) + return ONLP_STATUS_E_MISSING; + + fd = open(path, O_RDONLY); + if (fd < 0) + return ONLP_STATUS_E_MISSING; + + lseek(fd, addr, SEEK_SET); + nrd = read(fd, &data, 2); + close(fd); + + if (nrd != 2) { + AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); + return ONLP_STATUS_E_INTERNAL; + } + return data; } int diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c index 7ee8262a..bc65322a 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c @@ -68,6 +68,13 @@ msn2410_sfp_get_port_path(int port, char *node_name) return sfp_node_path; } +static char* +sn2410_sfp_convert_i2c_path(int port, int devaddr) +{ + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); + return sfp_node_path; +} + /************************************************************ * * SFPI Entry Points @@ -153,7 +160,27 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + char* path = sn2410_sfp_convert_i2c_path(port, devaddr); + uint8_t data; + int fd; + int nrd; + + if (!path) + return ONLP_STATUS_E_MISSING; + + fd = open(path, O_RDONLY); + if (fd < 0) + return ONLP_STATUS_E_MISSING; + + lseek(fd, addr, SEEK_SET); + nrd = read(fd, &data, 1); + close(fd); + + if (nrd != 1) { + AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); + return ONLP_STATUS_E_INTERNAL; + } + return data; } int @@ -165,7 +192,29 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + char* path = sn2410_sfp_convert_i2c_path(port, devaddr); + uint16_t data; + int fd; + int nrd; + + if (!path){ + return ONLP_STATUS_E_MISSING; + } + + fd = open(path, O_RDONLY); + if (fd < 0) { + return ONLP_STATUS_E_MISSING; + } + + lseek(fd, addr, SEEK_SET); + nrd = read(fd, &data, 2); + close(fd); + + if (nrd != 2) { + AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); + return ONLP_STATUS_E_INTERNAL; + } + return data; } int diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c index 4e9851f9..ad5b5fa7 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c @@ -68,6 +68,13 @@ sn2700_sfp_get_port_path(int port, char *node_name) return sfp_node_path; } +static char* +sn2700_sfp_convert_i2c_path(int port, int devaddr) +{ + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); + return sfp_node_path; +} + /************************************************************ * * SFPI Entry Points @@ -153,7 +160,27 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + char* path = sn2700_sfp_convert_i2c_path(port, devaddr); + uint8_t data; + int fd; + int nrd; + + if (!path) + return ONLP_STATUS_E_MISSING; + + fd = open(path, O_RDONLY); + if (fd < 0) + return ONLP_STATUS_E_MISSING; + + lseek(fd, addr, SEEK_SET); + nrd = read(fd, &data, 1); + close(fd); + + if (nrd != 1) { + AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); + return ONLP_STATUS_E_INTERNAL; + } + return data; } int @@ -165,7 +192,27 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + char* path = sn2700_sfp_convert_i2c_path(port, devaddr); + uint16_t data; + int fd; + int nrd; + + if (!path) + return ONLP_STATUS_E_MISSING; + + fd = open(path, O_RDONLY); + if (fd < 0) + return ONLP_STATUS_E_MISSING; + + lseek(fd, addr, SEEK_SET); + nrd = read(fd, &data, 2); + close(fd); + + if (nrd != 2) { + AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); + return ONLP_STATUS_E_INTERNAL; + } + return data; } int From 968d645852e4caffa8fb83aeafa32a9c67061882 Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Mon, 10 Jul 2017 15:05:21 +0800 Subject: [PATCH 003/244] Add Support for QuantaMesh T7032-IX1B: 1. Port IX1B platform driver 2. Add IX1B enum at qci_pmbus.c 3. Port IX1B ONLP: board info 4. Port IX1B ONLP: psu 5. Port IX1B ONLP: sfp 6. Port IX1B ONLP: led 7. Print "ONLP is not supported for FAN/THERMAL" 8. Set SYS_OBJECT_ID as ".7032.3102" --- .../quanta/x86-64/modules/builds/qci_pmbus.c | 4 +- .../x86-64-quanta-ix1b-rglbmc/.gitignore | 2 + .../x86-64/x86-64-quanta-ix1b-rglbmc/Makefile | 1 + .../modules/Makefile | 1 + .../x86-64-quanta-ix1b-rglbmc/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../modules/builds/quanta_platform_ix1b.c | 326 ++++++++++++++++++ .../x86-64-quanta-ix1b-rglbmc/onlp/Makefile | 1 + .../x86-64-quanta-ix1b-rglbmc/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 +++ .../onlp/builds/onlpdump/Makefile | 45 +++ .../src/x86_64_quanta_ix1b_rglbmc/.module | 1 + .../src/x86_64_quanta_ix1b_rglbmc/Makefile | 9 + .../module/auto/make.mk | 9 + .../module/auto/x86_64_quanta_ix1b_rglbmc.yml | 134 +++++++ .../x86_64_quanta_ix1b_rglbmc.x | 14 + .../x86_64_quanta_ix1b_rglbmc_config.h | 167 +++++++++ .../x86_64_quanta_ix1b_rglbmc_dox.h | 26 ++ .../x86_64_quanta_ix1b_rglbmc_gpio_table.h | 55 +++ .../x86_64_quanta_ix1b_rglbmc_porting.h | 87 +++++ .../x86_64_quanta_ix1b_rglbmc/module/make.mk | 10 + .../module/src/Makefile | 9 + .../module/src/fani.c | 75 ++++ .../module/src/ledi.c | 229 ++++++++++++ .../module/src/make.mk | 9 + .../module/src/psui.c | 119 +++++++ .../module/src/sfpi.c | 244 +++++++++++++ .../module/src/sysi.c | 253 ++++++++++++++ .../module/src/thermali.c | 33 ++ .../src/x86_64_quanta_ix1b_rglbmc_config.c | 95 +++++ .../src/x86_64_quanta_ix1b_rglbmc_enums.c | 10 + .../src/x86_64_quanta_ix1b_rglbmc_int.h | 311 +++++++++++++++++ .../src/x86_64_quanta_ix1b_rglbmc_log.c | 18 + .../src/x86_64_quanta_ix1b_rglbmc_log.h | 12 + .../src/x86_64_quanta_ix1b_rglbmc_module.c | 24 ++ .../src/x86_64_quanta_ix1b_rglbmc_ucli.c | 50 +++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml | 31 ++ .../x86_64_quanta_ix1b_rglbmc_r0/__init__.py | 23 ++ 43 files changed, 2495 insertions(+), 1 deletion(-) create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/.gitignore create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/PKG.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/.gitignore create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/PKG.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/lib/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/onlpdump/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.module create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/make.mk create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/x86_64_quanta_ix1b_rglbmc.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc.x create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_config.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_dox.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_gpio_table.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_porting.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/make.mk create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/make.mk create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/psui.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/PKG.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py diff --git a/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c b/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c index 553a27f4..fce52537 100755 --- a/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c +++ b/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c @@ -28,7 +28,7 @@ #include <../drivers/hwmon/pmbus/pmbus.h> #include -enum projects { ly8, ix1, ix2, ix1a }; +enum projects { ly8, ix1, ix2, ix1b }; #define DELAY_TIME 1000 /* uS */ @@ -196,6 +196,7 @@ static const struct i2c_device_id qci_pmbus_id[] = { {"qci_pmbus_ly8", ly8}, {"qci_pmbus_ix1", ix1}, {"qci_pmbus_ix2", ix2}, + {"qci_pmbus_ix1b", ix1b}, {} }; MODULE_DEVICE_TABLE(i2c, qci_pmbus_id); @@ -414,6 +415,7 @@ static int qci_pmbus_probe(struct i2c_client *client, break; case ix1: case ix2: + case ix1b: info->pages = 1; info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/.gitignore new file mode 100755 index 00000000..6fb34116 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/.gitignore @@ -0,0 +1,2 @@ +*x86*64*quanta*ix1b*rglbmc.mk +onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/PKG.yml new file mode 100755 index 00000000..7e2623b4 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix1b-rglbmc KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/.gitignore new file mode 100755 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/Makefile new file mode 100755 index 00000000..1a7724c3 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := quanta +BASENAME := x86-64-quanta-ix1b-rglbmc +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c new file mode 100755 index 00000000..105dd2e7 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c @@ -0,0 +1,326 @@ +/* + * Quanta Switch platform driver + * + * + * Copyright (C) 2017 Quanta Computer inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define DRIVER_NAME "quanta-platform-ix1b" + +#define MAX_I2C_CLIENTS 512 +#define I2C_GPIO_BASE 0x80 +#define XSTR(x) STR(X) +#define STR(x) #x + +enum i2c_types { + i2c_type_spd, + i2c_type_rtc, + i2c_type_pca9546, + i2c_type_pca9548, + i2c_type_pca9554, + i2c_type_pca9555, + i2c_type_pca9698, + i2c_type_qci_cpld, + i2c_type_24c02, + i2c_type_qci_pmbus_ix1b, +}; + +char *i2c_type_names[] = { + "spd", + "ds1339", + "pca9546", + "pca9548", + "pca9554", + "pca9555", + "pca9698", + "CPLD-QSFP28", + "24c02", + "qci_pmbus_ix1b", +}; + +struct i2c_init_data { + int parent_bus; + int type; + int addr; + int busno; + int gpio_base; + char name[I2C_NAME_SIZE]; +}; + +static struct i2c_init_data quanta_ix1b_i2c_init_data[] = { + { .parent_bus = (0x00 + 0), .type = i2c_type_pca9546, .addr = 0x71, .busno = 0x02, .name = "PCA9546(CPU)\0" }, + { .parent_bus = (0x02 + 0), .type = i2c_type_pca9555, .addr = 0x20, .gpio_base = 0x40, .name = "PCA9555_1(CPU)\0" }, + + { .parent_bus = (0x00 + 0), .type = i2c_type_spd, .addr = 0x52, .name = "SPD(DDR3-SODIMM0)\0" }, + { .parent_bus = (0x00 + 0), .type = i2c_type_spd, .addr = 0x53, .name = "SPD(DDR3-SODIMM1)\0" }, + { .parent_bus = (0x00 + 0), .type = i2c_type_pca9546, .addr = 0x77, .busno = 0x10, .name = "PCA9546_1\0" }, + + { .parent_bus = (0x10 + 0), .type = i2c_type_pca9548, .addr = 0x73, .busno = 0x20, .name = "PCA9548_1\0" }, + { .parent_bus = (0x10 + 0), .type = i2c_type_pca9548, .addr = 0x74, .busno = 0x28, .name = "PCA9548_2\0" }, + { .parent_bus = (0x10 + 0), .type = i2c_type_pca9548, .addr = 0x75, .busno = 0x30, .name = "PCA9548_3\0" }, + { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x76, .busno = 0x38, .name = "PCA9548_4\0" }, + { .parent_bus = (0x10 + 0), .type = i2c_type_qci_cpld, .addr = 0x38, .name = "qci_cpld1\0" }, + { .parent_bus = (0x10 + 0), .type = i2c_type_qci_cpld, .addr = 0x39, .name = "qci_cpld2\0" }, + { .parent_bus = (0x20 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_1_EEPROM\0" }, + { .parent_bus = (0x20 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_2_EEPROM\0" }, + { .parent_bus = (0x20 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_3_EEPROM\0" }, + { .parent_bus = (0x20 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_4_EEPROM\0" }, + { .parent_bus = (0x20 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_5_EEPROM\0" }, + { .parent_bus = (0x20 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_6_EEPROM\0" }, + { .parent_bus = (0x20 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_7_EEPROM\0" }, + { .parent_bus = (0x20 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_8_EEPROM\0" }, + { .parent_bus = (0x28 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_9_EEPROM\0" }, + { .parent_bus = (0x28 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_10_EEPROM\0" }, + { .parent_bus = (0x28 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_11_EEPROM\0" }, + { .parent_bus = (0x28 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_12_EEPROM\0" }, + { .parent_bus = (0x28 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_13_EEPROM\0" }, + { .parent_bus = (0x28 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_14_EEPROM\0" }, + { .parent_bus = (0x28 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_15_EEPROM\0" }, + { .parent_bus = (0x28 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_16_EEPROM\0" }, + { .parent_bus = (0x30 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_17_EEPROM\0" }, + { .parent_bus = (0x30 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_18_EEPROM\0" }, + { .parent_bus = (0x30 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_19_EEPROM\0" }, + { .parent_bus = (0x30 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_20_EEPROM\0" }, + { .parent_bus = (0x30 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_21_EEPROM\0" }, + { .parent_bus = (0x30 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_22_EEPROM\0" }, + { .parent_bus = (0x30 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_23_EEPROM\0" }, + { .parent_bus = (0x30 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_24_EEPROM\0" }, + { .parent_bus = (0x38 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_25_EEPROM\0" }, + { .parent_bus = (0x38 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_26_EEPROM\0" }, + { .parent_bus = (0x38 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_27_EEPROM\0" }, + { .parent_bus = (0x38 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_28_EEPROM\0" }, + { .parent_bus = (0x38 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_29_EEPROM\0" }, + { .parent_bus = (0x38 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_30_EEPROM\0" }, + { .parent_bus = (0x38 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_31_EEPROM\0" }, + { .parent_bus = (0x38 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_32_EEPROM\0" }, + + { .parent_bus = (0x00 + 0), .type = i2c_type_pca9546, .addr = 0x72, .busno = 0x18, .name = "PCA9546_2\0" }, + { .parent_bus = (0x18 + 0), .type = i2c_type_qci_pmbus_ix1b, .addr = 0x5f, .name = "PSU_1\0" }, + { .parent_bus = (0x18 + 1), .type = i2c_type_qci_pmbus_ix1b, .addr = 0x59, .name = "PSU_2\0" }, + { .parent_bus = (0x18 + 2), .type = i2c_type_pca9555, .addr = 0x26, .gpio_base = 0x10, .name = "PCA9555-1(PSU)\0" }, + { .parent_bus = (0x18 + 2), .type = i2c_type_24c02, .addr = 0x54, .name = "Board_EEPROM\0" }, + { .parent_bus = (0x18 + 2), .type = i2c_type_pca9555, .addr = 0x23, .name = "PCA9555-2(Board ID)\0" }, + { .parent_bus = (0x18 + 3), .type = i2c_type_pca9555, .addr = 0x25, .name = "PCA9555-3(FAN IO)\0" }, +}; + +static inline struct pca954x_platform_data *pca954x_platform_data_get(int type, int busno) { + static struct pca954x_platform_mode platform_modes[8]; + static struct pca954x_platform_data platform_data; + int num_modes, i; + + switch(type) { + case i2c_type_pca9546: + num_modes = 4; + break; + + case i2c_type_pca9548: + num_modes = 8; + break; + + default: + return (struct pca954x_platform_data *) NULL; + break; + } + + for(i=0;i +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-quanta-ix1b-rglbmc +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_quanta_ix1b_rglbmc quanta_sys_eeprom onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-quanta-ix1b-rglbmc.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..dc4617f8 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_quanta_ix1b_rglbmc quanta_sys_eeprom onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.module b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.module new file mode 100755 index 00000000..a92ca2f5 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.module @@ -0,0 +1 @@ +name: x86_64_quanta_ix1b_rglbmc diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/Makefile new file mode 100755 index 00000000..ddc188e8 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_quanta_ix1b_rglbmc +AUTOMODULE := x86_64_quanta_ix1b_rglbmc +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/make.mk new file mode 100755 index 00000000..17b2a37d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_quanta_ix1b_rglbmc Autogeneration +# +############################################################################### +x86_64_quanta_ix1b_rglbmc_AUTO_DEFS := module/auto/x86_64_quanta_ix1b_rglbmc.yml +x86_64_quanta_ix1b_rglbmc_AUTO_DIRS := module/inc/x86_64_quanta_ix1b_rglbmc module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/x86_64_quanta_ix1b_rglbmc.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/x86_64_quanta_ix1b_rglbmc.yml new file mode 100755 index 00000000..8b791946 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/auto/x86_64_quanta_ix1b_rglbmc.yml @@ -0,0 +1,134 @@ +############################################################################### +# +# x86_64_quanta_ix1b_rglbmc Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: + doc: "RPM Threshold at which the fan is considered to have failed." + default: 3000 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX: + doc: "Maximum system front-to-back fan speed." + default: 18000 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX: + doc: "Maximum system back-to-front fan speed." + default: 18000 +- X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS: + doc: "Time to hold Phy GPIO in reset, in ms" + default: 100 + +definitions: + cdefs: + X86_64_QUANTA_IX1B_RGLBMC_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_quanta_ix1b_rglbmc_config + + enum: &enums + + fan_id: + members: + - FAN1 : 1 + - FAN2 : 2 + - FAN3 : 3 + - FAN4 : 4 + - FAN5 : 5 + - FAN6 : 6 + - FAN7 : 7 + - FAN8 : 8 + - FAN9 : 9 + - FAN10 : 10 + + fan_oid: + members: + - FAN1 : ONLP_FAN_ID_CREATE(1) + - FAN2 : ONLP_FAN_ID_CREATE(2) + - FAN3 : ONLP_FAN_ID_CREATE(3) + - FAN4 : ONLP_FAN_ID_CREATE(4) + - FAN5 : ONLP_FAN_ID_CREATE(5) + - FAN6 : ONLP_FAN_ID_CREATE(6) + - FAN7 : ONLP_FAN_ID_CREATE(7) + - FAN8 : ONLP_FAN_ID_CREATE(8) + - FAN9 : ONLP_FAN_ID_CREATE(9) + - FAN10 : ONLP_FAN_ID_CREATE(10) + + psu_id: + members: + - PSU1 : 1 + - PSU2 : 2 + + psu_oid: + members: + - PSU1 : ONLP_PSU_ID_CREATE(1) + - PSU2 : ONLP_PSU_ID_CREATE(2) + + thermal_id: + members: + - THERMAL1 : 1 + - THERMAL2 : 2 + - THERMAL3 : 3 + - THERMAL4 : 4 + - THERMAL5 : 5 + - THERMAL6 : 6 + - THERMAL7 : 7 + - THERMAL8 : 8 + - THERMAL9 : 9 + - THERMAL10 : 10 + - THERMAL11 : 11 + - THERMAL12 : 12 + - THERMAL13 : 13 + - THERMAL14 : 14 + - THERMAL15 : 15 + - THERMAL16 : 16 + + + thermal_oid: + members: + - THERMAL1 : ONLP_THERMAL_ID_CREATE(1) + - THERMAL2 : ONLP_THERMAL_ID_CREATE(2) + - THERMAL3 : ONLP_THERMAL_ID_CREATE(3) + - THERMAL4 : ONLP_THERMAL_ID_CREATE(4) + - THERMAL5 : ONLP_THERMAL_ID_CREATE(5) + - THERMAL6 : ONLP_THERMAL_ID_CREATE(6) + - THERMAL7 : ONLP_THERMAL_ID_CREATE(7) + - THERMAL8 : ONLP_THERMAL_ID_CREATE(8) + - THERMAL9 : ONLP_THERMAL_ID_CREATE(9) + - THERMAL10 : ONLP_THERMAL_ID_CREATE(10) + - THERMAL11 : ONLP_THERMAL_ID_CREATE(11) + - THERMAL12 : ONLP_THERMAL_ID_CREATE(12) + - THERMAL13 : ONLP_THERMAL_ID_CREATE(13) + - THERMAL14 : ONLP_THERMAL_ID_CREATE(14) + - THERMAL15 : ONLP_THERMAL_ID_CREATE(15) + - THERMAL16 : ONLP_THERMAL_ID_CREATE(16) + + + portingmacro: + X86_64_QUANTA_IX1B_RGLBMC: + macros: + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc.x b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc.x new file mode 100755 index 00000000..10917e43 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_config.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_config.h new file mode 100755 index 00000000..c84b8f89 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_config.h @@ -0,0 +1,167 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ix1b_rglbmc Configuration Header + * + * @addtogroup x86_64_quanta_ix1b_rglbmc-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX1B_RGLBMC_CONFIG_H__ +#define __X86_64_QUANTA_IX1B_RGLBMC_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + * + * RPM Threshold at which the fan is considered to have failed. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + * + * Maximum system front-to-back fan speed. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + * + * Maximum system back-to-front fan speed. */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + * + * Time to hold Phy GPIO in reset, in ms */ + + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS +#define X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS 100 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_quanta_ix1b_rglbmc_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_quanta_ix1b_rglbmc_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_quanta_ix1b_rglbmc_config_settings table. */ +extern x86_64_quanta_ix1b_rglbmc_config_settings_t x86_64_quanta_ix1b_rglbmc_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_quanta_ix1b_rglbmc_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_quanta_ix1b_rglbmc_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_quanta_ix1b_rglbmc_porting.h" + +#endif /* __X86_64_QUANTA_IX1B_RGLBMC_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_dox.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_dox.h new file mode 100755 index 00000000..23d74b2e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_quanta_ix1b_rglbmc Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX1B_RGLBMC_DOX_H__ +#define __X86_64_QUANTA_IX1B_RGLBMC_DOX_H__ + +/** + * @defgroup x86_64_quanta_ix1b_rglbmc x86_64_quanta_ix1b_rglbmc - x86_64_quanta_ix1b_rglbmc Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_quanta_ix1b_rglbmc-x86_64_quanta_ix1b_rglbmc Public Interface + * @defgroup x86_64_quanta_ix1b_rglbmc-config Compile Time Configuration + * @defgroup x86_64_quanta_ix1b_rglbmc-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_QUANTA_IX1B_RGLBMC_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_gpio_table.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_gpio_table.h new file mode 100755 index 00000000..39eacc30 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_gpio_table.h @@ -0,0 +1,55 @@ +#ifndef __X86_64_QUANTA_IX1B_RGLBMC_GPIO_TABLE_H__ +#define __X86_64_QUANTA_IX1B_RGLBMC_GPIO_TABLE_H__ + +/* + * defined within platform/quanta_switch.c + * Quanta Switch Platform driver + */ +#define QUANTA_IX1B_PCA953x_GPIO(P1, P2) (P1*8+P2) + +#define QUANTA_IX1B_PCA9555_GPIO_SIZE 0x10 + +#define QUANTA_IX1B_I2C_GPIO_BASE 0x80 + +#define QUANTA_IX1B_I2C_GPIO_CPU_BASE 0x40 + +#define QUANTA_IX1B_CPU_BOARD_GPIO_BASE (QUANTA_IX1B_I2C_GPIO_CPU_BASE) +#define QUANTA_IX1B_CPU_BOARD_SYS_P1 (QUANTA_IX1B_CPU_BOARD_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,2)) +#define QUANTA_IX1B_CPU_BOARD_SYS_P2 (QUANTA_IX1B_CPU_BOARD_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,3)) + +#define QUANTA_IX1B_PSU_GPIO_BASE 0x10 +#define QUANTA_IX1B_PSU_GPIO_SIZE QUANTA_IX1B_PCA9555_GPIO_SIZE +#define QUANTA_IX1B_PSU_GPIO_PSU1_PRSNT_N (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,0)) +#define QUANTA_IX1B_PSU_GPIO_PSU1_PWRGD (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,1)) +#define QUANTA_IX1B_PSU_GPIO_PSU2_PRSNT_N (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,3)) +#define QUANTA_IX1B_PSU_GPIO_PSU2_PWRGD (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,4)) +#define QUANTA_IX1B_PSU_GPIO_PSU1_AC_OK (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,6)) +#define QUANTA_IX1B_PSU_GPIO_PSU2_AC_OK (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,7)) +#define QUANTA_IX1B_PSU_GPIO_PSU1_GREEN_R (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,2)) +#define QUANTA_IX1B_PSU_GPIO_PSU1_RED_R (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,3)) +#define QUANTA_IX1B_PSU_GPIO_PSU2_GREEN_R (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,4)) +#define QUANTA_IX1B_PSU_GPIO_PSU2_RED_R (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,5)) +#define QUANTA_IX1B_PSU_GPIO_FAN_GREEN_R (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,6)) +#define QUANTA_IX1B_PSU_GPIO_FAN_RED_R (QUANTA_IX1B_PSU_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,7)) + +#define QUANTA_IX1B_ZQSFP_EN_GPIO_BASE QUANTA_IX1B_I2C_GPIO_BASE +#define QUANTA_IX1B_ZQSFP_EN_GPIO_SIZE QUANTA_IX1B_PCA9555_GPIO_SIZE +#define QUANTA_IX1B_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_IX1B_ZQSFP_EN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,4)) +#define QUANTA_IX1B_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_IX1B_ZQSFP_EN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,5)) + +#define QUANTA_IX1B_FAN_GPIO_BASE (QUANTA_IX1B_ZQSFP_EN_GPIO_BASE + QUANTA_IX1B_ZQSFP_EN_GPIO_SIZE) +#define QUANTA_IX1B_FAN_GPIO_SIZE QUANTA_IX1B_PCA9555_GPIO_SIZE +#define QUANTA_IX1B_FAN_PRSNT_N_1 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,4)) +#define QUANTA_IX1B_FAN_PRSNT_N_2 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,5)) +#define QUANTA_IX1B_FAN_PRSNT_N_3 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,6)) +#define QUANTA_IX1B_FAN_PRSNT_N_4 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(0,7)) +#define QUANTA_IX1B_FAN_BF_DET1 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,0)) +#define QUANTA_IX1B_FAN_BF_DET2 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,1)) +#define QUANTA_IX1B_FAN_BF_DET3 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,2)) +#define QUANTA_IX1B_FAN_BF_DET4 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,3)) +#define QUANTA_IX1B_FAN_FAIL_LED_1 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,4)) +#define QUANTA_IX1B_FAN_FAIL_LED_2 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,5)) +#define QUANTA_IX1B_FAN_FAIL_LED_3 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,6)) +#define QUANTA_IX1B_FAN_FAIL_LED_4 (QUANTA_IX1B_FAN_GPIO_BASE + QUANTA_IX1B_PCA953x_GPIO(1,7)) + +#endif /* __X86_64_QUANTA_IX1B_RGLBMC_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_porting.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_porting.h new file mode 100755 index 00000000..13a89c1d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_porting.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ix1b_rglbmc Porting Macros. + * + * @addtogroup x86_64_quanta_ix1b_rglbmc-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX1B_RGLBMC_PORTING_H__ +#define __X86_64_QUANTA_IX1B_RGLBMC_PORTING_H__ + + +/* */ +#if X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_QUANTA_IX1B_RGLBMC_MEMSET GLOBAL_MEMSET + #elif X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX1B_RGLBMC_MEMSET memset + #else + #error The macro X86_64_QUANTA_IX1B_RGLBMC_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_QUANTA_IX1B_RGLBMC_MEMCPY GLOBAL_MEMCPY + #elif X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX1B_RGLBMC_MEMCPY memcpy + #else + #error The macro X86_64_QUANTA_IX1B_RGLBMC_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_QUANTA_IX1B_RGLBMC_STRNCPY GLOBAL_STRNCPY + #elif X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX1B_RGLBMC_STRNCPY strncpy + #else + #error The macro X86_64_QUANTA_IX1B_RGLBMC_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_QUANTA_IX1B_RGLBMC_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX1B_RGLBMC_VSNPRINTF vsnprintf + #else + #error The macro X86_64_QUANTA_IX1B_RGLBMC_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_QUANTA_IX1B_RGLBMC_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX1B_RGLBMC_SNPRINTF snprintf + #else + #error The macro X86_64_QUANTA_IX1B_RGLBMC_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX1B_RGLBMC_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_QUANTA_IX1B_RGLBMC_STRLEN GLOBAL_STRLEN + #elif X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX1B_RGLBMC_STRLEN strlen + #else + #error The macro X86_64_QUANTA_IX1B_RGLBMC_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_QUANTA_IX1B_RGLBMC_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/make.mk new file mode 100755 index 00000000..facfa932 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_quanta_ix1b_rglbmc_INCLUDES := -I $(THIS_DIR)inc +x86_64_quanta_ix1b_rglbmc_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_quanta_ix1b_rglbmc_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ix1b_rglbmc ucli:x86_64_quanta_ix1b_rglbmc + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/Makefile new file mode 100755 index 00000000..4df4b050 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_quanta_ix1b_rglbmc_ucli.c + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c new file mode 100755 index 00000000..4ae5ff48 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c @@ -0,0 +1,75 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +#include "x86_64_quanta_ix1b_rglbmc_int.h" +#include "x86_64_quanta_ix1b_rglbmc_log.h" + +#include + +int +onlp_fani_init(void) +{ + AIM_LOG_MSG("ONLP is not supported for FAN"); + return ONLP_STATUS_E_UNSUPPORTED; +} + +static int +psu_fan_info_get__(onlp_fan_info_t* info, int id) +{ + extern struct psu_info_s psu_info[]; + char* dir = psu_info[id].path; + + return onlp_file_read_int(&info->rpm, "%s*fan1_input", dir); +} + +/* Onboard Fans */ +static onlp_fan_info_t fans__[] = { + { }, /* Not used */ + { { FAN_OID_FAN1, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, + { { FAN_OID_FAN2, "PSU-2 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, +}; + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) +{ + int fid = ONLP_OID_ID_GET(id); + + *rv = fans__[ONLP_OID_ID_GET(id)]; + rv->caps |= ONLP_FAN_CAPS_GET_RPM; + + switch(fid) { + case FAN_ID_FAN1: + case FAN_ID_FAN2: + return psu_fan_info_get__(rv, fid); + break; + + default: + return ONLP_STATUS_E_INVALID; + break; + } + + return ONLP_STATUS_E_INVALID; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c new file mode 100755 index 00000000..95db75af --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c @@ -0,0 +1,229 @@ +#include +#include +#include +#include +#include + +#include "x86_64_quanta_ix1b_rglbmc_int.h" +#include +#include + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t led_info[] = +{ + { }, /* Not used */ + { + { LED_OID_SYSTEM, "System LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + }, + { + { LED_OID_FAN, "Front FAN LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { LED_OID_PSU_1, "Front PSU(1) LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { LED_OID_PSU_2, "Front PSU(2) LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { LED_OID_FAN_FAIL_1, "FAN(1) fail LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED, + }, + { + { LED_OID_FAN_FAIL_2, "FAN(2) fail LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED, + }, + { + { LED_OID_FAN_FAIL_3, "FAN(3) fail LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED, + }, + { + { LED_OID_FAN_FAIL_4, "FAN(4) fail LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED, + } +}; + +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + + int led_id; + + led_id = ONLP_OID_ID_GET(id); + + *info = led_info[led_id]; + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_ON; + + return ONLP_STATUS_OK; +} + +void +Sysfs_Set_System_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_IX1B_CPU_BOARD_SYS_P1, 0); + onlp_gpio_set(QUANTA_IX1B_CPU_BOARD_SYS_P2, 1); + } + else if(mode == ONLP_LED_MODE_ORANGE){ + onlp_gpio_set(QUANTA_IX1B_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_IX1B_CPU_BOARD_SYS_P2, 0); + } + else{ + onlp_gpio_set(QUANTA_IX1B_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_IX1B_CPU_BOARD_SYS_P2, 1); + } +} + +void +Sysfs_Set_Fan_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_FAN_GREEN_R, 1); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_FAN_RED_R, 0); + } + else if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_FAN_GREEN_R, 0); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_FAN_RED_R, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_FAN_GREEN_R, 0); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_FAN_RED_R, 0); + } +} + +void +Sysfs_Set_Psu1_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU1_GREEN_R, 1); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU1_RED_R, 0); + } + else if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU1_GREEN_R, 0); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU1_RED_R, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU1_GREEN_R, 0); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU1_RED_R, 0); + } +} + +void +Sysfs_Set_Psu2_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU2_GREEN_R, 1); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU2_RED_R, 0); + } + else if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU2_GREEN_R, 0); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU2_RED_R, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU2_GREEN_R, 0); + onlp_gpio_set(QUANTA_IX1B_PSU_GPIO_PSU2_RED_R, 0); + } +} + +void +Sysfs_Set_Fan_Fail1_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_1, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_1, 0); + } +} + +void +Sysfs_Set_Fan_Fail2_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_2, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_2, 0); + } +} + +void +Sysfs_Set_Fan_Fail3_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_3, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_3, 0); + } +} + +void +Sysfs_Set_Fan_Fail4_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_RED){ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_4, 1); + } + else{ + onlp_gpio_set(QUANTA_IX1B_FAN_FAIL_LED_4, 0); + } +} + +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int led_id; + + led_id = ONLP_OID_ID_GET(id); + switch (led_id) { + case LED_ID_SYSTEM: + Sysfs_Set_System_LED(mode); + break; + case LED_ID_FAN: + Sysfs_Set_Fan_LED(mode); + break; + case LED_ID_PSU_1: + Sysfs_Set_Psu1_LED(mode); + break; + case LED_ID_PSU_2: + Sysfs_Set_Psu2_LED(mode); + break; + case LED_ID_FAN_FAIL_1: + Sysfs_Set_Fan_Fail1_LED(mode); + break; + case LED_ID_FAN_FAIL_2: + Sysfs_Set_Fan_Fail2_LED(mode); + break; + case LED_ID_FAN_FAIL_3: + Sysfs_Set_Fan_Fail3_LED(mode); + break; + case LED_ID_FAN_FAIL_4: + Sysfs_Set_Fan_Fail4_LED(mode); + break; + default: + return ONLP_STATUS_E_INTERNAL; + break; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/make.mk new file mode 100755 index 00000000..b3456595 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_quanta_ix1b_rglbmc +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/psui.c new file mode 100755 index 00000000..51c50814 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/psui.c @@ -0,0 +1,119 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "x86_64_quanta_ix1b_rglbmc_int.h" +#include "x86_64_quanta_ix1b_rglbmc_log.h" +#include + +struct psu_info_s psu_info[] = { + {}, /* Not used */ + { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/24-005f", .present = QUANTA_IX1B_PSU_GPIO_PSU1_PRSNT_N, .busno = 24, .addr = 0x5f}, + { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/25-0059", .present = QUANTA_IX1B_PSU_GPIO_PSU2_PRSNT_N, .busno = 25, .addr = 0x59}, +}; + +int +onlp_psui_init(void) +{ + return 0; +} + +static onlp_psu_info_t psus__[] = { + { }, /* Not used */ + { + { + PSU_OID_PSU1, + "Quanta IX1B RPSU-1", + 0, + { + FAN_OID_FAN1, + }, + } + }, + { + { + PSU_OID_PSU2, + "Quanta IX1B RPSU-2", + 0, + { + FAN_OID_FAN2, + }, + } + }, +}; + +#define PMBUS_MFR_MODEL 0x9A +#define PMBUS_MFR_SERIAL 0x9E +#define PMBUS_MFR_MODEL_LEN 20 +#define PMBUS_MFR_SERIAL_LEN 19 + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int rv; + int pid = ONLP_OID_ID_GET(id); + *info = psus__[pid]; + const char* dir = psu_info[pid].path; + unsigned char buffer[ONLP_CONFIG_INFO_STR_MAX]; + int value = -1, len; + + rv = onlp_gpio_get(psu_info[pid].present, &value); + if(rv < 0) { + return rv; + } + else if(value == 1) { + info->status &= ~1; + return 0; + } + + if(onlp_file_read_int(&info->mvin, "%s*in1_input", dir) == 0 && info->mvin >= 0) { + info->caps |= ONLP_PSU_CAPS_VIN; + } + + /* PSU is present and powered. */ + info->status |= 1; + + len = PMBUS_MFR_MODEL_LEN; + if(onlp_file_read(buffer, sizeof(buffer), &len, "%s*mfr_model", dir) != 0){ + AIM_LOG_ERROR("Read PMBUS_MFR_MODEL ###ERROR###");; + } + aim_strlcpy(info->model, (char *) buffer, 16); + + len = PMBUS_MFR_SERIAL_LEN; + if(onlp_file_read(buffer, sizeof(buffer), &len, "%s*mfr_serial", dir) != 0){ + AIM_LOG_ERROR("Read PMBUS_MFR_SERIAL ###ERROR###");; + } + aim_strlcpy(info->serial, (char *) buffer, 14); + + info->caps |= ONLP_PSU_CAPS_AC; + + if(onlp_file_read_int(&info->miin, "%s*curr1_input", dir) == 0 && info->miin >= 0) { + info->caps |= ONLP_PSU_CAPS_IIN; + } + if(onlp_file_read_int(&info->miout, "%s*curr2_input", dir) == 0 && info->miout >= 0) { + info->caps |= ONLP_PSU_CAPS_IOUT; + } + if(onlp_file_read_int(&info->mvout, "%s*in2_input", dir) == 0 && info->mvout >= 0) { + info->caps |= ONLP_PSU_CAPS_VOUT; + } + if(onlp_file_read_int(&info->mpin, "%s*power1_input", dir) == 0 && info->mpin >= 0) { + info->caps |= ONLP_PSU_CAPS_PIN; + /* The pmbus driver reports power in micro-units */ + info->mpin /= 1000; + } + if(onlp_file_read_int(&info->mpout, "%s*power2_input", dir) == 0 && info->mpout >= 0) { + info->caps |= ONLP_PSU_CAPS_POUT; + /* the pmbus driver reports power in micro-units */ + info->mpout /= 1000; + } + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c new file mode 100755 index 00000000..6b695f2c --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c @@ -0,0 +1,244 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * SFPI Interface for the Quanta IX1B + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "x86_64_quanta_ix1b_rglbmc_log.h" +#include +#include +#include + +/** + * This table maps the presence gpio, reset gpio, and eeprom file + * for each SFP port. + */ +typedef struct sfpmap_s { + int port; + const char* present_cpld; + const char* reset_gpio; + const char* eeprom; + const char* dom; +} sfpmap_t; + +static sfpmap_t sfpmap__[] = + { + { 1, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-1/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-32/32-0050/eeprom", NULL }, + { 2, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-2/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-33/33-0050/eeprom", NULL }, + { 3, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-3/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-34/34-0050/eeprom", NULL }, + { 4, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-4/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-35/35-0050/eeprom", NULL }, + { 5, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-5/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-36/36-0050/eeprom", NULL }, + { 6, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-6/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-37/37-0050/eeprom", NULL }, + { 7, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-7/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-38/38-0050/eeprom", NULL }, + { 8, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-8/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-39/39-0050/eeprom", NULL }, + { 9, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-9/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-40/40-0050/eeprom", NULL }, + { 10, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-10/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-41/41-0050/eeprom", NULL }, + { 11, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-11/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-42/42-0050/eeprom", NULL }, + { 12, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-12/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-43/43-0050/eeprom", NULL }, + { 13, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-13/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-44/44-0050/eeprom", NULL }, + { 14, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-14/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-45/45-0050/eeprom", NULL }, + { 15, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-15/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-46/46-0050/eeprom", NULL }, + { 16, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-16/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-47/47-0050/eeprom", NULL }, + { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-17/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-48/48-0050/eeprom", NULL }, + { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-18/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-49/49-0050/eeprom", NULL }, + { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-19/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-50/50-0050/eeprom", NULL }, + { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-20/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-51/51-0050/eeprom", NULL }, + { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-21/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-52/52-0050/eeprom", NULL }, + { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-22/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-53/53-0050/eeprom", NULL }, + { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-23/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-54/54-0050/eeprom", NULL }, + { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-24/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-55/55-0050/eeprom", NULL }, + { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-25/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-56/56-0050/eeprom", NULL }, + { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-26/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-57/57-0050/eeprom", NULL }, + { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-27/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-58/58-0050/eeprom", NULL }, + { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-28/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-59/59-0050/eeprom", NULL }, + { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-29/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-60/60-0050/eeprom", NULL }, + { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-30/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-61/61-0050/eeprom", NULL }, + { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-31/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-62/62-0050/eeprom", NULL }, + { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-63/63-0050/eeprom", NULL }, + }; + +#define SFP_GET(_port) (sfpmap__ + _port - 1) +#define MAX_SFP_PATH 128 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sfpmap_t* sfp = SFP_GET(port); + + sprintf(sfp_node_path, sfp->present_cpld, + node_name); + return sfp_node_path; +} + +int +onlp_sfpi_init(void) +{ + int ret; + + onlp_gpio_export(QUANTA_IX1B_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); + ret = onlp_gpio_set(QUANTA_IX1B_ZQSFP_EN_GPIO_P3V3_PW_EN, 1); + sleep(1); + + return ret; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + + for(p = 1; p < 33; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + return onlplib_sfp_is_present_file(sfp_get_port_path(port, "module_present"), /* Present */ "1\n", /* Absent */ "0\n"); +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->eeprom, data); +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->dom, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + char* path = NULL; + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + path = sfp_get_port_path(port, "reset"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set reset status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + path = sfp_get_port_path(port, "lpmode"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + char* path = NULL; + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + path = sfp_get_port_path(port, "reset"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + path = sfp_get_port_path(port, "lpmode"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read lpmode status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_RX_LOS: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c new file mode 100755 index 00000000..3839337d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c @@ -0,0 +1,253 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_quanta_ix1b_rglbmc_int.h" +#include "x86_64_quanta_ix1b_rglbmc_log.h" +#include +#include +#include +#include +#include + +struct led_control_s led_control; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-quanta-ix1b-rglbmc-r0"; +} + +int +onlp_sysi_init(void) +{ + /* Initial value */ + led_control.PMCnt = 0; + led_control.psu1_present = 0; + led_control.psu2_present = 0; + led_control.psu1_power_good = 0; + led_control.psu2_power_good = 0; + + /* Config GPIO */ + /* LED Output */ + onlp_gpio_export(QUANTA_IX1B_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU1_GREEN_R, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU1_RED_R, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU2_GREEN_R, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU2_RED_R, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_FAN_FAIL_LED_1, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_FAN_FAIL_LED_2, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_FAN_FAIL_LED_3, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_FAN_FAIL_LED_4, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_FAN_GREEN_R, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_FAN_RED_R, ONLP_GPIO_DIRECTION_OUT); + + /* PSU Input */ + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU1_PRSNT_N, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU1_PWRGD, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU2_PRSNT_N, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1B_PSU_GPIO_PSU2_PWRGD, ONLP_GPIO_DIRECTION_IN); + + /* FAN Input */ + onlp_gpio_export(QUANTA_IX1B_FAN_PRSNT_N_1, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1B_FAN_PRSNT_N_2, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1B_FAN_PRSNT_N_3, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1B_FAN_PRSNT_N_4, ONLP_GPIO_DIRECTION_IN); + + /* Set LED to green */ + onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); + led_control.psu_status_changed = 1; + led_control.fan_status_changed = 1; + onlp_sysi_platform_manage_leds(); + + return ONLP_STATUS_OK; +} + +#define QUANTA_SYS_EEPROM_PATH \ +"/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/26-0054/eeprom" + +int +onlp_sysi_onie_info_get(onlp_onie_info_t* onie) +{ + int rv; + + rv = onlp_onie_decode_file(onie, QUANTA_SYS_EEPROM_PATH); + if(rv >= 0) { + onie->platform_name = aim_strdup("x86-64-quanta-ix1b-rglbmc-r0"); + rv = quanta_onie_sys_eeprom_custom_format(onie); + } + return rv; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* + * 2 PSUs + */ + *e++ = PSU_OID_PSU1; + *e++ = PSU_OID_PSU2; + + /* + * 8 LEDs + */ + *e++ = LED_OID_SYSTEM; + *e++ = LED_OID_FAN; + *e++ = LED_OID_PSU_1; + *e++ = LED_OID_PSU_2; + *e++ = LED_OID_FAN_FAIL_1; + *e++ = LED_OID_FAN_FAIL_2; + *e++ = LED_OID_FAN_FAIL_3; + *e++ = LED_OID_FAN_FAIL_4; + + return 0; +} + +int +update_rpsu_fan_status(void){ + int last_status, rv, value = -1/*, tmp*/; + + last_status = led_control.psu1_present; + rv = onlp_gpio_get(QUANTA_IX1B_PSU_GPIO_PSU1_PRSNT_N, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_PSU_GPIO_PSU1_PRSNT_N); + return rv; + } + led_control.psu1_present = (value ? 0 : 1); + if(last_status != led_control.psu1_present) + led_control.psu_status_changed = 1; + + last_status = led_control.psu1_power_good; + rv = onlp_gpio_get(QUANTA_IX1B_PSU_GPIO_PSU1_PWRGD, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_PSU_GPIO_PSU1_PWRGD); + return rv; + } + led_control.psu1_power_good = (value ? 1 : 0); + if(last_status != led_control.psu1_power_good) + led_control.psu_status_changed = 1; + + last_status = led_control.psu2_present; + rv = onlp_gpio_get(QUANTA_IX1B_PSU_GPIO_PSU2_PRSNT_N, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_PSU_GPIO_PSU2_PRSNT_N); + return rv; + } + led_control.psu2_present = (value ? 0 : 1); + if(last_status != led_control.psu2_present) + led_control.psu_status_changed = 1; + + last_status = led_control.psu2_power_good; + rv = onlp_gpio_get(QUANTA_IX1B_PSU_GPIO_PSU2_PWRGD, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_PSU_GPIO_PSU2_PWRGD); + return rv; + } + led_control.psu2_power_good = (value ? 1 : 0); + if(last_status != led_control.psu2_power_good) + led_control.psu_status_changed = 1; + + last_status = led_control.fan1_present; + rv = onlp_gpio_get(QUANTA_IX1B_FAN_PRSNT_N_1, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_FAN_PRSNT_N_1); + return rv; + } + led_control.fan1_present = (value ? 0 : 1); + if(last_status != led_control.fan1_present) + led_control.fan_status_changed = 1; + + last_status = led_control.fan2_present; + rv = onlp_gpio_get(QUANTA_IX1B_FAN_PRSNT_N_2, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_FAN_PRSNT_N_2); + return rv; + } + led_control.fan2_present = (value ? 0 : 1); + if(last_status != led_control.fan2_present) + led_control.fan_status_changed = 1; + + last_status = led_control.fan3_present; + rv = onlp_gpio_get(QUANTA_IX1B_FAN_PRSNT_N_3, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_FAN_PRSNT_N_3); + return rv; + } + led_control.fan3_present = (value ? 0 : 1); + if(last_status != led_control.fan3_present) + led_control.fan_status_changed = 1; + + last_status = led_control.fan4_present; + rv = onlp_gpio_get(QUANTA_IX1B_FAN_PRSNT_N_4, &value); + if(rv < 0) { + AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1B_FAN_PRSNT_N_4); + return rv; + } + led_control.fan4_present = (value ? 0 : 1); + if(last_status != led_control.fan4_present) + led_control.fan_status_changed = 1; + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + int rv; + + led_control.PMCnt++; + if(led_control.PMCnt>300) + led_control.PMCnt = 0; + if(led_control.PMCnt % 5 == 1){/* Each 10 seconds detect one time */ + + rv = update_rpsu_fan_status(); + if(rv < 0){ + printf("onlp_sysi_platform_manage_leds error\n"); + return ONLP_STATUS_E_INVALID; + } + + if(led_control.psu_status_changed){ + if(led_control.psu1_present && led_control.psu1_power_good) { + onlp_ledi_mode_set(LED_ID_PSU_1, ONLP_LED_MODE_GREEN); + } + else if(!led_control.psu1_present){ + onlp_ledi_mode_set(LED_ID_PSU_1, ONLP_LED_MODE_OFF); + } + else{ + onlp_ledi_mode_set(LED_ID_PSU_1, ONLP_LED_MODE_RED); + } + + if(led_control.psu2_present && led_control.psu2_power_good) { + onlp_ledi_mode_set(LED_ID_PSU_2, ONLP_LED_MODE_GREEN); + } + else if(!led_control.psu2_present){ + onlp_ledi_mode_set(LED_ID_PSU_2, ONLP_LED_MODE_OFF); + } + else{ + onlp_ledi_mode_set(LED_ID_PSU_2, ONLP_LED_MODE_RED); + } + led_control.psu_status_changed = 0; + } + + if(led_control.fan_status_changed){ + if(led_control.fan1_present && led_control.fan2_present && led_control.fan3_present && led_control.fan4_present){ + onlp_ledi_mode_set(LED_ID_FAN, ONLP_LED_MODE_GREEN); + } + else{ + onlp_ledi_mode_set(LED_ID_FAN, ONLP_LED_MODE_RED); + } + led_control.fan_status_changed = 0; + } + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c new file mode 100755 index 00000000..f2528838 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c @@ -0,0 +1,33 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_quanta_ix1b_rglbmc_log.h" + +int +onlp_thermali_init(void) +{ + AIM_LOG_MSG("ONLP is not supported for THERMAL"); + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c new file mode 100755 index 00000000..f71213bf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c @@ -0,0 +1,95 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(_x) +x86_64_quanta_ix1b_rglbmc_config_settings_t x86_64_quanta_ix1b_rglbmc_config_settings[] = +{ +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_STDLIB(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + { __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS) }, +#else +{ X86_64_QUANTA_IX1B_RGLBMC_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_VALUE +#undef __x86_64_quanta_ix1b_rglbmc_config_STRINGIFY_NAME + +const char* +x86_64_quanta_ix1b_rglbmc_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_quanta_ix1b_rglbmc_config_settings[i].name; i++) { + if(strcmp(x86_64_quanta_ix1b_rglbmc_config_settings[i].name, setting)) { + return x86_64_quanta_ix1b_rglbmc_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_quanta_ix1b_rglbmc_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_quanta_ix1b_rglbmc_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_quanta_ix1b_rglbmc_config_settings[i].name, x86_64_quanta_ix1b_rglbmc_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c new file mode 100755 index 00000000..e31c1e1e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h new file mode 100755 index 00000000..c024d187 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h @@ -0,0 +1,311 @@ +/**************************************************************************//** + * + * x86_64_quanta_ix1b_rglbmc Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX1B_RGLBMC_INT_H__ +#define __X86_64_QUANTA_IX1B_RGLBMC_INT_H__ + +#include +#include + +/* */ +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; + +/** Enum names. */ +const char* thermal_oid_name(thermal_oid_t e); + +/** Enum values. */ +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_oid_desc(thermal_oid_t e); + +/** Enum validator. */ +int thermal_oid_valid(thermal_oid_t e); + +/** validator */ +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) + +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; + +/** psu_oid */ +typedef enum psu_oid_e { + PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), + PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), +} psu_oid_t; + +/** Enum names. */ +const char* psu_oid_name(psu_oid_t e); + +/** Enum values. */ +int psu_oid_value(const char* str, psu_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_oid_desc(psu_oid_t e); + +/** Enum validator. */ +int psu_oid_valid(psu_oid_t e); + +/** validator */ +#define PSU_OID_VALID(_e) \ + (psu_oid_valid((_e))) + +/** psu_oid_map table. */ +extern aim_map_si_t psu_oid_map[]; +/** psu_oid_desc_map table. */ +extern aim_map_si_t psu_oid_desc_map[]; + +/** thermal_id */ +typedef enum thermal_id_e { + THERMAL_ID_THERMAL1 = 1, + THERMAL_ID_THERMAL2 = 2, + THERMAL_ID_THERMAL3 = 3, + THERMAL_ID_THERMAL4 = 4, + THERMAL_ID_THERMAL5 = 5, + THERMAL_ID_THERMAL6 = 6, + THERMAL_ID_THERMAL7 = 7, + THERMAL_ID_THERMAL8 = 8, + THERMAL_ID_THERMAL9 = 9, + THERMAL_ID_THERMAL10 = 10, + THERMAL_ID_THERMAL11 = 11, + THERMAL_ID_THERMAL12 = 12, + THERMAL_ID_THERMAL13 = 13, + THERMAL_ID_THERMAL14 = 14, + THERMAL_ID_THERMAL15 = 15, + THERMAL_ID_THERMAL16 = 16, +} thermal_id_t; + +/** Enum names. */ +const char* thermal_id_name(thermal_id_t e); + +/** Enum values. */ +int thermal_id_value(const char* str, thermal_id_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_id_desc(thermal_id_t e); + +/** Enum validator. */ +int thermal_id_valid(thermal_id_t e); + +/** validator */ +#define THERMAL_ID_VALID(_e) \ + (thermal_id_valid((_e))) + +/** thermal_id_map table. */ +extern aim_map_si_t thermal_id_map[]; +/** thermal_id_desc_map table. */ +extern aim_map_si_t thermal_id_desc_map[]; + +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; + +/** Enum names. */ +const char* fan_id_name(fan_id_t e); + +/** Enum values. */ +int fan_id_value(const char* str, fan_id_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_id_desc(fan_id_t e); + +/** Enum validator. */ +int fan_id_valid(fan_id_t e); + +/** validator */ +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) + +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; +/* */ + +/* psu info table */ +struct psu_info_s { + char path[PATH_MAX]; + int present; + int busno; + int addr; +}; + +/** led_id */ +typedef enum led_id_e { + LED_ID_SYSTEM = 1, + LED_ID_FAN = 2, + LED_ID_PSU_1 = 3, + LED_ID_PSU_2 = 4, + LED_ID_FAN_FAIL_1 = 5, + LED_ID_FAN_FAIL_2 = 6, + LED_ID_FAN_FAIL_3 = 7, + LED_ID_FAN_FAIL_4 = 8, +} led_id_t; + +/** Enum names. */ +const char* led_id_name(led_id_t e); + +/** Enum values. */ +int led_id_value(const char* str, led_id_t* e, int substr); + +/** Enum descriptions. */ +const char* led_id_desc(led_id_t e); + +/** Enum validator. */ +int led_id_valid(led_id_t e); + +/** validator */ +#define LED_ID_VALID(_e) \ + (led_id_valid((_e))) + +/** led_id_map table. */ +extern aim_map_si_t led_id_map[]; +/** led_id_desc_map table. */ +extern aim_map_si_t led_id_desc_map[]; + +/** led_oid */ +typedef enum led_oid_e { + LED_OID_SYSTEM = ONLP_LED_ID_CREATE(LED_ID_SYSTEM), + LED_OID_FAN = ONLP_LED_ID_CREATE(LED_ID_FAN), + LED_OID_PSU_1 = ONLP_LED_ID_CREATE(LED_ID_PSU_1), + LED_OID_PSU_2 = ONLP_LED_ID_CREATE(LED_ID_PSU_2), + LED_OID_FAN_FAIL_1 = ONLP_LED_ID_CREATE(LED_ID_FAN_FAIL_1), + LED_OID_FAN_FAIL_2 = ONLP_LED_ID_CREATE(LED_ID_FAN_FAIL_2), + LED_OID_FAN_FAIL_3 = ONLP_LED_ID_CREATE(LED_ID_FAN_FAIL_3), + LED_OID_FAN_FAIL_4 = ONLP_LED_ID_CREATE(LED_ID_FAN_FAIL_4), +} led_oid_t; + +/** Enum names. */ +const char* led_oid_name(led_oid_t e); + +/** Enum values. */ +int led_oid_value(const char* str, led_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* led_oid_desc(led_oid_t e); + +/** Enum validator. */ +int led_oid_valid(led_oid_t e); + +/** validator */ +#define LED_OID_VALID(_e) \ + (led_oid_valid((_e))) + +/** led_oid_map table. */ +extern aim_map_si_t led_oid_map[]; +/** led_oid_desc_map table. */ +extern aim_map_si_t led_oid_desc_map[]; +/* */ + +struct led_control_s{ + int PMCnt; + int psu_status_changed; + int fan_status_changed; + int psu1_present; + int psu2_present; + int psu1_power_good; + int psu2_power_good; + int fan1_present; + int fan2_present; + int fan3_present; + int fan4_present; +}; + +#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" + +#endif /* __X86_64_QUANTA_IX1B_RGLBMC_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c new file mode 100755 index 00000000..555f1be9 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ix1b_rglbmc_log.h" +/* + * x86_64_quanta_ix1b_rglbmc log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_QUANTA_IX1B_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h new file mode 100755 index 00000000..54251205 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX1B_RGLBMC_LOG_H__ +#define __X86_64_QUANTA_IX1B_RGLBMC_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_quanta_ix1b_rglbmc +#include + +#endif /* __X86_64_QUANTA_IX1B_RGLBMC_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c new file mode 100755 index 00000000..5bb979a8 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ix1b_rglbmc_log.h" + +static int +datatypes_init__(void) +{ +#define X86_64_QUANTA_IX1B_RGLBMC_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_quanta_ix1b_rglbmc_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c new file mode 100755 index 00000000..14397e5c --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_QUANTA_IX1B_RGLBMC_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_quanta_ix1b_rglbmc_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ix1b_rglbmc) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_quanta_ix1b_rglbmc_ucli_module__ = + { + "x86_64_quanta_ix1b_rglbmc_ucli", + NULL, + x86_64_quanta_ix1b_rglbmc_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_quanta_ix1b_rglbmc_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_quanta_ix1b_rglbmc_ucli_module__); + n = ucli_node_create("x86_64_quanta_ix1b_rglbmc", NULL, &x86_64_quanta_ix1b_rglbmc_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ix1b_rglbmc")); + return n; +} + +#else +void* +x86_64_quanta_ix1b_rglbmc_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/PKG.yml new file mode 100755 index 00000000..de85e992 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix1b-rglbmc REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml new file mode 100755 index 00000000..bfe684bd --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for IX1B +# +###################################################################### + +x86-64-quanta-ix1b-rglbmc-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + console=ttyS1,115200n8 + reboot=c,p + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py new file mode 100755 index 00000000..882b0132 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py @@ -0,0 +1,23 @@ +from onl.platform.base import * +from onl.platform.quanta import * + +class OnlPlatform_x86_64_quanta_ix1b_rglbmc_r0(OnlPlatformQuanta, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-quanta-ix1b-rglbmc-r0' + MODEL="IX1B" + """ Define Quanta SYS_OBJECT_ID rule. + + SYS_OBJECT_ID = .xxxx.ABCC + "xxxx" define QCT device mark. For example, LB9->1048, LY2->3048 + "A" define QCT switch series name: LB define 1, LY define 2, IX define 3 + "B" define QCT switch series number 1: For example, LB9->9, LY2->2 + "CC" define QCT switch series number 2: For example, LY2->00, LY4R->18(R is 18th english letter) + """ + SYS_OBJECT_ID=".7032.3102" + + def baseconfig(self): + self.insmod("qci_pmbus") + self.insmod("qci_cpld") + self.insmod("quanta_platform_ix1b") + + return True From 87cd765b8ce809e50b1fc9b3471c27b8d72cf939 Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Mon, 10 Jul 2017 15:42:38 +0800 Subject: [PATCH 004/244] [Quanta-IX1,LY4R] Update ONLP: 1. Add sfp functions of onlp_sfpi_control_set() and onlp_sfpi_control_get() --- .../module/src/sfpi.c | 190 ++++++++++++++---- .../x86_64_quanta_ly4r_gpio_table.h | 15 ++ .../src/x86_64_quanta_ly4r/module/src/sfpi.c | 101 +++++++++- 3 files changed, 261 insertions(+), 45 deletions(-) diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sfpi.c index ffcfde0b..d5ea1b29 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sfpi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sfpi.c @@ -28,7 +28,7 @@ #include #include #include "x86_64_quanta_ix1_rangeley_log.h" - +#include #include #include @@ -46,40 +46,54 @@ typedef struct sfpmap_s { static sfpmap_t sfpmap__[] = { - { 1, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-1/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-32/32-0050/eeprom", NULL }, - { 2, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-2/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-33/33-0050/eeprom", NULL }, - { 3, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-3/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-34/34-0050/eeprom", NULL }, - { 4, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-4/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-35/35-0050/eeprom", NULL }, - { 5, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-5/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-36/36-0050/eeprom", NULL }, - { 6, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-6/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-37/37-0050/eeprom", NULL }, - { 7, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-7/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-38/38-0050/eeprom", NULL }, - { 8, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-8/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-39/39-0050/eeprom", NULL }, - { 9, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-9/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-40/40-0050/eeprom", NULL }, - { 10, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-10/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-41/41-0050/eeprom", NULL }, - { 11, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-11/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-42/42-0050/eeprom", NULL }, - { 12, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-12/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-43/43-0050/eeprom", NULL }, - { 13, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-13/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-44/44-0050/eeprom", NULL }, - { 14, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-14/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-45/45-0050/eeprom", NULL }, - { 15, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-15/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-46/46-0050/eeprom", NULL }, - { 16, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-16/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-47/47-0050/eeprom", NULL }, - { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-17/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-48/48-0050/eeprom", NULL }, - { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-18/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-49/49-0050/eeprom", NULL }, - { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-19/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-50/50-0050/eeprom", NULL }, - { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-20/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-51/51-0050/eeprom", NULL }, - { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-21/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-52/52-0050/eeprom", NULL }, - { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-22/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-53/53-0050/eeprom", NULL }, - { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-23/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-54/54-0050/eeprom", NULL }, - { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-24/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-55/55-0050/eeprom", NULL }, - { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-25/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-56/56-0050/eeprom", NULL }, - { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-26/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-57/57-0050/eeprom", NULL }, - { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-27/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-58/58-0050/eeprom", NULL }, - { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-28/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-59/59-0050/eeprom", NULL }, - { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-29/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-60/60-0050/eeprom", NULL }, - { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-30/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-61/61-0050/eeprom", NULL }, - { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-31/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-62/62-0050/eeprom", NULL }, - { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-32/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-63/63-0050/eeprom", NULL }, + { 1, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-1/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-32/32-0050/eeprom", NULL }, + { 2, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-2/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-33/33-0050/eeprom", NULL }, + { 3, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-3/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-34/34-0050/eeprom", NULL }, + { 4, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-4/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-35/35-0050/eeprom", NULL }, + { 5, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-5/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-36/36-0050/eeprom", NULL }, + { 6, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-6/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-37/37-0050/eeprom", NULL }, + { 7, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-7/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-38/38-0050/eeprom", NULL }, + { 8, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-8/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-39/39-0050/eeprom", NULL }, + { 9, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-9/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-40/40-0050/eeprom", NULL }, + { 10, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-10/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-41/41-0050/eeprom", NULL }, + { 11, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-11/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-42/42-0050/eeprom", NULL }, + { 12, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-12/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-43/43-0050/eeprom", NULL }, + { 13, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-13/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-44/44-0050/eeprom", NULL }, + { 14, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-14/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-45/45-0050/eeprom", NULL }, + { 15, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-15/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-46/46-0050/eeprom", NULL }, + { 16, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-qsfp28/port-16/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-47/47-0050/eeprom", NULL }, + { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-17/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-48/48-0050/eeprom", NULL }, + { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-18/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-49/49-0050/eeprom", NULL }, + { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-19/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-50/50-0050/eeprom", NULL }, + { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-20/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-51/51-0050/eeprom", NULL }, + { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-21/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-52/52-0050/eeprom", NULL }, + { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-22/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-53/53-0050/eeprom", NULL }, + { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-23/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-54/54-0050/eeprom", NULL }, + { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-24/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-55/55-0050/eeprom", NULL }, + { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-25/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-56/56-0050/eeprom", NULL }, + { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-26/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-57/57-0050/eeprom", NULL }, + { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-27/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-58/58-0050/eeprom", NULL }, + { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-28/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-59/59-0050/eeprom", NULL }, + { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-29/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-60/60-0050/eeprom", NULL }, + { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-30/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-61/61-0050/eeprom", NULL }, + { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-31/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-62/62-0050/eeprom", NULL }, + { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-qsfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-63/63-0050/eeprom", NULL }, }; +#define SFP_GET(_port) (sfpmap__ + _port - 1) +#define MAX_SFP_PATH 128 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sfpmap_t* sfp = SFP_GET(port); + + sprintf(sfp_node_path, sfp->present_cpld, + node_name); + return sfp_node_path; +} + int onlp_sfpi_init(void) { @@ -104,14 +118,10 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) return ONLP_STATUS_OK; } -#define SFP_GET(_port) (sfpmap__ + _port - 1) - int onlp_sfpi_is_present(int port) { - sfpmap_t* sfp = SFP_GET(port); - - return onlplib_sfp_is_present_file(sfp->present_cpld, /* Present */ "1\n", /* Absent */ "0\n"); + return onlplib_sfp_is_present_file(sfp_get_port_path(port, "module_present"), /* Present */ "1\n", /* Absent */ "0\n"); } int @@ -128,3 +138,107 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) return onlplib_sfp_eeprom_read_file(sfp->dom, data); } +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + char* path = NULL; + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + path = sfp_get_port_path(port, "reset"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set reset status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + path = sfp_get_port_path(port, "lpmode"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + char* path = NULL; + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + path = sfp_get_port_path(port, "reset"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + path = sfp_get_port_path(port, "lpmode"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read lpmode status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_RX_LOS: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h index 1794e95f..030c4b7c 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h @@ -12,11 +12,26 @@ #define QUANTA_LY4R_I2C_GPIO_BASE 0x10 #define QUANTA_LY4R_PCA9698_GPIO_BASE (QUANTA_LY4R_I2C_GPIO_BASE) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_1_TX_FAULT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,0)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_1_TX_DIS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,1)) #define QUANTA_LY4R_PCA9698_GPIO_SFP_1_PRSNT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,2)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_1_RX_LOS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,3)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_2_TX_FAULT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,4)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_2_TX_DIS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,5)) #define QUANTA_LY4R_PCA9698_GPIO_SFP_2_PRSNT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,6)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_2_RX_LOS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(0,7)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_3_TX_FAULT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,0)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_3_TX_DIS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,1)) #define QUANTA_LY4R_PCA9698_GPIO_SFP_3_PRSNT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,2)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_3_RX_LOS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,3)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_4_TX_FAULT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,4)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_4_TX_DIS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,5)) #define QUANTA_LY4R_PCA9698_GPIO_SFP_4_PRSNT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,6)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_4_RX_LOS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(1,7)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_5_TX_FAULT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,0)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_5_TX_DIS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,1)) #define QUANTA_LY4R_PCA9698_GPIO_SFP_5_PRSNT_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,2)) +#define QUANTA_LY4R_PCA9698_GPIO_SFP_5_RX_LOS_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,3)) #define QUANTA_LY4R_PCA9698_BOOT_STSLED_N (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,4)) #define QUANTA_LY4R_PCA9698_SYS_STSLED (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,5)) #define QUANTA_LY4R_PCA9698_GPIO_SFP_P3V3_PW_EN (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,6)) diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/sfpi.c index 7e1f6861..ceba9fe4 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/sfpi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/sfpi.c @@ -28,7 +28,7 @@ #include #include #include "x86_64_quanta_ly4r_log.h" - +#include #include #include @@ -39,18 +39,20 @@ typedef struct sfpmap_s { int port; int present_gpio; - const char* reset_gpio; + int tx_fault_gpio; + int tx_dis_gpio; + int rx_los_gpio; const char* eeprom; const char* dom; } sfpmap_t; static sfpmap_t sfpmap__[] = { - { 49, QUANTA_LY4R_PCA9698_GPIO_SFP_1_PRSNT_N, NULL, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-32/32-0050/eeprom", NULL }, - { 50, QUANTA_LY4R_PCA9698_GPIO_SFP_2_PRSNT_N, NULL, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-33/33-0050/eeprom", NULL }, - { 51, QUANTA_LY4R_PCA9698_GPIO_SFP_3_PRSNT_N, NULL, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-34/34-0050/eeprom", NULL }, - { 52, QUANTA_LY4R_PCA9698_GPIO_SFP_4_PRSNT_N, NULL, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-35/35-0050/eeprom", NULL }, - { 53, QUANTA_LY4R_PCA9698_GPIO_SFP_5_PRSNT_N, NULL, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-36/36-0050/eeprom", NULL }, + { 49, QUANTA_LY4R_PCA9698_GPIO_SFP_1_PRSNT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_1_TX_FAULT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_1_TX_DIS_N, QUANTA_LY4R_PCA9698_GPIO_SFP_1_RX_LOS_N, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-32/32-0050/eeprom", NULL }, + { 50, QUANTA_LY4R_PCA9698_GPIO_SFP_2_PRSNT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_2_TX_FAULT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_2_TX_DIS_N, QUANTA_LY4R_PCA9698_GPIO_SFP_2_RX_LOS_N, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-33/33-0050/eeprom", NULL }, + { 51, QUANTA_LY4R_PCA9698_GPIO_SFP_3_PRSNT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_3_TX_FAULT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_3_TX_DIS_N, QUANTA_LY4R_PCA9698_GPIO_SFP_3_RX_LOS_N, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-34/34-0050/eeprom", NULL }, + { 52, QUANTA_LY4R_PCA9698_GPIO_SFP_4_PRSNT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_4_TX_FAULT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_4_TX_DIS_N, QUANTA_LY4R_PCA9698_GPIO_SFP_4_RX_LOS_N, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-35/35-0050/eeprom", NULL }, + { 53, QUANTA_LY4R_PCA9698_GPIO_SFP_5_PRSNT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_5_TX_FAULT_N, QUANTA_LY4R_PCA9698_GPIO_SFP_5_TX_DIS_N, QUANTA_LY4R_PCA9698_GPIO_SFP_5_RX_LOS_N, "/sys/devices/pci0000:00/0000:00:13.0/i2c-1/i2c-36/36-0050/eeprom", NULL }, }; #define SFP_GET(_port) (sfpmap__ + _port - 49) @@ -72,6 +74,10 @@ onlp_sfpi_init(void) for(i = 49; i < 54; i++) { sfp = SFP_GET(i); onlp_gpio_export(sfp->present_gpio, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(sfp->tx_fault_gpio, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(sfp->tx_dis_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(sfp->tx_dis_gpio, 1); + onlp_gpio_export(sfp->rx_los_gpio, ONLP_GPIO_DIRECTION_IN); } return ret; @@ -140,3 +146,84 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) return onlplib_sfp_eeprom_read_file(sfp->dom, data); } +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + sfpmap_t* sfp = SFP_GET(port); + + switch(control){ + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if(onlp_gpio_set(sfp->tx_dis_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + sfpmap_t* sfp = SFP_GET(port); + + switch(control){ + case ONLP_SFP_CONTROL_TX_FAULT: + { + if(onlp_gpio_get(sfp->tx_fault_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if(onlp_gpio_get(sfp->tx_dis_gpio, value) == ONLP_STATUS_OK){ + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read tx_disable status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_RX_LOS: + { + if(onlp_gpio_get(sfp->rx_los_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} From 5eb6952d8789492b687ead3a4418f05c654cd33d Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Wed, 19 Jul 2017 08:18:16 +0800 Subject: [PATCH 005/244] [Quanta-LY4R,IX1B] Update ONLP: 1. Remove all AIM_LOG_MSG statements because these are always output regardless of the logging level --- .../src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c | 4 ---- .../src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c | 2 -- .../onlp/builds/src/x86_64_quanta_ly4r/module/src/fani.c | 9 --------- .../onlp/builds/src/x86_64_quanta_ly4r/module/src/psui.c | 8 -------- .../builds/src/x86_64_quanta_ly4r/module/src/thermali.c | 4 ---- 5 files changed, 27 deletions(-) diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c index 4ae5ff48..3a661184 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/fani.c @@ -23,16 +23,12 @@ * ***********************************************************/ #include - #include "x86_64_quanta_ix1b_rglbmc_int.h" -#include "x86_64_quanta_ix1b_rglbmc_log.h" - #include int onlp_fani_init(void) { - AIM_LOG_MSG("ONLP is not supported for FAN"); return ONLP_STATUS_E_UNSUPPORTED; } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c index f2528838..2a84c017 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c @@ -23,11 +23,9 @@ * ***********************************************************/ #include -#include "x86_64_quanta_ix1b_rglbmc_log.h" int onlp_thermali_init(void) { - AIM_LOG_MSG("ONLP is not supported for THERMAL"); return ONLP_STATUS_E_UNSUPPORTED; } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/fani.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/fani.c index b305bbd8..7594b0ca 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/fani.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/fani.c @@ -22,19 +22,10 @@ * * ***********************************************************/ -#include -#include #include -#include "x86_64_quanta_ly4r_int.h" -#include "x86_64_quanta_ly4r_log.h" - -#include -#include - int onlp_fani_init(void) { - AIM_LOG_MSG("ONLP is not supported for FAN"); return ONLP_STATUS_E_UNSUPPORTED; } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/psui.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/psui.c index c8d46771..b5cedce1 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/psui.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/psui.c @@ -6,18 +6,10 @@ * * ***********************************************************/ -#include -#include #include -#include -#include -#include "x86_64_quanta_ly4r_int.h" -#include "x86_64_quanta_ly4r_log.h" -#include int onlp_psui_init(void) { - AIM_LOG_MSG("ONLP is not supported for RPSU"); return ONLP_STATUS_E_UNSUPPORTED; } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/thermali.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/thermali.c index 91780b16..2a84c017 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/thermali.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/thermali.c @@ -23,13 +23,9 @@ * ***********************************************************/ #include -#include -#include "x86_64_quanta_ly4r_int.h" -#include "x86_64_quanta_ly4r_log.h" int onlp_thermali_init(void) { - AIM_LOG_MSG("ONLP is not supported for THERMAL"); return ONLP_STATUS_E_UNSUPPORTED; } From 1547f487a746d46d78bc4ce90114c200e33aa218 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 12 Sep 2017 11:28:10 -0700 Subject: [PATCH 006/244] Initial checkin - wrapper for some AIM classes (probably the wrong package) - wrap a subset of libonlp - wrap onlp.h, sys.h, oids.h - sample unit tests - sample onlpdump.py --- packages/base/any/onlp/APKG.yml | 5 + .../src/onlp/module/python/onlp/__init__.py | 4 + .../onlp/module/python/onlp/onlp/__init__.py | 261 ++++++++++++++++++ .../module/python/onlp/test/OnlpApiTest.py | 236 ++++++++++++++++ .../onlp/module/python/onlp/test/__init__.py | 4 + packages/base/any/onlp/src/onlpdump.py | 36 +++ .../module/python/onlp/onlplib/__init__.py | 87 ++++++ 7 files changed, 633 insertions(+) create mode 100644 packages/base/any/onlp/src/onlp/module/python/onlp/__init__.py create mode 100644 packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py create mode 100644 packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py create mode 100644 packages/base/any/onlp/src/onlp/module/python/onlp/test/__init__.py create mode 100755 packages/base/any/onlp/src/onlpdump.py create mode 100644 packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib/__init__.py diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml index a245d8ec..2144913b 100644 --- a/packages/base/any/onlp/APKG.yml +++ b/packages/base/any/onlp/APKG.yml @@ -26,6 +26,11 @@ packages: builds/onlp-platform/$BUILD_DIR/${TOOLCHAIN}/bin/libonlp-platform.so : $libdir/ builds/onlp-platform-defaults/$BUILD_DIR/${TOOLCHAIN}/bin/libonlp-platform-defaults.so : $libdir/ builds/onlpd/$BUILD_DIR/${TOOLCHAIN}/bin/onlpd : $bindir/ + ${ONL}/packages/base/any/onlp/src/onlpdump.py: $bindir/ + ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/*.py: ${PY_INSTALL}/onlp/ + ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/*.py: ${PY_INSTALL}/onlp/onlp/ + ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/test/*.py: ${PY_INSTALL}/onlp/test/ + ${ONL}/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib/*.py: ${PY_INSTALL}/onlp/onlplib/ init: $ONL/packages/base/any/onlp/src/onlpd.init diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/__init__.py new file mode 100644 index 00000000..cd682130 --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/__init__.py @@ -0,0 +1,4 @@ +"""__init__.py + +Module init for onlp. +""" diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py new file mode 100644 index 00000000..a0ba3412 --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -0,0 +1,261 @@ +"""__init__.py + +Module init for onlp.onlp +""" + +import ctypes + +libonlp = ctypes.cdll.LoadLibrary("libonlp.so") + +import ctypes.util +libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) + +import onlp.onlplib + +# AIM/aim_memory.h + +class aim_void_p(ctypes.c_void_p): + """Generic data allocated by AIM.""" + def __del__(self): + libonlp.aim_free(self) + +class aim_char_p(aim_void_p): + """AIM data that is a printable string.""" + + def __init__(self, stringOrAddress): + + if stringOrAddress is None: + aim_void_p.__init__(self, stringOrAddress) + return + + if isinstance(stringOrAddress, aim_void_p): + aim_void_p.__init__(self, stringOrAddress) + return + + if isinstance(stringOrAddress, basestring): + cs = ctypes.c_char_p(stringOrAddress) + ptr = libonlp.aim_malloc(len(stringOrAddress)+1) + libc.strcpy(ptr, ctypes.addressof(cs)) + aim_void_p.__init__(self, ptr) + return + + if type(stringOrAddress) == int: + aim_void_p.__init__(self, stringOrAddress) + return + + raise ValueError("invalid initializer for aim_char_p: %s" + % repr(stringOrAddress)) + + def string_at(self): + if self.value: + return ctypes.string_at(self.value) + else: + return None + + def __eq__(self, other): + return (isinstance(other, aim_char_p) + and (self.string_at()==other.string_at())) + + def __neq__(self, other): + return not self == other + + def __hash__(self): + return hash(self.string_at()) + +def aim_memory_init_prototypes(): + + libonlp.aim_malloc.restype = aim_void_p + libonlp.aim_malloc.argtypes = (ctypes.c_size_t,) + + libonlp.aim_free.restype = None + libonlp.aim_free.argtypes = (aim_void_p,) + +# AIM/aim_object.h + +aim_object_dtor = ctypes.CFUNCTYPE(None, ctypes.c_void_p) + +class aim_object(ctypes.Structure): + _fields_ = [("_id", ctypes.c_char_p,), + ("subtype", ctypes.c_int,), + ("cookie", ctypes.c_void_p,), + ("destructor", aim_object_dtor,),] + +# AIM/aim_pvs.h +# AIM/aim_pvs_*.h + +aim_vprintf_f = ctypes.CFUNCTYPE(ctypes.c_int) + +class aim_pvs(ctypes.Structure): + _fields_ = [("object", aim_object,), + ("description", ctypes.c_char_p,), + ("vprintf", aim_vprintf_f,), + ("enabled", ctypes.c_int,), + ("counter", ctypes.c_uint,), + ("isatty", aim_vprintf_f,),] + +def aim_pvs_init_prototypes(): + + libonlp.aim_pvs_buffer_create.restype = ctypes.POINTER(aim_pvs) + + libonlp.aim_pvs_destroy.restype = None + libonlp.aim_pvs_destroy.argtypes = (ctypes.POINTER(aim_pvs),) + + libonlp.aim_pvs_buffer_size.restype = ctypes.c_int + libonlp.aim_pvs_buffer_size.argtypes = (ctypes.POINTER(aim_pvs),) + + libonlp.aim_pvs_buffer_get.restype = aim_char_p + libonlp.aim_pvs_buffer_get.argtypes = (ctypes.POINTER(aim_pvs),) + + libonlp.aim_pvs_buffer_reset.restype = None + libonlp.aim_pvs_buffer_reset.argtypes = (ctypes.POINTER(aim_pvs),) + +# onlp/oids.h + +onlp_oid = ctypes.c_uint + +ONLP_OID_DESC_SIZE = 128 +ONLP_OID_TABLE_SIZE = 32 + +ONLP_OID_DUMP_F_RECURSE = 0x1 +ONLP_OID_DUMP_F_EVEN_IF_ABSENT = 0x2 + +ONLP_OID_SHOW_F_RECURSE = 0x1 +ONLP_OID_SHOW_F_EXTENDED = 0x2 +ONLP_OID_SHOW_F_YAML = 0x4 + +class OidTableIterator(object): + + def __init__(self, hdr): + self.hdr = hdr + self.idx = 0 + + def __iter__(self): + return self + + def next(self): + if self.idx >= ONLP_OID_TABLE_SIZE: + raise StopIteration + oid = self.hdr.coids[self.idx] + self.idx += 1 + if oid == 0: + raise StopIteration + oidHdr = onlp_oid_hdr() + libonlp.onlp_oid_hdr_get(oid, ctypes.byref(oidHdr)) + return oidHdr + +ONLP_OID_TYPE_SYS = 1 +ONLP_OID_TYPE_THERMAL = 2 +ONLP_OID_TYPE_FAN = 3 +ONLP_OID_TYPE_PSU = 4 +ONLP_OID_TYPE_LED = 5 +ONLP_OID_TYPE_MODULE = 6 +ONLP_OID_TYPE_RTC = 7 +# XXX roth waiting for enum generator + +class onlp_oid_hdr(ctypes.Structure): + + _fields_ = [("_id", onlp_oid,), + ("description", ctypes.c_char * ONLP_OID_DESC_SIZE,), + ("poid", onlp_oid,), + ("coids", onlp_oid * ONLP_OID_TABLE_SIZE,),] + + def getType(self): + return self._id >> 24 + + def isSystem(self): + return self.getType() == ONLP_OID_TYPE_SYS + def isThermal(self): + return self.getType() == ONLP_OID_TYPE_THERMAL + def isFan(self): + return self.getType() == ONLP_OID_TYPE_FAN + def isPsu(self): + return self.getType() == ONLP_OID_TYPE_PSU + def isLed(self): + return self.getType() == ONLP_OID_TYPE_LED + def isModule(self): + return self.getType() == ONLP_OID_TYPE_MODULE + def isRtc(self): + return self.getType() == ONLP_OID_TYPE_RTC + + def children(self): + return OidTableIterator(self) + +onlp_oid_iterate_f = ctypes.CFUNCTYPE(ctypes.c_int, onlp_oid, ctypes.c_void_p) + +def onlp_oid_init_prototypes(): + + #onlp_oid_dump + #onlp_oid_table_dump + #onlp_oid_show + #onlp_oid_table_show + + libonlp.onlp_oid_iterate.restype = ctypes.c_int + libonlp.onlp_oid_iterate.argtypes = (onlp_oid, ctypes.c_int, + onlp_oid_iterate_f, ctypes.c_void_p,) + # XXX enum + + libonlp.onlp_oid_hdr_get.restype = ctypes.c_int + libonlp.onlp_oid_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr,)) + # XXX enum + +# onlp/sys.h + +class onlp_sys_info(ctypes.Structure): + + initialized = False + + _fields_ = [("hdr", onlp_oid_hdr,), + ("onie_info", onlp.onlplib.onlp_onie_info,), + ("platform_info", onlp.onlplib.onlp_platform_info,),] + + def __del__(self): + if self.initialized: + libonlp.onlp_sys_info_free(ctypes.byref(self)) + +def onlp_sys_init_prototypes(): + + libonlp.onlp_sys_init.restype = ctypes.c_int + + libonlp.onlp_sys_info_get.restype = ctypes.c_int + libonlp.onlp_sys_info_get.argtypes = (ctypes.POINTER(onlp_sys_info),) + + libonlp.onlp_sys_info_free.restype = None + libonlp.onlp_sys_info_get.argtypes = (ctypes.POINTER(onlp_sys_info),) + + libonlp.onlp_sys_hdr_get.restype = ctypes.c_int + libonlp.onlp_sys_hdr_get.argtypes = (ctypes.POINTER(onlp_oid_hdr),) + + libonlp.onlp_sys_dump.restype = None + libonlp.onlp_sys_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_sys_show.restype = None + libonlp.onlp_sys_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_sys_ioctl.restype = ctypes.c_int + # leave the parameters empty (varargs) + + ##libonlp.onlp_sys_vioctl.restype = ctypes.c_int + # NOTE that ctypes cannot automatically handle va_list + + libonlp.onlp_sys_platform_manage_start.restype = ctypes.c_int + libonlp.onlp_sys_platform_manage_start.argtypes = (ctypes.c_int,) + + libonlp.onlp_sys_platform_manage_stop.restype = ctypes.c_int + libonlp.onlp_sys_platform_manage_stop.argtypes = (ctypes.c_int,) + + libonlp.onlp_sys_platform_manage_join.restype = ctypes.c_int + + libonlp.onlp_sys_platform_manage_now.restype = None + + libonlp.onlp_sys_debug.restype = ctypes.c_int + libonlp.onlp_sys_debug.argtypes = (ctypes.POINTER(aim_pvs), ctypes.c_int, + ctypes.POINTER(ctypes.POINTER(ctypes.c_char)),) + +# onlp/onlp.h + +def onlp_init(): + libonlp.onlp_init() + aim_memory_init_prototypes() + aim_pvs_init_prototypes() + onlp_oid_init_prototypes() + onlp_sys_init_prototypes() diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py new file mode 100644 index 00000000..f5ce59a3 --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -0,0 +1,236 @@ +"""OnlpApiTest.py + +Test the API bindings. +""" + +import ctypes +import unittest +import logging +import re + +import onlp.onlp +onlp.onlp.onlp_init() + +libonlp = onlp.onlp.libonlp + +class OnlpTestMixin(object): + + def setUp(self): + + self.log = logging.getLogger("onlp") + self.log.setLevel(logging.DEBUG) + + self.aim_pvs_buffer_p = libonlp.aim_pvs_buffer_create() + self.aim_pvs_buffer = self.aim_pvs_buffer_p.contents + + def tearDown(self): + + libonlp.aim_pvs_destroy(self.aim_pvs_buffer_p) + +class InitTest(OnlpTestMixin, + unittest.TestCase): + + def setUp(self): + OnlpTestMixin.setUp(self) + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testInit(self): + """Verify that the library can be loaded.""" + pass + + def testBuffer(self): + """Verify that the AIM buffer type is usable.""" + + nullString = onlp.onlp.aim_char_p(None) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertEqual(nullString, buf) + + libonlp.aim_printf(self.aim_pvs_buffer_p, "hello\n") + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertEqual("hello\n", buf.string_at()) + + libonlp.aim_printf(self.aim_pvs_buffer_p, "world\n") + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertEqual("hello\nworld\n", buf.string_at()) + + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertEqual(nullString, buf) + +class OnlpTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/onlp.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testPlatformDump(self): + """Verify basic platform dump output.""" + + flags = 0 + libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("System Information:", bufStr) + self.assertIn("thermal @ 1", bufStr) + + def testPlatformDumpFlags(self): + """Verify platform dump flags are honored.""" + + flags = 0 + libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("psu @ 1", bufStr) + self.assertNotIn("PSU-1 Fan", bufStr) + + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + + flags = onlp.onlp.ONLP_OID_DUMP_F_RECURSE + libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("psu @ 1", bufStr) + self.assertIn("PSU-1 Fan", bufStr) + + # hard to test onlp.onlp.ONLP_OID_DUMP_F_RECURSE, + # since it depends on whether a specific component is inserted + + def testPlatformShow(self): + """Verify basic platform show output.""" + + flags = 0 + libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("System Information:", bufStr) + + def testPlatformShowFlags(self): + """Verify that onlp_platform_show honors flags.""" + + flags = 0 + libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertNotIn("PSU 1", bufStr) + self.assertNotIn("PSU-1 Fan", bufStr) + + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + + flags = onlp.onlp.ONLP_OID_SHOW_F_RECURSE + libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("PSU 1", bufStr) + self.assertIn("PSU-1 Fan", bufStr) + +class SysTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/sys.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_sys_init() + self.sys_info = onlp.onlp.onlp_sys_info() + + libonlp.onlp_sys_info_get(ctypes.byref(self.sys_info)) + self.sys_info.initialized = True + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testNoop(self): + pass + + def testOnieInfo(self): + """Verify the ONIE fields.""" + + product_re = re.compile("(.*)-(.*)-(.*)") + m = product_re.match(self.sys_info.onie_info.product_name) + self.assertIsNotNone(m) + + vendor_re = re.compile("[A-Z][a-z]*[a-zA-Z0-9_. -]") + m = vendor_re.match(self.sys_info.onie_info.vendor) + self.assertIsNotNone(m) + + self.assertIn('.', self.sys_info.onie_info.onie_version) + + # see if there are any vendor extensions + # if there are any, make sure the are well-formed + for vx in self.sys_info.onie_info.vx_list: + sz = vx.size + self.assert_(sz <= 256) + + def testPlatformInfo(self): + """Verify the platform info fields.""" + # XXX VM platforms have null for both + pass + + def auditOidHdr(self, hdr): + + self.assertEqual(0, hdr.poid) + self.assertEqual(0, hdr._id) + # root OID + + coids = [x for x in hdr.children()] + self.assert_(coids) + self.assert_(len(coids) < onlp.onlp.ONLP_OID_TABLE_SIZE) + + def _oidType(oid): + if oid.isSystem(): + return "sys" + if oid.isThermal(): + return "thm" + if oid.isFan(): + return "fan" + if oid.isPsu(): + return "psu" + if oid.isLed(): + return "led" + if oid.isModule(): + return "mod" + if oid.isRtc(): + return "rtc" + return "unk" + + for coid in coids: + self.log.info("oid %d (%s): %s", + coid._id, _oidType(coid), coid.description) + if _oidType(coid) == "unk": + raise AssertionError("invalid oid") + self.assertEqual(hdr._id, coid.poid) + + # if it's a PSU, verify that it has fans + if _oidType(coid) == "psu": + foids = [x for x in coid.children()] + for foid in foids: + self.log.info("oid %d (%s): %s", + foid._id, _oidType(foid), foid.description) + self.assertEqual("fan", _oidType(foid)) + # parent should the the PSU or the chassis + if coid._id == foid.poid: + pass + elif hdr._id == foid.poid: + pass + else: + raise AssertionError("invalid parent OID") + + def testSysHeaderOnie(self): + """Test the sys_hdr data that is in the sys_info.""" + self.auditOidHdr(self.sys_info.hdr) + + # test the iteration of the oid table + + def testSysHeader(self): + """Test the sys_hdr data available via sys_hdr_get.""" + pass + +if __name__ == "__main__": + logging.basicConfig() + unittest.main() diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/__init__.py new file mode 100644 index 00000000..512e8637 --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/__init__.py @@ -0,0 +1,4 @@ +"""__init__.py + +Test code for the onlp Python bindings. +""" diff --git a/packages/base/any/onlp/src/onlpdump.py b/packages/base/any/onlp/src/onlpdump.py new file mode 100755 index 00000000..87204cb8 --- /dev/null +++ b/packages/base/any/onlp/src/onlpdump.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +"""onldump.py + +Test harness for Python bindings. +""" + +import sys +from ctypes import * + +import logging + +import onlp.onlp +import onlp.onlplib + +logging.basicConfig() +logger = logging.getLogger("onlpdump") +logger.setLevel(logging.DEBUG) + +onlp.onlp.onlp_init() + +libonlp = onlp.onlp.libonlp +si = onlp.onlp.onlp_sys_info() +libonlp.onlp_sys_info_get(byref(si)) + +logger.info("hello") + +import pdb +pdb.set_trace() + +##libonlp.onlp_onie_show(byref(si.onie_info), byref(libonlp.aim_pvs_stdout)) +libonlp.onlp_platform_dump(libonlp.aim_pvs_stdout, + (onlp.onlp.ONLP_OID_DUMP_F_RECURSE + | onlp.onlp.ONLP_OID_DUMP_F_EVEN_IF_ABSENT)) + +sys.exit(0) diff --git a/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib/__init__.py b/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib/__init__.py new file mode 100644 index 00000000..f5d998bf --- /dev/null +++ b/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib/__init__.py @@ -0,0 +1,87 @@ +"""__init__.py + +Module init for onlp.onlplib +""" + +import ctypes + +# properly belongs in AIM.aim_list + +class list_links(ctypes.Structure): + pass + +list_links._fields_ = [("prev", ctypes.POINTER(list_links),), + ("next", ctypes.POINTER(list_links),),] + +class ListIterator(object): + + def __init__(self, links, castType=None): + self.links = links + self.castType = castType + self.cur = self.links.links.next + + def next(self): + + # Hurr, pointer()/POINTER() types are not directly comparable + p1 = ctypes.cast(self.cur, ctypes.c_void_p) + p2 = ctypes.cast(self.links.links.prev, ctypes.c_void_p) + if p1.value == p2.value: + raise StopIteration + + cur, self.cur = self.cur, self.cur.contents.next + if self.castType is not None: + cur = ctypes.cast(cur, ctypes.POINTER(self.castType)) + return cur.contents + +class list_head(ctypes.Structure): + _fields_ = [("links", list_links,),] + + links_klass = list_links + + def __iter__(self): + if self.links_klass == list_links: + return ListIterator(self) + else: + return ListIterator(self, castType=self.links_klass) + +class onlp_onie_vx(list_links): + # NOTE that Python inheritence merges the fields + # with the base class (ctypes-ism) + _fields_ = [("data", ctypes.c_ubyte * 256,), + ("size", ctypes.c_int,),] + +class onlp_onie_vx_list_head(list_head): + links_klass = onlp_onie_vx + +class onlp_onie_info(ctypes.Structure): + _fields_ = [("product_name", ctypes.c_char_p,), + ("part_number", ctypes.c_char_p,), + ("serial_number", ctypes.c_char_p,), + ("mac", ctypes.c_ubyte * 6,), + ("manufacture_date", ctypes.c_char_p,), + ("device_version", ctypes.c_ubyte,), + ("label_revision", ctypes.c_char_p,), + ("platform_name", ctypes.c_char_p,), + ("onie_version", ctypes.c_char_p,), + ("mac_range", ctypes.c_ushort,), + ("manufacturer", ctypes.c_char_p,), + ("country_code", ctypes.c_char_p,), + ("vendor", ctypes.c_char_p,), + ("diag_version", ctypes.c_char_p,), + ("service_tag", ctypes.c_char_p,), + ("crc", ctypes.c_uint,), + + # + # Vendor Extensions list, if available. + # + ("vx_list", onlp_onie_vx_list_head,), + + # Internal/debug + ("_hdr_id_string", ctypes.c_char_p,), + ("_hdr_version", ctypes.c_ubyte,), + ("_hdr_length", ctypes.c_ubyte,), + ("_hdr_valid_crc", ctypes.c_ubyte,),] + +class onlp_platform_info(ctypes.Structure): + _fields_ = [("cpld_versions", ctypes.c_char_p,), + ("other_versions", ctypes.c_char_p,),] From e8f044508bf40d3fd1623514451f8f14e06e5786 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 12 Sep 2017 15:46:08 -0700 Subject: [PATCH 007/244] Add the rest of the functions from oids.h, add the system OID --- .../onlp/module/python/onlp/onlp/__init__.py | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index a0ba3412..f5c70e8b 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -113,6 +113,17 @@ def aim_pvs_init_prototypes(): onlp_oid = ctypes.c_uint +ONLP_OID_TYPE_SYS = 1 +ONLP_OID_TYPE_THERMAL = 2 +ONLP_OID_TYPE_FAN = 3 +ONLP_OID_TYPE_PSU = 4 +ONLP_OID_TYPE_LED = 5 +ONLP_OID_TYPE_MODULE = 6 +ONLP_OID_TYPE_RTC = 7 +# XXX roth waiting for enum generator + +ONLP_OID_SYS = (ONLP_OID_TYPE_SYS<<24) | 1 + ONLP_OID_DESC_SIZE = 128 ONLP_OID_TABLE_SIZE = 32 @@ -143,15 +154,6 @@ class OidTableIterator(object): libonlp.onlp_oid_hdr_get(oid, ctypes.byref(oidHdr)) return oidHdr -ONLP_OID_TYPE_SYS = 1 -ONLP_OID_TYPE_THERMAL = 2 -ONLP_OID_TYPE_FAN = 3 -ONLP_OID_TYPE_PSU = 4 -ONLP_OID_TYPE_LED = 5 -ONLP_OID_TYPE_MODULE = 6 -ONLP_OID_TYPE_RTC = 7 -# XXX roth waiting for enum generator - class onlp_oid_hdr(ctypes.Structure): _fields_ = [("_id", onlp_oid,), @@ -184,10 +186,17 @@ onlp_oid_iterate_f = ctypes.CFUNCTYPE(ctypes.c_int, onlp_oid, ctypes.c_void_p) def onlp_oid_init_prototypes(): - #onlp_oid_dump - #onlp_oid_table_dump - #onlp_oid_show - #onlp_oid_table_show + libonlp.onlp_oid_dump.restype = None + libonlp.onlp_oid_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_oid_table_dump.restype = None + libonlp.onlp_oid_table_dump.argtypes = (ctypes.POINTER(onlp_oid), ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_oid_show.restype = None + libonlp.onlp_oid_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_oid_table_show.restype = None + libonlp.onlp_oid_table_show.argtypes = (ctypes.POINTER(onlp_oid), ctypes.POINTER(aim_pvs), ctypes.c_uint,) libonlp.onlp_oid_iterate.restype = ctypes.c_int libonlp.onlp_oid_iterate.argtypes = (onlp_oid, ctypes.c_int, From e74dde6277a3cedec95a4b8b945b5431be16f45f Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 12 Sep 2017 15:46:29 -0700 Subject: [PATCH 008/244] Finish testing oids.h, including the oid iterator --- .../module/python/onlp/test/OnlpApiTest.py | 123 +++++++++++++++++- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index f5ce59a3..0dfe43a7 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -175,7 +175,12 @@ class SysTest(OnlpTestMixin, def auditOidHdr(self, hdr): self.assertEqual(0, hdr.poid) - self.assertEqual(0, hdr._id) + if hdr._id == onlp.onlp.ONLP_OID_SYS: + pass + elif hdr._id == 0: + self.log.warn("invalid system OID 0") + else: + raise AssertionError("invalid system OID") # root OID coids = [x for x in hdr.children()] @@ -225,11 +230,121 @@ class SysTest(OnlpTestMixin, """Test the sys_hdr data that is in the sys_info.""" self.auditOidHdr(self.sys_info.hdr) - # test the iteration of the oid table - def testSysHeader(self): """Test the sys_hdr data available via sys_hdr_get.""" - pass + + hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_sys_hdr_get(ctypes.byref(hdr)) + self.auditOidHdr(hdr) + + def testOidIter(self): + """Test the oid iteration functions.""" + + class OidIterator(object): + + def __init__(self, log): + self.log = log or logging.getLogger("visit") + + def visit(self, oid, cookie): + return 0 + + def cvisit(self): + def _v(oid, cookie): + try: + return self.visit(oid, cookie) + except: + self.log.exception("visitor failed") + return -1 + return onlp.onlp.onlp_oid_iterate_f(_v) + + class V1(OidIterator): + + def __init__(self, cookie, log): + super(V1, self).__init__(log) + self.cookie = cookie + self.oids = [] + + def visit(self, oid, cookie): + if cookie != self.cookie: + raise AssertionError("invalid cookie") + self.log.info("found oid %d", oid) + self.oids.append(oid) + return 0 + + oidType = 0 + cookie = 0xdeadbeef + + # gather all OIDs + + v1 = V1(cookie, log=self.log.getChild("v1")) + libonlp.onlp_oid_iterate(self.sys_info.hdr._id, oidType, v1.cvisit(), cookie) + self.assert_(v1.oids) + oids = list(v1.oids) + + # validate error recovery + + v2 = V1(cookie+1, log=self.log.getChild("v2")) + libonlp.onlp_oid_iterate(self.sys_info.hdr._id, oidType, v2.cvisit(), cookie) + self.assertEqual([], v2.oids) + + # validate early exit + + class V3(OidIterator): + + def __init__(self, log): + super(V3, self).__init__(log) + self.oids = [] + + def visit(self, oid, cookie): + if oid == cookie: + return -1 + self.log.info("found oid %d", oid) + self.oids.append(oid) + return 0 + + v3 = V3(log=self.log.getChild("v3")) + cookie = oids[4] + libonlp.onlp_oid_iterate(self.sys_info.hdr._id, oidType, v3.cvisit(), cookie) + self.assertEqual(4, len(v3.oids)) + + def testOidDump(self): + oid = self.sys_info.hdr.coids[0] + flags = 0 + libonlp.onlp_oid_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertIn("Description:", buf.string_at()) + + def testOidTableDump(self): + tbl = self.sys_info.hdr.coids + flags = 0 + libonlp.onlp_oid_table_dump(tbl, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + lines = buf.string_at().splitlines(False) + lines = [x for x in lines if 'Description' in x] + self.assert_(len(lines) > 1) + + def testOidShow(self): + oid = self.sys_info.hdr.coids[0] + flags = 0 + libonlp.onlp_oid_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertIn("Description:", buf.string_at()) + + def testOidTableShow(self): + tbl = self.sys_info.hdr.coids + flags = 0 + libonlp.onlp_oid_table_show(tbl, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + lines = buf.string_at().splitlines(False) + lines = [x for x in lines if 'Description' in x] + self.assert_(len(lines) > 1) + + def testSystemOid(self): + """Get the system oid.""" + + hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_oid_hdr_get(onlp.onlp.ONLP_OID_SYS, ctypes.byref(hdr)) + self.auditOidHdr(hdr) if __name__ == "__main__": logging.basicConfig() From f001c3adb5c54600b8fdf532c2d94cd3d912fbb9 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 13 Sep 2017 14:38:02 -0700 Subject: [PATCH 009/244] WIP to add some status codes --- .../any/onlp/src/onlp/module/python/onlp/onlp/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index f5c70e8b..562c9a1f 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -262,6 +262,10 @@ def onlp_sys_init_prototypes(): # onlp/onlp.h +ONLP_STATUS_OK = 0 +ONLP_STATUS_E_UNSUPPORTED = -10 +# XXX roth + def onlp_init(): libonlp.onlp_init() aim_memory_init_prototypes() From 7b545c0284b694a4db21b351b56c57affd805f5a Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 13 Sep 2017 14:38:58 -0700 Subject: [PATCH 010/244] Finish testing sys.h, oids.h - test system oid - test sys dump - test platform management loop - test ioctl --- .../module/python/onlp/test/OnlpApiTest.py | 197 +++++++++++++----- 1 file changed, 141 insertions(+), 56 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index 0dfe43a7..d2a89a6f 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -7,6 +7,7 @@ import ctypes import unittest import logging import re +import time import onlp.onlp onlp.onlp.onlp_init() @@ -55,6 +56,10 @@ class InitTest(OnlpTestMixin, buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) self.assertEqual("hello\nworld\n", buf.string_at()) + libonlp.aim_printf(self.aim_pvs_buffer_p, "%d\n", 42) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertEqual("hello\nworld\n42\n", buf.string_at()) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) self.assertEqual(nullString, buf) @@ -129,48 +134,7 @@ class OnlpTest(OnlpTestMixin, self.assertIn("PSU 1", bufStr) self.assertIn("PSU-1 Fan", bufStr) -class SysTest(OnlpTestMixin, - unittest.TestCase): - """Test interfaces in onlp/sys.h.""" - - def setUp(self): - OnlpTestMixin.setUp(self) - - libonlp.onlp_sys_init() - self.sys_info = onlp.onlp.onlp_sys_info() - - libonlp.onlp_sys_info_get(ctypes.byref(self.sys_info)) - self.sys_info.initialized = True - - def tearDown(self): - OnlpTestMixin.tearDown(self) - - def testNoop(self): - pass - - def testOnieInfo(self): - """Verify the ONIE fields.""" - - product_re = re.compile("(.*)-(.*)-(.*)") - m = product_re.match(self.sys_info.onie_info.product_name) - self.assertIsNotNone(m) - - vendor_re = re.compile("[A-Z][a-z]*[a-zA-Z0-9_. -]") - m = vendor_re.match(self.sys_info.onie_info.vendor) - self.assertIsNotNone(m) - - self.assertIn('.', self.sys_info.onie_info.onie_version) - - # see if there are any vendor extensions - # if there are any, make sure the are well-formed - for vx in self.sys_info.onie_info.vx_list: - sz = vx.size - self.assert_(sz <= 256) - - def testPlatformInfo(self): - """Verify the platform info fields.""" - # XXX VM platforms have null for both - pass +class SysHdrMixin(object): def auditOidHdr(self, hdr): @@ -226,6 +190,50 @@ class SysTest(OnlpTestMixin, else: raise AssertionError("invalid parent OID") +class SysTest(OnlpTestMixin, + SysHdrMixin, + unittest.TestCase): + """Test interfaces in onlp/sys.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_sys_init() + self.sys_info = onlp.onlp.onlp_sys_info() + + libonlp.onlp_sys_info_get(ctypes.byref(self.sys_info)) + self.sys_info.initialized = True + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testNoop(self): + pass + + def testOnieInfo(self): + """Verify the ONIE fields.""" + + product_re = re.compile("(.*)-(.*)-(.*)") + m = product_re.match(self.sys_info.onie_info.product_name) + self.assertIsNotNone(m) + + vendor_re = re.compile("[A-Z][a-z]*[a-zA-Z0-9_. -]") + m = vendor_re.match(self.sys_info.onie_info.vendor) + self.assertIsNotNone(m) + + self.assertIn('.', self.sys_info.onie_info.onie_version) + + # see if there are any vendor extensions + # if there are any, make sure the are well-formed + for vx in self.sys_info.onie_info.vx_list: + sz = vx.size + self.assert_(sz <= 256) + + def testPlatformInfo(self): + """Verify the platform info fields.""" + # XXX VM platforms have null for both + pass + def testSysHeaderOnie(self): """Test the sys_hdr data that is in the sys_info.""" self.auditOidHdr(self.sys_info.hdr) @@ -237,6 +245,90 @@ class SysTest(OnlpTestMixin, libonlp.onlp_sys_hdr_get(ctypes.byref(hdr)) self.auditOidHdr(hdr) + def testManage(self): + """Verify we can start/stop platform management.""" + + code = libonlp.onlp_sys_platform_manage_start(0) + self.assert_(code >= 0) + + for i in range(10): + libonlp.onlp_sys_platform_manage_now() + time.sleep(0.25) + + code = libonlp.onlp_sys_platform_manage_stop(0) + self.assert_(code >= 0) + + time.sleep(2.0) + + code = libonlp.onlp_sys_platform_manage_join(0) + self.assert_(code >= 0) + + def testSysDump(self): + """Test the SYS OID debug dump.""" + + oid = onlp.onlp.ONLP_OID_SYS + flags = 0 + libonlp.onlp_sys_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("System Information", bufStr) + + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + + # this is not the system OID + + oid = self.sys_info.hdr.coids[0] + libonlp.onlp_sys_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIsNone(bufStr) + + def testSysShow(self): + """Test the OID status.""" + + oid = onlp.onlp.ONLP_OID_SYS + flags = 0 + libonlp.onlp_sys_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("System Information", bufStr) + + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + + # this is not the system OID + + oid = self.sys_info.hdr.coids[0] + libonlp.onlp_sys_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIsNone(bufStr) + + def testSysIoctl(self): + """Test the IOCTL interface.""" + + # no such ioctl + + code = libonlp.onlp_sys_ioctl(9999) + self.assertEqual(onlp.onlp.ONLP_STATUS_E_UNSUPPORTED, code) + +class OidTest(OnlpTestMixin, + SysHdrMixin, + unittest.TestCase): + """Test interfaces in onlp/oids.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + self.hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_oid_hdr_get(onlp.onlp.ONLP_OID_SYS, ctypes.byref(self.hdr)) + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testSystemOid(self): + """Audit the system oid.""" + self.auditOidHdr(self.hdr) + def testOidIter(self): """Test the oid iteration functions.""" @@ -277,14 +369,14 @@ class SysTest(OnlpTestMixin, # gather all OIDs v1 = V1(cookie, log=self.log.getChild("v1")) - libonlp.onlp_oid_iterate(self.sys_info.hdr._id, oidType, v1.cvisit(), cookie) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, oidType, v1.cvisit(), cookie) self.assert_(v1.oids) oids = list(v1.oids) # validate error recovery v2 = V1(cookie+1, log=self.log.getChild("v2")) - libonlp.onlp_oid_iterate(self.sys_info.hdr._id, oidType, v2.cvisit(), cookie) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, oidType, v2.cvisit(), cookie) self.assertEqual([], v2.oids) # validate early exit @@ -304,18 +396,18 @@ class SysTest(OnlpTestMixin, v3 = V3(log=self.log.getChild("v3")) cookie = oids[4] - libonlp.onlp_oid_iterate(self.sys_info.hdr._id, oidType, v3.cvisit(), cookie) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, oidType, v3.cvisit(), cookie) self.assertEqual(4, len(v3.oids)) def testOidDump(self): - oid = self.sys_info.hdr.coids[0] + oid = self.hdr.coids[0] flags = 0 libonlp.onlp_oid_dump(oid, self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) self.assertIn("Description:", buf.string_at()) def testOidTableDump(self): - tbl = self.sys_info.hdr.coids + tbl = self.hdr.coids flags = 0 libonlp.onlp_oid_table_dump(tbl, self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) @@ -324,14 +416,14 @@ class SysTest(OnlpTestMixin, self.assert_(len(lines) > 1) def testOidShow(self): - oid = self.sys_info.hdr.coids[0] + oid = self.hdr.coids[0] flags = 0 libonlp.onlp_oid_show(oid, self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) self.assertIn("Description:", buf.string_at()) def testOidTableShow(self): - tbl = self.sys_info.hdr.coids + tbl = self.hdr.coids flags = 0 libonlp.onlp_oid_table_show(tbl, self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) @@ -339,13 +431,6 @@ class SysTest(OnlpTestMixin, lines = [x for x in lines if 'Description' in x] self.assert_(len(lines) > 1) - def testSystemOid(self): - """Get the system oid.""" - - hdr = onlp.onlp.onlp_oid_hdr() - libonlp.onlp_oid_hdr_get(onlp.onlp.ONLP_OID_SYS, ctypes.byref(hdr)) - self.auditOidHdr(hdr) - if __name__ == "__main__": logging.basicConfig() unittest.main() From b140fec41b382aa37985eb591b3694f711847140 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 13 Sep 2017 15:53:06 -0700 Subject: [PATCH 011/244] enum overhaul - move python enums to a proper modul - pull up OID show and dump flags to the auto.yml - update APIs and tests to use autogen enums --- packages/base/any/onlp/APKG.yml | 8 +- .../any/onlp/src/onlp/module/auto/make.mk | 2 +- .../any/onlp/src/onlp/module/auto/onlp.yml | 19 +++ .../any/onlp/src/onlp/module/inc/onlp/oids.h | 62 ++++++++- .../any/onlp/src/onlp/module/inc/onlp/onlp.x | 2 + .../onlp/module/python/onlp/onlp/__init__.py | 40 ++---- .../module/{py => python/onlp/onlp}/enums.py | 11 ++ .../module/python/onlp/test/OnlpApiTest.py | 40 ++---- .../base/any/onlp/src/onlp/module/src/fan.c | 2 +- .../base/any/onlp/src/onlp/module/src/led.c | 2 +- .../any/onlp/src/onlp/module/src/onlp_enums.c | 122 ++++++++++++++++++ .../any/onlp/src/onlp/module/src/onlp_main.c | 12 +- .../base/any/onlp/src/onlp/module/src/psu.c | 8 +- .../base/any/onlp/src/onlp/module/src/sys.c | 10 +- .../any/onlp/src/onlp/module/src/thermal.c | 2 +- packages/base/any/onlp/src/onlp/utest/main.c | 4 +- packages/base/any/onlp/src/onlpdump.py | 4 +- packages/base/any/oom-shim/src/utest/main.c | 4 +- 18 files changed, 261 insertions(+), 93 deletions(-) rename packages/base/any/onlp/src/onlp/module/{py => python/onlp/onlp}/enums.py (94%) diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml index 2144913b..7ab08aa3 100644 --- a/packages/base/any/onlp/APKG.yml +++ b/packages/base/any/onlp/APKG.yml @@ -27,10 +27,10 @@ packages: builds/onlp-platform-defaults/$BUILD_DIR/${TOOLCHAIN}/bin/libonlp-platform-defaults.so : $libdir/ builds/onlpd/$BUILD_DIR/${TOOLCHAIN}/bin/onlpd : $bindir/ ${ONL}/packages/base/any/onlp/src/onlpdump.py: $bindir/ - ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/*.py: ${PY_INSTALL}/onlp/ - ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/*.py: ${PY_INSTALL}/onlp/onlp/ - ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/test/*.py: ${PY_INSTALL}/onlp/test/ - ${ONL}/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib/*.py: ${PY_INSTALL}/onlp/onlplib/ + ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/__init__.py: ${PY_INSTALL}/onlp/ + ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/onlp: ${PY_INSTALL}/onlp/onlp + ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/test: ${PY_INSTALL}/onlp/test + ${ONL}/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib: ${PY_INSTALL}/onlp/onlplib init: $ONL/packages/base/any/onlp/src/onlpd.init diff --git a/packages/base/any/onlp/src/onlp/module/auto/make.mk b/packages/base/any/onlp/src/onlp/module/auto/make.mk index 95a06896..dbf853f1 100644 --- a/packages/base/any/onlp/src/onlp/module/auto/make.mk +++ b/packages/base/any/onlp/src/onlp/module/auto/make.mk @@ -24,5 +24,5 @@ ############################################################ onlp_AUTO_DEFS := module/auto/onlp.yml -onlp_AUTO_DIRS := module/inc/onlp module/src module/py +onlp_AUTO_DIRS := module/inc/onlp module/src module/python/onlp/onlp include $(BUILDER)/auto.mk diff --git a/packages/base/any/onlp/src/onlp/module/auto/onlp.yml b/packages/base/any/onlp/src/onlp/module/auto/onlp.yml index f784e320..ac82e314 100644 --- a/packages/base/any/onlp/src/onlp/module/auto/onlp.yml +++ b/packages/base/any/onlp/src/onlp/module/auto/onlp.yml @@ -109,6 +109,17 @@ oid_types: &oid_types - MODULE : 6 - RTC : 7 +# OID dump options +oid_dump: &oid_dump +- RECURSE +- EVEN_IF_ABSENT + +# OID show options +oid_show: &oid_show +- RECURSE +- EXTENDED +- YAML + # SFP Control sfp_control: &sfp_control - RESET @@ -255,6 +266,14 @@ definitions: onlp_oid_type: tag: oid members: *oid_types + onlp_oid_show: + tag: oid + members: *oid_show + flags: True + onlp_oid_dump: + tag: oid + members: *oid_dump + flags: True onlp_thermal_status: tag: thermal members: *thermal_status diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h index 20ce5746..13df3243 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/oids.h @@ -47,6 +47,19 @@ typedef uint32_t onlp_oid_t; /* */ +/** onlp_oid_dump */ +typedef enum onlp_oid_dump_e { + ONLP_OID_DUMP_RECURSE = (1 << 0), + ONLP_OID_DUMP_EVEN_IF_ABSENT = (1 << 1), +} onlp_oid_dump_t; + +/** onlp_oid_show */ +typedef enum onlp_oid_show_e { + ONLP_OID_SHOW_RECURSE = (1 << 0), + ONLP_OID_SHOW_EXTENDED = (1 << 1), + ONLP_OID_SHOW_YAML = (1 << 2), +} onlp_oid_show_t; + /** onlp_oid_type */ typedef enum onlp_oid_type_e { ONLP_OID_TYPE_SYS = 1, @@ -121,13 +134,6 @@ typedef struct onlp_oid_hdr_s { } onlp_oid_hdr_t; -#define ONLP_OID_DUMP_F_RECURSE 0x1 -#define ONLP_OID_DUMP_F_EVEN_IF_ABSENT 0x2 - -#define ONLP_OID_SHOW_F_RECURSE 0x1 -#define ONLP_OID_SHOW_F_EXTENDED 0x2 -#define ONLP_OID_SHOW_F_YAML 0x4 - void onlp_oid_dump(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags); void onlp_oid_table_dump(onlp_oid_table_t table, aim_pvs_t* pvs, uint32_t flags); @@ -199,6 +205,48 @@ int onlp_oid_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t* hdr); * *****************************************************************************/ /* */ +/** Enum names. */ +const char* onlp_oid_dump_name(onlp_oid_dump_t e); + +/** Enum values. */ +int onlp_oid_dump_value(const char* str, onlp_oid_dump_t* e, int substr); + +/** Enum descriptions. */ +const char* onlp_oid_dump_desc(onlp_oid_dump_t e); + +/** Enum validator. */ +int onlp_oid_dump_valid(onlp_oid_dump_t e); + +/** validator */ +#define ONLP_OID_DUMP_VALID(_e) \ + (onlp_oid_dump_valid((_e))) + +/** onlp_oid_dump_map table. */ +extern aim_map_si_t onlp_oid_dump_map[]; +/** onlp_oid_dump_desc_map table. */ +extern aim_map_si_t onlp_oid_dump_desc_map[]; + +/** Enum names. */ +const char* onlp_oid_show_name(onlp_oid_show_t e); + +/** Enum values. */ +int onlp_oid_show_value(const char* str, onlp_oid_show_t* e, int substr); + +/** Enum descriptions. */ +const char* onlp_oid_show_desc(onlp_oid_show_t e); + +/** Enum validator. */ +int onlp_oid_show_valid(onlp_oid_show_t e); + +/** validator */ +#define ONLP_OID_SHOW_VALID(_e) \ + (onlp_oid_show_valid((_e))) + +/** onlp_oid_show_map table. */ +extern aim_map_si_t onlp_oid_show_map[]; +/** onlp_oid_show_desc_map table. */ +extern aim_map_si_t onlp_oid_show_desc_map[]; + /** Enum names. */ const char* onlp_oid_type_name(onlp_oid_type_t e); diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x index ebcf42da..988bcf3c 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/onlp.x @@ -48,6 +48,8 @@ ONLP_ENUMERATION_ENTRY(onlp_fan_status, "") ONLP_ENUMERATION_ENTRY(onlp_led_caps, "") ONLP_ENUMERATION_ENTRY(onlp_led_mode, "") ONLP_ENUMERATION_ENTRY(onlp_led_status, "") +ONLP_ENUMERATION_ENTRY(onlp_oid_dump, "") +ONLP_ENUMERATION_ENTRY(onlp_oid_show, "") ONLP_ENUMERATION_ENTRY(onlp_oid_type, "") ONLP_ENUMERATION_ENTRY(onlp_psu_caps, "") ONLP_ENUMERATION_ENTRY(onlp_psu_status, "") diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index 562c9a1f..48deb6d5 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -12,6 +12,8 @@ libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) import onlp.onlplib +from onlp.onlp.enums import * + # AIM/aim_memory.h class aim_void_p(ctypes.c_void_p): @@ -113,27 +115,11 @@ def aim_pvs_init_prototypes(): onlp_oid = ctypes.c_uint -ONLP_OID_TYPE_SYS = 1 -ONLP_OID_TYPE_THERMAL = 2 -ONLP_OID_TYPE_FAN = 3 -ONLP_OID_TYPE_PSU = 4 -ONLP_OID_TYPE_LED = 5 -ONLP_OID_TYPE_MODULE = 6 -ONLP_OID_TYPE_RTC = 7 -# XXX roth waiting for enum generator - -ONLP_OID_SYS = (ONLP_OID_TYPE_SYS<<24) | 1 +ONLP_OID_SYS = (ONLP_OID_TYPE.SYS<<24) | 1 ONLP_OID_DESC_SIZE = 128 ONLP_OID_TABLE_SIZE = 32 -ONLP_OID_DUMP_F_RECURSE = 0x1 -ONLP_OID_DUMP_F_EVEN_IF_ABSENT = 0x2 - -ONLP_OID_SHOW_F_RECURSE = 0x1 -ONLP_OID_SHOW_F_EXTENDED = 0x2 -ONLP_OID_SHOW_F_YAML = 0x4 - class OidTableIterator(object): def __init__(self, hdr): @@ -165,19 +151,19 @@ class onlp_oid_hdr(ctypes.Structure): return self._id >> 24 def isSystem(self): - return self.getType() == ONLP_OID_TYPE_SYS + return self.getType() == ONLP_OID_TYPE.SYS def isThermal(self): - return self.getType() == ONLP_OID_TYPE_THERMAL + return self.getType() == ONLP_OID_TYPE.THERMAL def isFan(self): - return self.getType() == ONLP_OID_TYPE_FAN + return self.getType() == ONLP_OID_TYPE.FAN def isPsu(self): - return self.getType() == ONLP_OID_TYPE_PSU + return self.getType() == ONLP_OID_TYPE.PSU def isLed(self): - return self.getType() == ONLP_OID_TYPE_LED + return self.getType() == ONLP_OID_TYPE.LED def isModule(self): - return self.getType() == ONLP_OID_TYPE_MODULE + return self.getType() == ONLP_OID_TYPE.MODULE def isRtc(self): - return self.getType() == ONLP_OID_TYPE_RTC + return self.getType() == ONLP_OID_TYPE.RTC def children(self): return OidTableIterator(self) @@ -201,11 +187,9 @@ def onlp_oid_init_prototypes(): libonlp.onlp_oid_iterate.restype = ctypes.c_int libonlp.onlp_oid_iterate.argtypes = (onlp_oid, ctypes.c_int, onlp_oid_iterate_f, ctypes.c_void_p,) - # XXX enum libonlp.onlp_oid_hdr_get.restype = ctypes.c_int libonlp.onlp_oid_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr,)) - # XXX enum # onlp/sys.h @@ -262,10 +246,6 @@ def onlp_sys_init_prototypes(): # onlp/onlp.h -ONLP_STATUS_OK = 0 -ONLP_STATUS_E_UNSUPPORTED = -10 -# XXX roth - def onlp_init(): libonlp.onlp_init() aim_memory_init_prototypes() diff --git a/packages/base/any/onlp/src/onlp/module/py/enums.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/enums.py similarity index 94% rename from packages/base/any/onlp/src/onlp/module/py/enums.py rename to packages/base/any/onlp/src/onlp/module/python/onlp/onlp/enums.py index 65cd75ec..a747c9bc 100644 --- a/packages/base/any/onlp/src/onlp/module/py/enums.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/enums.py @@ -88,6 +88,17 @@ class ONLP_LED_STATUS(Enumeration): ON = (1 << 2) +class ONLP_OID_DUMP(Enumeration): + RECURSE = (1 << 0) + EVEN_IF_ABSENT = (1 << 1) + + +class ONLP_OID_SHOW(Enumeration): + RECURSE = (1 << 0) + EXTENDED = (1 << 1) + YAML = (1 << 2) + + class ONLP_OID_TYPE(Enumeration): SYS = 1 THERMAL = 2 diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index d2a89a6f..691f2266 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -96,14 +96,14 @@ class OnlpTest(OnlpTestMixin, libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) - flags = onlp.onlp.ONLP_OID_DUMP_F_RECURSE + flags = onlp.onlp.ONLP_OID_DUMP.RECURSE libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) bufStr = buf.string_at() self.assertIn("psu @ 1", bufStr) self.assertIn("PSU-1 Fan", bufStr) - # hard to test onlp.onlp.ONLP_OID_DUMP_F_RECURSE, + # hard to test onlp.onlp.ONLP_OID_DUMP.RECURSE, # since it depends on whether a specific component is inserted def testPlatformShow(self): @@ -127,7 +127,7 @@ class OnlpTest(OnlpTestMixin, libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) - flags = onlp.onlp.ONLP_OID_SHOW_F_RECURSE + flags = onlp.onlp.ONLP_OID_SHOW.RECURSE libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) bufStr = buf.string_at() @@ -152,36 +152,22 @@ class SysHdrMixin(object): self.assert_(len(coids) < onlp.onlp.ONLP_OID_TABLE_SIZE) def _oidType(oid): - if oid.isSystem(): - return "sys" - if oid.isThermal(): - return "thm" - if oid.isFan(): - return "fan" - if oid.isPsu(): - return "psu" - if oid.isLed(): - return "led" - if oid.isModule(): - return "mod" - if oid.isRtc(): - return "rtc" - return "unk" + return onlp.onlp.ONLP_OID_TYPE.name(oid._id>>24) for coid in coids: self.log.info("oid %d (%s): %s", coid._id, _oidType(coid), coid.description) - if _oidType(coid) == "unk": + if _oidType(coid) is None: raise AssertionError("invalid oid") self.assertEqual(hdr._id, coid.poid) # if it's a PSU, verify that it has fans - if _oidType(coid) == "psu": + if _oidType(coid) == "PSU": foids = [x for x in coid.children()] for foid in foids: self.log.info("oid %d (%s): %s", foid._id, _oidType(foid), foid.description) - self.assertEqual("fan", _oidType(foid)) + self.assertEqual("FAN", _oidType(foid)) # parent should the the PSU or the chassis if coid._id == foid.poid: pass @@ -309,7 +295,7 @@ class SysTest(OnlpTestMixin, # no such ioctl code = libonlp.onlp_sys_ioctl(9999) - self.assertEqual(onlp.onlp.ONLP_STATUS_E_UNSUPPORTED, code) + self.assertEqual(onlp.onlp.ONLP_STATUS.E_UNSUPPORTED, code) class OidTest(OnlpTestMixin, SysHdrMixin, @@ -338,7 +324,7 @@ class OidTest(OnlpTestMixin, self.log = log or logging.getLogger("visit") def visit(self, oid, cookie): - return 0 + return onlp.onlp.ONLP_STATUS.E_OK def cvisit(self): def _v(oid, cookie): @@ -346,7 +332,7 @@ class OidTest(OnlpTestMixin, return self.visit(oid, cookie) except: self.log.exception("visitor failed") - return -1 + return onlp.onlp.ONLP_STATUS.E_GENERIC return onlp.onlp.onlp_oid_iterate_f(_v) class V1(OidIterator): @@ -361,7 +347,7 @@ class OidTest(OnlpTestMixin, raise AssertionError("invalid cookie") self.log.info("found oid %d", oid) self.oids.append(oid) - return 0 + return onlp.onlp.ONLP_STATUS.E_OK oidType = 0 cookie = 0xdeadbeef @@ -389,10 +375,10 @@ class OidTest(OnlpTestMixin, def visit(self, oid, cookie): if oid == cookie: - return -1 + return onlp.onlp.ONLP_STATUS.E_GENERIC self.log.info("found oid %d", oid) self.oids.append(oid) - return 0 + return onlp.onlp.ONLP_STATUS.E_OK v3 = V3(log=self.log.getChild("v3")) cookie = oids[4] diff --git a/packages/base/any/onlp/src/onlp/module/src/fan.c b/packages/base/any/onlp/src/onlp/module/src/fan.c index 3ef8a75e..549814db 100644 --- a/packages/base/any/onlp/src/onlp/module/src/fan.c +++ b/packages/base/any/onlp/src/onlp/module/src/fan.c @@ -281,7 +281,7 @@ onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags) rv = onlp_fan_info_get(oid, &fi); - yaml = flags & ONLP_OID_SHOW_F_YAML; + yaml = flags & ONLP_OID_SHOW_YAML; if(yaml) { iof_push(&iof, "- "); diff --git a/packages/base/any/onlp/src/onlp/module/src/led.c b/packages/base/any/onlp/src/onlp/module/src/led.c index e914ee69..21036cd4 100644 --- a/packages/base/any/onlp/src/onlp/module/src/led.c +++ b/packages/base/any/onlp/src/onlp/module/src/led.c @@ -215,7 +215,7 @@ onlp_led_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) VALIDATENR(id); onlp_oid_show_iof_init_default(&iof, pvs, flags); - yaml = flags & ONLP_OID_SHOW_F_YAML; + yaml = flags & ONLP_OID_SHOW_YAML; if(yaml) { iof_push(&iof, " -"); diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c b/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c index 67ebd6f7..e632b27b 100644 --- a/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c +++ b/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c @@ -519,6 +519,128 @@ onlp_led_status_valid(onlp_led_status_t e) } +aim_map_si_t onlp_oid_dump_map[] = +{ + { "RECURSE", ONLP_OID_DUMP_RECURSE }, + { "EVEN_IF_ABSENT", ONLP_OID_DUMP_EVEN_IF_ABSENT }, + { NULL, 0 } +}; + +aim_map_si_t onlp_oid_dump_desc_map[] = +{ + { "None", ONLP_OID_DUMP_RECURSE }, + { "None", ONLP_OID_DUMP_EVEN_IF_ABSENT }, + { NULL, 0 } +}; + +const char* +onlp_oid_dump_name(onlp_oid_dump_t e) +{ + const char* name; + if(aim_map_si_i(&name, e, onlp_oid_dump_map, 0)) { + return name; + } + else { + return "-invalid value for enum type 'onlp_oid_dump'"; + } +} + +int +onlp_oid_dump_value(const char* str, onlp_oid_dump_t* e, int substr) +{ + int i; + AIM_REFERENCE(substr); + if(aim_map_si_s(&i, str, onlp_oid_dump_map, 0)) { + /* Enum Found */ + *e = i; + return 0; + } + else { + return -1; + } +} + +const char* +onlp_oid_dump_desc(onlp_oid_dump_t e) +{ + const char* name; + if(aim_map_si_i(&name, e, onlp_oid_dump_desc_map, 0)) { + return name; + } + else { + return "-invalid value for enum type 'onlp_oid_dump'"; + } +} + +int +onlp_oid_dump_valid(onlp_oid_dump_t e) +{ + return aim_map_si_i(NULL, e, onlp_oid_dump_map, 0) ? 1 : 0; +} + + +aim_map_si_t onlp_oid_show_map[] = +{ + { "RECURSE", ONLP_OID_SHOW_RECURSE }, + { "EXTENDED", ONLP_OID_SHOW_EXTENDED }, + { "YAML", ONLP_OID_SHOW_YAML }, + { NULL, 0 } +}; + +aim_map_si_t onlp_oid_show_desc_map[] = +{ + { "None", ONLP_OID_SHOW_RECURSE }, + { "None", ONLP_OID_SHOW_EXTENDED }, + { "None", ONLP_OID_SHOW_YAML }, + { NULL, 0 } +}; + +const char* +onlp_oid_show_name(onlp_oid_show_t e) +{ + const char* name; + if(aim_map_si_i(&name, e, onlp_oid_show_map, 0)) { + return name; + } + else { + return "-invalid value for enum type 'onlp_oid_show'"; + } +} + +int +onlp_oid_show_value(const char* str, onlp_oid_show_t* e, int substr) +{ + int i; + AIM_REFERENCE(substr); + if(aim_map_si_s(&i, str, onlp_oid_show_map, 0)) { + /* Enum Found */ + *e = i; + return 0; + } + else { + return -1; + } +} + +const char* +onlp_oid_show_desc(onlp_oid_show_t e) +{ + const char* name; + if(aim_map_si_i(&name, e, onlp_oid_show_desc_map, 0)) { + return name; + } + else { + return "-invalid value for enum type 'onlp_oid_show'"; + } +} + +int +onlp_oid_show_valid(onlp_oid_show_t e) +{ + return aim_map_si_i(NULL, e, onlp_oid_show_map, 0) ? 1 : 0; +} + + aim_map_si_t onlp_oid_type_map[] = { { "SYS", ONLP_OID_TYPE_SYS }, diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_main.c b/packages/base/any/onlp/src/onlp/module/src/onlp_main.c index 6dd5ccfe..41d32795 100644 --- a/packages/base/any/onlp/src/onlp/module/src/onlp_main.c +++ b/packages/base/any/onlp/src/onlp/module/src/onlp_main.c @@ -203,8 +203,8 @@ onlpdump_main(int argc, char* argv[]) switch(c) { case 's': show=1; break; - case 'r': show=1; showflags |= ONLP_OID_SHOW_F_RECURSE; break; - case 'e': show=1; showflags |= ONLP_OID_SHOW_F_EXTENDED; break; + case 'r': show=1; showflags |= ONLP_OID_SHOW_RECURSE; break; + case 'e': show=1; showflags |= ONLP_OID_SHOW_EXTENDED; break; case 'd': show=0; break; case 'h': help=1; rv = 0; break; case 'j': j=1; break; @@ -220,7 +220,7 @@ onlpdump_main(int argc, char* argv[]) case 'l': l=1; break; case 'b': b=1; break; case 'J': J = optarg; break; - case 'y': show=1; showflags |= ONLP_OID_SHOW_F_YAML; break; + case 'y': show=1; showflags |= ONLP_OID_SHOW_YAML; break; default: help=1; rv = 1; break; } } @@ -305,8 +305,8 @@ onlpdump_main(int argc, char* argv[]) int oid; if(sscanf(O, "0x%x", &oid) == 1) { onlp_oid_dump(oid, &aim_pvs_stdout, - ONLP_OID_DUMP_F_RECURSE | - ONLP_OID_DUMP_F_EVEN_IF_ABSENT); + ONLP_OID_DUMP_RECURSE | + ONLP_OID_DUMP_EVEN_IF_ABSENT); } return 0; } @@ -349,7 +349,7 @@ onlpdump_main(int argc, char* argv[]) if(show == 0) { /* Default to full dump */ onlp_platform_dump(&aim_pvs_stdout, - ONLP_OID_DUMP_F_RECURSE | ONLP_OID_DUMP_F_EVEN_IF_ABSENT); + ONLP_OID_DUMP_RECURSE | ONLP_OID_DUMP_EVEN_IF_ABSENT); } else { onlp_platform_show(&aim_pvs_stdout, diff --git a/packages/base/any/onlp/src/onlp/module/src/psu.c b/packages/base/any/onlp/src/onlp/module/src/psu.c index 76baf3fe..5aaf166c 100644 --- a/packages/base/any/onlp/src/onlp/module/src/psu.c +++ b/packages/base/any/onlp/src/onlp/module/src/psu.c @@ -143,7 +143,7 @@ onlp_psu_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) iof_iprintf(&iof, "Iout: %d", info.miout); iof_iprintf(&iof, "Pin: %d", info.mpin); iof_iprintf(&iof, "Pout: %d", info.mpout); - if(flags & ONLP_OID_DUMP_F_RECURSE) { + if(flags & ONLP_OID_DUMP_RECURSE) { onlp_oid_table_dump(info.hdr.coids, &iof.inherit, flags); } } @@ -165,7 +165,7 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) onlp_oid_show_iof_init_default(&iof, pvs, flags); rv = onlp_psu_info_get(id, &pi); - yaml = flags & ONLP_OID_SHOW_F_YAML; + yaml = flags & ONLP_OID_SHOW_YAML; if(yaml) { iof_push(&iof, "- "); @@ -235,7 +235,7 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) ONLP_MILLI_NORMAL_INTEGER_TENTHS(pi.mpout)); } - if(flags & ONLP_OID_SHOW_F_RECURSE) { + if(flags & ONLP_OID_SHOW_RECURSE) { /* * Display sub oids. * @@ -264,7 +264,7 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) iof_pop(&iof); } - if(flags & ONLP_OID_SHOW_F_EXTENDED) { + if(flags & ONLP_OID_SHOW_EXTENDED) { /* Include all other types as well. */ ONLP_OID_TABLE_ITER_TYPE(pi.hdr.coids, oidp, LED) { onlp_oid_show(*oidp, &iof.inherit, flags); diff --git a/packages/base/any/onlp/src/onlp/module/src/sys.c b/packages/base/any/onlp/src/onlp/module/src/sys.c index c8090476..ad6fc49f 100644 --- a/packages/base/any/onlp/src/onlp/module/src/sys.c +++ b/packages/base/any/onlp/src/onlp/module/src/sys.c @@ -214,7 +214,7 @@ onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) int yaml; onlp_oid_show_iof_init_default(&iof, pvs, flags); - yaml = (flags & ONLP_OID_SHOW_F_YAML); + yaml = (flags & ONLP_OID_SHOW_YAML); if(id && ONLP_OID_TYPE_GET(id) != ONLP_OID_TYPE_SYS) { return; @@ -234,14 +234,14 @@ onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) * unless you specify EXTENDED or !RECURSIVE */ if(yaml || - flags & ONLP_OID_SHOW_F_EXTENDED || - (flags & ONLP_OID_SHOW_F_RECURSE) == 0) { + flags & ONLP_OID_SHOW_EXTENDED || + (flags & ONLP_OID_SHOW_RECURSE) == 0) { iof_push(&iof, "System Information:"); onlp_onie_show(&si.onie_info, &iof.inherit); iof_pop(&iof); } - if(flags & ONLP_OID_SHOW_F_RECURSE) { + if(flags & ONLP_OID_SHOW_RECURSE) { onlp_oid_t* oidp; @@ -266,7 +266,7 @@ onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) } YPOP(); - if(flags & ONLP_OID_SHOW_F_EXTENDED) { + if(flags & ONLP_OID_SHOW_EXTENDED) { /** Show all LEDs */ YPUSH("LEDs:"); ONLP_OID_TABLE_ITER_TYPE(si.hdr.coids, oidp, LED) { diff --git a/packages/base/any/onlp/src/onlp/module/src/thermal.c b/packages/base/any/onlp/src/onlp/module/src/thermal.c index c3511b2e..219a1123 100644 --- a/packages/base/any/onlp/src/onlp/module/src/thermal.c +++ b/packages/base/any/onlp/src/onlp/module/src/thermal.c @@ -202,7 +202,7 @@ onlp_thermal_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags) rv = onlp_thermal_info_get(id, &ti); - yaml = flags & ONLP_OID_SHOW_F_YAML; + yaml = flags & ONLP_OID_SHOW_YAML; if(yaml) { iof_push(&iof, "- "); diff --git a/packages/base/any/onlp/src/onlp/utest/main.c b/packages/base/any/onlp/src/onlp/utest/main.c index e7e9e030..7ada8e55 100644 --- a/packages/base/any/onlp/src/onlp/utest/main.c +++ b/packages/base/any/onlp/src/onlp/utest/main.c @@ -115,9 +115,9 @@ aim_main(int argc, char* argv[]) /* Example Platform Dump */ onlp_init(); - onlp_platform_dump(&aim_pvs_stdout, ONLP_OID_DUMP_F_RECURSE); + onlp_platform_dump(&aim_pvs_stdout, ONLP_OID_DUMP_RECURSE); onlp_oid_iterate(0, 0, iter__, NULL); - onlp_platform_show(&aim_pvs_stdout, ONLP_OID_SHOW_F_RECURSE|ONLP_OID_SHOW_F_EXTENDED); + onlp_platform_show(&aim_pvs_stdout, ONLP_OID_SHOW_RECURSE|ONLP_OID_SHOW_EXTENDED); if(argv[1] && !strcmp("manage", argv[1])) { onlp_sys_platform_manage_start(); diff --git a/packages/base/any/onlp/src/onlpdump.py b/packages/base/any/onlp/src/onlpdump.py index 87204cb8..e2349d62 100755 --- a/packages/base/any/onlp/src/onlpdump.py +++ b/packages/base/any/onlp/src/onlpdump.py @@ -30,7 +30,7 @@ pdb.set_trace() ##libonlp.onlp_onie_show(byref(si.onie_info), byref(libonlp.aim_pvs_stdout)) libonlp.onlp_platform_dump(libonlp.aim_pvs_stdout, - (onlp.onlp.ONLP_OID_DUMP_F_RECURSE - | onlp.onlp.ONLP_OID_DUMP_F_EVEN_IF_ABSENT)) + (onlp.onlp.ONLP_OID_DUMP.RECURSE + | onlp.onlp.ONLP_OID_DUMP.EVEN_IF_ABSENT)) sys.exit(0) diff --git a/packages/base/any/oom-shim/src/utest/main.c b/packages/base/any/oom-shim/src/utest/main.c index e7e9e030..7ada8e55 100644 --- a/packages/base/any/oom-shim/src/utest/main.c +++ b/packages/base/any/oom-shim/src/utest/main.c @@ -115,9 +115,9 @@ aim_main(int argc, char* argv[]) /* Example Platform Dump */ onlp_init(); - onlp_platform_dump(&aim_pvs_stdout, ONLP_OID_DUMP_F_RECURSE); + onlp_platform_dump(&aim_pvs_stdout, ONLP_OID_DUMP_RECURSE); onlp_oid_iterate(0, 0, iter__, NULL); - onlp_platform_show(&aim_pvs_stdout, ONLP_OID_SHOW_F_RECURSE|ONLP_OID_SHOW_F_EXTENDED); + onlp_platform_show(&aim_pvs_stdout, ONLP_OID_SHOW_RECURSE|ONLP_OID_SHOW_EXTENDED); if(argv[1] && !strcmp("manage", argv[1])) { onlp_sys_platform_manage_start(); From 04f785d105f6a4652a53ae9fbd4450735f575580 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 24 Aug 2017 09:02:54 +0800 Subject: [PATCH 012/244] [Quanta-IX1B] Update ONLP: Fix unexpected psu read block isuue: add retry flow --- .../quanta/x86-64/modules/builds/qci_pmbus.c | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) mode change 100755 => 100644 packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c diff --git a/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c b/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c old mode 100755 new mode 100644 index fce52537..176e6caf --- a/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c +++ b/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c @@ -74,6 +74,28 @@ struct pmbus_data { u8 currpage; }; +static int qci_pmbus_read_block(struct i2c_client *client, u8 command, int data_len, u8 *data) +{ + int result = 0; + int retry_count = 3; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (result < 0) { + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + static ssize_t qci_pmbus_show_mfr_id(struct device *dev, struct device_attribute *da, char *buf) { @@ -81,8 +103,7 @@ static ssize_t qci_pmbus_show_mfr_id(struct device *dev, u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; struct i2c_client *client = container_of(dev, struct i2c_client, dev); - - ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_ID, I2C_SMBUS_BLOCK_MAX, block_buffer); + ret = qci_pmbus_read_block(client, PMBUS_MFR_ID, I2C_SMBUS_BLOCK_MAX, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read Manufacturer ID\n"); return ret; @@ -101,7 +122,7 @@ static ssize_t qci_pmbus_show_mfr_model(struct device *dev, u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; struct i2c_client *client = container_of(dev, struct i2c_client, dev); - ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_MODEL, I2C_SMBUS_BLOCK_MAX, block_buffer); + ret = qci_pmbus_read_block(client, PMBUS_MFR_MODEL, I2C_SMBUS_BLOCK_MAX, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read Manufacturer Model\n"); return ret; @@ -120,7 +141,7 @@ static ssize_t qci_pmbus_show_mfr_revision(struct device *dev, u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; struct i2c_client *client = container_of(dev, struct i2c_client, dev); - ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_REVISION, I2C_SMBUS_BLOCK_MAX, block_buffer); + ret = qci_pmbus_read_block(client, PMBUS_MFR_REVISION, I2C_SMBUS_BLOCK_MAX, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read Manufacturer Revision\n"); return ret; @@ -139,7 +160,7 @@ static ssize_t qci_pmbus_show_mfr_location(struct device *dev, u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; struct i2c_client *client = container_of(dev, struct i2c_client, dev); - ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_LOCATION, I2C_SMBUS_BLOCK_MAX, block_buffer); + ret = qci_pmbus_read_block(client, PMBUS_MFR_LOCATION, I2C_SMBUS_BLOCK_MAX, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read Manufacture Location\n"); return ret; @@ -158,7 +179,7 @@ static ssize_t qci_pmbus_show_mfr_serial(struct device *dev, u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; struct i2c_client *client = container_of(dev, struct i2c_client, dev); - ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_SERIAL, I2C_SMBUS_BLOCK_MAX, block_buffer); + ret = qci_pmbus_read_block(client, PMBUS_MFR_SERIAL, I2C_SMBUS_BLOCK_MAX, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read Manufacturer Serial\n"); return ret; From efe9508cd8ad97c3cfda7cc5e843aeb8be820e83 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 18 Sep 2017 17:13:59 -0700 Subject: [PATCH 013/244] Added fan and led interfaces --- .../onlp/module/python/onlp/onlp/__init__.py | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index 48deb6d5..4e9329b9 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -111,6 +111,11 @@ def aim_pvs_init_prototypes(): libonlp.aim_pvs_buffer_reset.restype = None libonlp.aim_pvs_buffer_reset.argtypes = (ctypes.POINTER(aim_pvs),) +# onlp.yml + +ONLP_CONFIG_INFO_STR_MAX = 64 +# XXX roth -- no cdefs support (yet) + # onlp/oids.h onlp_oid = ctypes.c_uint @@ -244,6 +249,98 @@ def onlp_sys_init_prototypes(): libonlp.onlp_sys_debug.argtypes = (ctypes.POINTER(aim_pvs), ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ctypes.c_char)),) +# onlp/fan.h + +class onlp_fan_info(ctypes.Structure): + _fields_ = [("hdr", onlp_oid_hdr,), + ("status", ctypes.c_uint,), + ("caps", ctypes.c_uint,), + ("rpm", ctypes.c_int,), + ("percentage", ctypes.c_int,), + ("mode", ctypes.c_uint,), + ("model", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,), + ("serial", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,),] + + def isPresent(self): + return self.status & ONLP_FAN_STATUS.PRESENT + + def isMissing(self): + return not self.PRESENT() + + def isFailed(self): + return self.status & ONLP_FAN_STATUS.FAILED + + def isNormal(self): + return self.isPresent() and not self.isFailed() + +def onlp_fan_init_prototypes(): + + libonlp.onlp_fan_init.restype = None + + libonlp.onlp_fan_info_get.restype = ctypes.c_int + libonlp.onlp_fan_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_fan_info),) + + libonlp.onlp_fan_status_get.restype = ctypes.c_int + libonlp.onlp_fan_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + + libonlp.onlp_fan_hdr_get.restype = ctypes.c_int + libonlp.onlp_fan_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) + + libonlp.onlp_fan_rpm_set.restype = ctypes.c_int + libonlp.onlp_fan_rpm_set.argtypes = (onlp_oid, ctypes.c_int,) + + libonlp.onlp_fan_percentage_set.restype = ctypes.c_int + libonlp.onlp_fan_percentage_set.argtypes = (onlp_oid, ctypes.c_int,) + + libonlp.onlp_fan_mode_set.restype = ctypes.c_int + libonlp.onlp_fan_mode_set.argtypes = (onlp_oid, ctypes.c_uint,) + + libonlp.onlp_fan_dir_set.restype = ctypes.c_int + libonlp.onlp_fan_dir_set.argtypes = (onlp_oid, ctypes.c_uint,) + + libonlp.onlp_fan_dump.restype = None + libonlp.onlp_fan_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_fan_show.restype = None + libonlp.onlp_fan_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + +# onlp/led.h + +class onlp_led_info(ctypes.Structure): + _fields_ = [("hdr", onlp_oid_hdr,), + ("status", ctypes.c_uint,), + ("caps", ctypes.c_uint,), + ("mode", ctypes.c_uint,), + ("character", ctypes.c_char,),] + +def onlp_led_init_prototypes(): + + libonlp.onlp_led_init.restype = None + + libonlp.onlp_led_info_get.restype = ctypes.c_int + libonlp.onlp_led_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_led_info),) + + libonlp.onlp_led_status_get.restype = ctypes.c_int + libonlp.onlp_led_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + + libonlp.onlp_led_hdr_get.restype = ctypes.c_int + libonlp.onlp_led_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) + + libonlp.onlp_led_set.restype = ctypes.c_int + libonlp.onlp_led_set.argtypes = (onlp_oid, ctypes.c_int,) + + libonlp.onlp_led_mode_set.restype = ctypes.c_int + libonlp.onlp_led_mode_set.argtypes = (onlp_oid, ctypes.c_uint,) + + libonlp.onlp_led_char_set.restype = ctypes.c_int + libonlp.onlp_led_char_set.argtypes = (onlp_oid, ctypes.c_char,) + + libonlp.onlp_led_dump.restype = None + libonlp.onlp_led_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + + libonlp.onlp_led_show.restype = None + libonlp.onlp_led_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + # onlp/onlp.h def onlp_init(): @@ -252,3 +349,5 @@ def onlp_init(): aim_pvs_init_prototypes() onlp_oid_init_prototypes() onlp_sys_init_prototypes() + onlp_fan_init_prototypes() + onlp_led_init_prototypes() From e095ffcb52f891b233e82f35b600112490bac579 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 18 Sep 2017 17:14:17 -0700 Subject: [PATCH 014/244] Fix argument order for OID enumerator --- packages/base/any/onlp/src/onlp/module/src/oids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/any/onlp/src/onlp/module/src/oids.c b/packages/base/any/onlp/src/onlp/module/src/oids.c index baea7610..861f427c 100644 --- a/packages/base/any/onlp/src/onlp/module/src/oids.c +++ b/packages/base/any/onlp/src/onlp/module/src/oids.c @@ -216,7 +216,7 @@ onlp_oid_iterate(onlp_oid_t oid, onlp_oid_type_t type, } ONLP_OID_TABLE_ITER(hdr.coids, oidp) { - if(type == 0 || ONLP_OID_IS_TYPE(*oidp, type)) { + if(type == 0 || ONLP_OID_IS_TYPE(type, *oidp)) { int rv = itf(*oidp, cookie); if(rv < 0) { return rv; From 02261de11a1cc44222b33e19d97a9842b3a1516c Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 18 Sep 2017 17:14:37 -0700 Subject: [PATCH 015/244] Added fan test and initial LED test --- .../module/python/onlp/test/OnlpApiTest.py | 638 +++++++++++++++++- 1 file changed, 601 insertions(+), 37 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index 691f2266..b6e42141 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -8,12 +8,21 @@ import unittest import logging import re import time +import subprocess import onlp.onlp onlp.onlp.onlp_init() libonlp = onlp.onlp.libonlp +def isVirtual(): + with open("/etc/onl/platform") as fd: + buf = fd.read() + return "bigswitch" in buf + +def skipIfVirtual(reason="this test only works with a physical device"): + return unittest.skipIf(isVirtual(), reason) + class OnlpTestMixin(object): def setUp(self): @@ -28,6 +37,11 @@ class OnlpTestMixin(object): libonlp.aim_pvs_destroy(self.aim_pvs_buffer_p) + def assertStatusOK(self, sts): + if sts == onlp.onlp.ONLP_STATUS.OK: + return + raise AssertionError("invalid ONLP status %s" % onlp.onlp.ONLP_STATUS.name(sts)) + class InitTest(OnlpTestMixin, unittest.TestCase): @@ -149,7 +163,7 @@ class SysHdrMixin(object): coids = [x for x in hdr.children()] self.assert_(coids) - self.assert_(len(coids) < onlp.onlp.ONLP_OID_TABLE_SIZE) + self.assertLess(len(coids), onlp.onlp.ONLP_OID_TABLE_SIZE) def _oidType(oid): return onlp.onlp.ONLP_OID_TYPE.name(oid._id>>24) @@ -167,7 +181,10 @@ class SysHdrMixin(object): for foid in foids: self.log.info("oid %d (%s): %s", foid._id, _oidType(foid), foid.description) - self.assertEqual("FAN", _oidType(foid)) + if _oidType(foid) in ["FAN", "THERMAL",]: + pass + else: + raise AssertionError("invalid child oid") # parent should the the PSU or the chassis if coid._id == foid.poid: pass @@ -199,13 +216,17 @@ class SysTest(OnlpTestMixin, def testOnieInfo(self): """Verify the ONIE fields.""" - product_re = re.compile("(.*)-(.*)-(.*)") + product_re = re.compile("[a-z]*[a-zA-Z0-9_. -]") m = product_re.match(self.sys_info.onie_info.product_name) - self.assertIsNotNone(m) + if m is None: + raise AssertionError("invalid product name %s" + % repr(self.sys_info.onie_info.product_name)) vendor_re = re.compile("[A-Z][a-z]*[a-zA-Z0-9_. -]") m = vendor_re.match(self.sys_info.onie_info.vendor) - self.assertIsNotNone(m) + if m is None: + raise AssertionError("invalid vendor %s" + % repr(self.sys_info.onie_info.vendor)) self.assertIn('.', self.sys_info.onie_info.onie_version) @@ -213,7 +234,7 @@ class SysTest(OnlpTestMixin, # if there are any, make sure the are well-formed for vx in self.sys_info.onie_info.vx_list: sz = vx.size - self.assert_(sz <= 256) + self.assertLessEqual(sz, 256) def testPlatformInfo(self): """Verify the platform info fields.""" @@ -234,20 +255,30 @@ class SysTest(OnlpTestMixin, def testManage(self): """Verify we can start/stop platform management.""" - code = libonlp.onlp_sys_platform_manage_start(0) - self.assert_(code >= 0) + try: - for i in range(10): - libonlp.onlp_sys_platform_manage_now() - time.sleep(0.25) + subprocess.check_call(('service', 'onlpd', 'stop',)) - code = libonlp.onlp_sys_platform_manage_stop(0) - self.assert_(code >= 0) + code = libonlp.onlp_sys_platform_manage_init() + self.assertGreaterEqual(code, 0) - time.sleep(2.0) + code = libonlp.onlp_sys_platform_manage_start(0) + self.assertGreaterEqual(code, 0) - code = libonlp.onlp_sys_platform_manage_join(0) - self.assert_(code >= 0) + for i in range(10): + libonlp.onlp_sys_platform_manage_now() + time.sleep(0.25) + + code = libonlp.onlp_sys_platform_manage_stop(0) + self.assertGreaterEqual(code, 0) + + time.sleep(2.0) + + code = libonlp.onlp_sys_platform_manage_join(0) + self.assertGreaterEqual(code, 0) + + except: + subprocess.check_call(('service', 'onlpd', 'start',)) def testSysDump(self): """Test the SYS OID debug dump.""" @@ -297,6 +328,23 @@ class SysTest(OnlpTestMixin, code = libonlp.onlp_sys_ioctl(9999) self.assertEqual(onlp.onlp.ONLP_STATUS.E_UNSUPPORTED, code) +class OidIterator(object): + + def __init__(self, log): + self.log = log or logging.getLogger("visit") + + def visit(self, oid, cookie): + return onlp.onlp.ONLP_STATUS.OK + + def cvisit(self): + def _v(oid, cookie): + try: + return self.visit(oid, cookie) + except: + self.log.exception("visitor failed") + return onlp.onlp.ONLP_STATUS.E_GENERIC + return onlp.onlp.onlp_oid_iterate_f(_v) + class OidTest(OnlpTestMixin, SysHdrMixin, unittest.TestCase): @@ -318,23 +366,6 @@ class OidTest(OnlpTestMixin, def testOidIter(self): """Test the oid iteration functions.""" - class OidIterator(object): - - def __init__(self, log): - self.log = log or logging.getLogger("visit") - - def visit(self, oid, cookie): - return onlp.onlp.ONLP_STATUS.E_OK - - def cvisit(self): - def _v(oid, cookie): - try: - return self.visit(oid, cookie) - except: - self.log.exception("visitor failed") - return onlp.onlp.ONLP_STATUS.E_GENERIC - return onlp.onlp.onlp_oid_iterate_f(_v) - class V1(OidIterator): def __init__(self, cookie, log): @@ -347,7 +378,7 @@ class OidTest(OnlpTestMixin, raise AssertionError("invalid cookie") self.log.info("found oid %d", oid) self.oids.append(oid) - return onlp.onlp.ONLP_STATUS.E_OK + return onlp.onlp.ONLP_STATUS.OK oidType = 0 cookie = 0xdeadbeef @@ -359,8 +390,17 @@ class OidTest(OnlpTestMixin, self.assert_(v1.oids) oids = list(v1.oids) + # filter based on OID type + + oidType = onlp.onlp.ONLP_OID_TYPE.PSU + v1b = V1(cookie, log=self.log.getChild("v1b")) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, oidType, v1b.cvisit(), cookie) + self.assert_(v1b.oids) + self.assertLess(len(v1b.oids), len(oids)) + # validate error recovery + oidType = 0 v2 = V1(cookie+1, log=self.log.getChild("v2")) libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, oidType, v2.cvisit(), cookie) self.assertEqual([], v2.oids) @@ -378,7 +418,7 @@ class OidTest(OnlpTestMixin, return onlp.onlp.ONLP_STATUS.E_GENERIC self.log.info("found oid %d", oid) self.oids.append(oid) - return onlp.onlp.ONLP_STATUS.E_OK + return onlp.onlp.ONLP_STATUS.OK v3 = V3(log=self.log.getChild("v3")) cookie = oids[4] @@ -399,7 +439,7 @@ class OidTest(OnlpTestMixin, buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) lines = buf.string_at().splitlines(False) lines = [x for x in lines if 'Description' in x] - self.assert_(len(lines) > 1) + self.assertGreater(len(lines), 1) def testOidShow(self): oid = self.hdr.coids[0] @@ -415,7 +455,531 @@ class OidTest(OnlpTestMixin, buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) lines = buf.string_at().splitlines(False) lines = [x for x in lines if 'Description' in x] - self.assert_(len(lines) > 1) + self.assertGreater(len(lines), 1) + +class FanTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/fan.h.""" + + FAN_MODE_VALID = False + # 'fan mode' configuration is not implemented + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_sys_init() + libonlp.onlp_fan_init() + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def auditFanOid(self, oid): + """Test the power-on behavior of a fan.""" + + hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_fan_hdr_get(oid, ctypes.byref(hdr)) + self.assertEqual(oid, hdr._id) + + fan = onlp.onlp.onlp_fan_info() + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + + self.assertEqual(oid, fan.hdr._id) + self.assert_(fan.model) + self.assert_(fan.serial) + self.log.info("auditing fan %d: %s (S/N %s)", + oid & 0xFFFFFF, + fan.model, fan.serial) + + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.B2F: + pass + elif fan.caps & onlp.onlp.ONLP_FAN_CAPS.F2B: + pass + else: + raise AssertionError("invalid fan caps") + + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_RPM: + self.assertGreater(fan.rpm, 0) + else: + self.log.warn("fan does not support RPM get") + + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_PERCENTAGE: + self.assertGreater(fan.percentage, 0) + self.assertLessEqual(fan.percentage, 100) + else: + self.log.warn("fan does not support PCT get") + + if self.FAN_MODE_VALID: + self.assertNotEqual(onlp.onlp.ONLP_FAN_MODE.OFF, fan.mode) + # default, fan should be running + + self.assert_(onlp.onlp.ONLP_FAN_STATUS.PRESENT & fan.status) + # default, fan should be present + + if fan.status & onlp.onlp.ONLP_FAN_STATUS.B2F: + self.assert_(onlp.onlp.ONLP_ONLP_FAN_CAPS.B2F) + elif fan.status & onlp.onlp.ONLP_FAN_STATUS.F2B: + self.assert_(onlp.onlp.ONLP_FAN_CAPS.F2B) + else: + self.log.warn("fan direction not supported") + + # retrieve fan status separately + sts = ctypes.c_uint() + libonlp.onlp_fan_status_get(oid, ctypes.byref(sts)) + self.assert_(onlp.onlp.ONLP_FAN_STATUS.PRESENT & sts.value) + + # try to manipulate the fan speed + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.SET_RPM: + self.auditFanRpm(oid) + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.SET_PERCENTAGE: + self.auditFanPct(oid) + if (self.FAN_MODE_VALID + and (fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_RPM + or fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_PERCENTAGE)): + self.auditFanMode(oid) + if (fan.caps & onlp.onlp.ONLP_FAN_CAPS.F2B + and fan.caps & onlp.onlp.ONLP_FAN_CAPS.B2F): + self.auditFanDir(oid) + + flags = 0 + libonlp.onlp_fan_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("Fan", bufStr) + + libonlp.onlp_fan_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("Fan", bufStr) + + def auditFanRpm(self, oid): + """Try to adjust the fan RPM. + + Note that the maximum fan speed is not know ahead of time. + Also note the mechanicals here: + - fan spin-up takes several seconds + - fan spin-down takes much longer than spin-up + - actual target fan speeds are set by the driver + - for safety reasons there may not be an 'off' setting + """ + + fan = onlp.onlp.onlp_fan_info() + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + if self.FAN_MODE_VALID: + self.assertEqual(fan.mode, onlp.onlp.ONLP_FAN_MODE.MAX) + minRpm = maxRpm = curRpm = fan.rpm + + speeds = [] + pcts = [] + try: + subprocess.check_call(('service', 'onlpd', 'stop',)) + + self.log.info("probing for max fan speed") + nspeed = curRpm + while True: + self.log.info("current fan rpm is %d", nspeed) + self.log.info("trying higher fan rpm is %d", nspeed * 2) + libonlp.onlp_fan_rpm_set(oid, nspeed * 2) + time.sleep(5.0) + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + self.log.info("probed fan speed is %d", fan.rpm) + if fan.rpm > (nspeed * 125 // 100): + nspeed = fan.rpm + continue + + self.log.info("max fan speed is %d", fan.rpm) + maxRpm = fan.rpm + break + + self.log.info("probing for min fan speed") + nspeed = curRpm + while True: + self.log.info("setting fan rpm to %d", nspeed) + self.log.info("trying lower fan rpm is %d", nspeed // 2) + libonlp.onlp_fan_rpm_set(oid, nspeed // 2) + + time.sleep(10.0) + # spin-down is slower than spin-up + + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + self.log.info("probed fan speed is %d", fan.rpm) + if fan.rpm < (nspeed * 75 // 100): + nspeed = fan.rpm + continue + + self.log.info("min fan speed is %d", fan.rpm) + minRpm = fan.rpm + break + + self.assertLess(minRpm, maxRpm) + + self.log.info("cycling through fan speeds") + for nspeed in range(minRpm, maxRpm, (maxRpm-minRpm)//3): + self.log.info("setting fan rpm to %d", nspeed) + libonlp.onlp_fan_rpm_set(oid, nspeed) + time.sleep(5.0) + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + speeds.append(fan.rpm) + pcts.append(fan.percentage) + + finally: + libonlp.onlp_fan_rpm_set(oid, curRpm) + libonlp.onlp_fan_mode_set(oid, onlp.onlp.ONLP_FAN_MODE.MAX) + subprocess.check_call(('service', 'onlpd', 'start',)) + + # fan speeds should be monotonically increasing + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_RPM: + self.assertEqual(speeds, sorted(speeds)) + self.assertLess(minRpm * 95 // 100, speeds[0]) + self.assertGreater(maxRpm * 105 // 100, speeds[-1]) + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_PERCENTAGE: + self.assertEqual(pcts, sorted(pcts)) + ##self.assertEqual(0, pcts[0]) + ##self.assertGreater(105, pcts[-1]) + + def auditFanPct(self, oid): + """Try to adjust the fan percentage.""" + + fan = onlp.onlp.onlp_fan_info() + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + if self.FAN_MODE_VALID: + self.assertEqual(fan.mode, onlp.onlp.ONLP_FAN_MODE.MAX) + + speeds = [] + pcts = [] + try: + subprocess.check_call(('service', 'onlpd', 'stop',)) + + libonlp.onlp_fan_percentage_set(oid, 0) + time.sleep(10.0) + # initially spin down the fan + + for npct in [0, 33, 66, 100,]: + self.log.info("setting fan percentage to %d", npct) + libonlp.onlp_fan_percentage_set(oid, npct) + time.sleep(5.0) + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + speeds.append(fan.rpm) + pcts.append(fan.percentage) + finally: + libonlp.onlp_fan_percentage_set(oid, 100) + libonlp.onlp_fan_mode_set(oid, onlp.onlp.ONLP_FAN_MODE.MAX) + subprocess.check_call(('service', 'onlpd', 'start',)) + + # fan speeds should be monotonically increasing + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_RPM: + self.assertEqual(speeds, sorted(speeds)) + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_PERCENTAGE: + self.assertEqual(pcts, sorted(pcts)) + + def auditFanDir(self, oid): + """Try to adjust the fan direction.""" + unittest.skip("not implemented") + + def auditFanMode(self, oid): + """Try to adjust the fan speed using the mode specifier.""" + + fan = onlp.onlp.onlp_fan_info() + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + self.assertEqual(fan.mode, onlp.onlp.ONLP_FAN_MODE.MAX) + + speeds = [] + pcts = [] + try: + subprocess.check_call(('service', 'onlpd', 'stop',)) + for nmode in [onlp.onlp.ONLP_FAN_MODE.OFF, + onlp.onlp.ONLP_FAN_MODE.SLOW, + onlp.onlp.ONLP_FAN_MODE.NORMAL, + onlp.onlp.ONLP_FAN_MODE.FAST, + onlp.onlp.ONLP_FAN_MODE.MAX,]: + self.log.info("setting fan mode to %s", onlp.onlp.ONLP_FAN_MODE.name(nmode)) + libonlp.onlp_fan_mode_set(oid, nmode) + time.sleep(2.0) + libonlp.onlp_fan_info_get(oid, ctypes.byref(fan)) + speeds.append(fan.rpm) + pcts.append(fan.percentage) + finally: + libonlp.onlp_fan_mode_set(oid, onlp.onlp.ONLP_FAN_MODE.MAX) + subprocess.check_call(('service', 'onlpd', 'start',)) + + # fan speeds should be monotonically increasing + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_RPM: + self.assertEqual(speeds, sorted(speeds)) + self.assertEqual(0, speeds[0]) + self.assertGreater(105*maxRpm//100, speeds[-1]) + if fan.caps & onlp.onlp.ONLP_FAN_CAPS.GET_PERCENTAGE: + self.assertEqual(pcts, sorted(pcts)) + self.assertEqual(0, pcts[0]) + self.assertGreater(105, pcts[-1]) + + def testFindFans(self): + """Verify that the system has fans.""" + + class V(OidIterator): + + def __init__(self, log): + super(V, self).__init__(log) + self.oids = [] + + def visit(self, oid, cookie): + self.log.info("found FAN oid %d", oid) + self.oids.append(oid) + return onlp.onlp.ONLP_STATUS.OK + + v = V(log=self.log.getChild("fan")) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, + onlp.onlp.ONLP_OID_TYPE.FAN, + v.cvisit(), 0) + self.assert_(v.oids) + + self.auditFanOid(v.oids[0]) + +class LedTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/led.h. + + XXX roth -- need to flesh this out using a physical device. + """ + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_sys_init() + libonlp.onlp_led_init() + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testFindLeds(self): + """Verify that the system has LEDs.""" + + class V(OidIterator): + + def __init__(self, log): + super(V, self).__init__(log) + self.oids = [] + + def visit(self, oid, cookie): + self.log.info("found LED oid %d", oid) + self.oids.append(oid) + return onlp.onlp.ONLP_STATUS.OK + + v = V(log=self.log.getChild("led")) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, + onlp.onlp.ONLP_OID_TYPE.LED, + v.cvisit(), 0) + self.assert_(v.oids) + + self.auditLedOid(v.oids[0]) + + def auditLedOid(self, oid): + + hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_led_hdr_get(oid, ctypes.byref(hdr)) + self.assertEqual(oid, hdr._id) + + led = onlp.onlp.onlp_led_info() + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + + self.assertEqual(oid, led.hdr._id) + + self.assert_(led.caps) + # should support some non-empty set of capabilities + + self.log.info("auditing led %d", + oid & 0xFFFFFF) + + self.assert_(led.status & onlp.onlp.ONLP_LED_STATUS.PRESENT) + + # retrieve led status separately + sts = ctypes.c_uint() + libonlp.onlp_led_status_get(oid, ctypes.byref(sts)) + self.assert_(onlp.onlp.ONLP_LED_STATUS.PRESENT & sts.value) + + if led.caps & onlp.onlp.ONLP_LED_CAPS.CHAR: + self.auditLedChar(oid) + if led.caps & onlp.onlp.ONLP_LED_CAPS.ON_OFF: + self.auditLedOnOff(oid) + self.auditLedColors(oid) + self.auditLedBlink(oid) + + flags = 0 + libonlp.onlp_led_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("LED", bufStr) + + libonlp.onlp_led_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("LED", bufStr) + + def auditLedChar(self, oid): + + led = onlp.onlp.onlp_led_info() + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + saveChar = led.char + + try: + for nchar in ['0', '1', '2', '3',]: + self.log.info("led %d: char '%s'", oid, nchar) + + sts = libonlp.onlp_led_char_set(oid, nchar) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(nchar, led.char) + except: + libonlp.onlp_led_char_set(oid, saveChar) + raise + + def auditLedOnOff(self, oid): + + led = onlp.onlp.onlp_led_info() + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + saveMode = led.mode + + if saveMode == onlp.onlp.ONLP_LED_MODE.OFF: + pass + elif saveMode == onlp.onlp.ONLP_LED_MODE.ON: + pass + else: + self.log.warn("invalid LED on/off mode %s", + onlp.onlp.ONLP_LED_MODE.name(saveMode)) + + try: + for i in range(4): + self.log.info("led %d: on", oid) + + sts = libonlp.onlp_led_set(oid, 1) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(onlp.onlp.ONLP_LED_MODE.ON, led.mode) + + sts = libonlp.onlp_led_get(oid, 0) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(onlp.onlp.ONLP_LED_MODE.OFF, led.mode) + + except: + if saveMode == onlp.onlp.ONLP_LED_MODE.OFF: + libonlp.onlp_led_set(oid, 0) + else: + libonlp.onlp_led_set(oid, 1) + raise + + def auditLedColors(self, oid): + + led = onlp.onlp.onlp_led_info() + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + saveMode = led.mode + + allModes = [] + if led.caps & onlp.onlp.ONLP_LED_CAPS.RED: + allModes.append(onlp.onlp.ONLP_LED_MODE.RED) + if led.caps & onlp.onlp.ONLP_LED_CAPS.ORANGE: + allModes.append(onlp.onlp.ONLP_LED_MODE.ORANGE) + if led.caps & onlp.onlp.ONLP_LED_CAPS.YELLOW: + allModes.append(onlp.onlp.ONLP_LED_MODE.YELLOW) + if led.caps & onlp.onlp.ONLP_LED_CAPS.GREEN: + allModes.append(onlp.onlp.ONLP_LED_MODE.GREEN) + if led.caps & onlp.onlp.ONLP_LED_CAPS.BLUE: + allModes.append(onlp.onlp.ONLP_LED_MODE.BLUE) + if led.caps & onlp.onlp.ONLP_LED_CAPS.PURPLE: + allModes.append(onlp.onlp.ONLP_LED_MODE.PURPLE) + if led.caps & onlp.onlp.ONLP_LED_CAPS.AUTO: + allModes.append(onlp.onlp.ONLP_LED_MODE.AUTO) + + if not allModes: + unittest.skip("colors not supported") + return + self.log.info("found %d supported colors", len(allModes)) + + try: + for ncolor in allModes: + self.log.info("led %d: color '%s'", oid, onlp.onlp.ONLP_LED_MODE.name(ncolor)) + + sts = libonlp.onlp_led_mode_set(oid, ncolor) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(ncolor, led.mode) + + self.log.info("led %d: OFF", oid) + + sts = libonlp.onlp_led_mode_set(oid, onlp.onlp.ONLP_LED_MODE.OFF) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(onlp.onlp.ONLP_LED_MODE.OFF, led.mode) + + except: + libonlp.onlp_led_mode_set(oid, saveMode) + raise + + def auditLedBlink(self, oid): + + led = onlp.onlp.onlp_led_info() + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + saveMode = led.mode + + allModes = [] + if led.caps & onlp.onlp.ONLP_LED_CAPS.RED_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.RED_BLINKING) + if led.caps & onlp.onlp.ONLP_LED_CAPS.ORANGE_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.ORANGE_BLINKING) + if led.caps & onlp.onlp.ONLP_LED_CAPS.YELLOW_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.YELLOW_BLINKING) + if led.caps & onlp.onlp.ONLP_LED_CAPS.GREEN_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.GREEN_BLINKING) + if led.caps & onlp.onlp.ONLP_LED_CAPS.BLUE_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.BLUE_BLINKING) + if led.caps & onlp.onlp.ONLP_LED_CAPS.PURPLE_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.PURPLE_BLINKING) + if led.caps & onlp.onlp.ONLP_LED_CAPS.AUTO_BLINKING: + allModes.append(onlp.onlp.ONLP_LED_MODE.AUTO_BLINKING) + + if not allModes: + unittest.skip("blinking colors not supported") + return + self.log.info("found %d supported blink colors", len(allModes)) + + try: + for ncolor in allModes: + self.log.info("led %d: blink color '%s'", oid, onlp.onlp.ONLP_LED_MODE.name(ncolor)) + + sts = libonlp.onlp_led_mode_set(oid, ncolor) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(ncolor, led.mode) + + self.log.info("led %d: OFF", oid) + + sts = libonlp.onlp_led_mode_set(oid, onlp.onlp.ONLP_LED_MODE.OFF) + self.assertStatusOK(sts) + + time.sleep(1.0) + + libonlp.onlp_led_info_get(oid, ctypes.byref(led)) + self.assertEqual(onlp.onlp.ONLP_LED_MODE.OFF, led.mode) + + except: + libonlp.onlp_led_mode_set(oid, saveMode) + raise if __name__ == "__main__": logging.basicConfig() From 45b5331eb7d171193dba65f908b0bfa4fc83b302 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 18 Sep 2017 18:28:16 -0700 Subject: [PATCH 016/244] Added a working LED test --- .../module/python/onlp/test/OnlpApiTest.py | 68 ++++++++++++++----- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index b6e42141..6daf811f 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -277,7 +277,7 @@ class SysTest(OnlpTestMixin, code = libonlp.onlp_sys_platform_manage_join(0) self.assertGreaterEqual(code, 0) - except: + finally: subprocess.check_call(('service', 'onlpd', 'start',)) def testSysDump(self): @@ -795,23 +795,61 @@ class LedTest(OnlpTestMixin, libonlp.onlp_led_status_get(oid, ctypes.byref(sts)) self.assert_(onlp.onlp.ONLP_LED_STATUS.PRESENT & sts.value) - if led.caps & onlp.onlp.ONLP_LED_CAPS.CHAR: - self.auditLedChar(oid) - if led.caps & onlp.onlp.ONLP_LED_CAPS.ON_OFF: - self.auditLedOnOff(oid) - self.auditLedColors(oid) - self.auditLedBlink(oid) + try: + subprocess.check_call(('service', 'onlpd', 'stop',)) + + if led.caps & onlp.onlp.ONLP_LED_CAPS.CHAR: + self.auditLedChar(oid) + if (led.caps & onlp.onlp.ONLP_LED_CAPS.ON_OFF + and not self.hasColors(led.caps)): + self.auditLedOnOff(oid) + self.auditLedColors(oid) + self.auditLedBlink(oid) + + finally: + subprocess.check_call(('service', 'onlpd', 'start',)) + flags = 0 libonlp.onlp_led_dump(oid, self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) bufStr = buf.string_at() - self.assertIn("LED", bufStr) + self.assertIn("led @", bufStr) libonlp.onlp_led_show(oid, self.aim_pvs_buffer_p, flags) buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) bufStr = buf.string_at() - self.assertIn("LED", bufStr) + self.assertIn("led @", bufStr) + + def hasColors(self, caps): + """True if this a color LED.""" + + if caps & onlp.onlp.ONLP_LED_CAPS.RED: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.RED_BLINKING: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.ORANGE: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.ORANGE_BLINKING: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.YELLOW: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.YELLOW_BLINKING: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.GREEN: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.GREEN_BLINKING: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.BLUE: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.BLUE_BLINKING: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.PURPLE: + return True + if caps & onlp.onlp.ONLP_LED_CAPS.PURPLE_BLINKING: + return True + + return False def auditLedChar(self, oid): @@ -830,9 +868,8 @@ class LedTest(OnlpTestMixin, libonlp.onlp_led_info_get(oid, ctypes.byref(led)) self.assertEqual(nchar, led.char) - except: + finally: libonlp.onlp_led_char_set(oid, saveChar) - raise def auditLedOnOff(self, oid): @@ -868,12 +905,11 @@ class LedTest(OnlpTestMixin, libonlp.onlp_led_info_get(oid, ctypes.byref(led)) self.assertEqual(onlp.onlp.ONLP_LED_MODE.OFF, led.mode) - except: + finally: if saveMode == onlp.onlp.ONLP_LED_MODE.OFF: libonlp.onlp_led_set(oid, 0) else: libonlp.onlp_led_set(oid, 1) - raise def auditLedColors(self, oid): @@ -924,9 +960,8 @@ class LedTest(OnlpTestMixin, libonlp.onlp_led_info_get(oid, ctypes.byref(led)) self.assertEqual(onlp.onlp.ONLP_LED_MODE.OFF, led.mode) - except: + finally: libonlp.onlp_led_mode_set(oid, saveMode) - raise def auditLedBlink(self, oid): @@ -977,9 +1012,8 @@ class LedTest(OnlpTestMixin, libonlp.onlp_led_info_get(oid, ctypes.byref(led)) self.assertEqual(onlp.onlp.ONLP_LED_MODE.OFF, led.mode) - except: + finally: libonlp.onlp_led_mode_set(oid, saveMode) - raise if __name__ == "__main__": logging.basicConfig() From e5abf25a574eb552777f4e83418c48a6a2dc1130 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 19 Sep 2017 16:56:55 -0700 Subject: [PATCH 017/244] Added bindings for onlp_config.h --- .../src/onlp/module/python/onlp/onlp/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index 4e9329b9..6d924f16 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -341,6 +341,18 @@ def onlp_led_init_prototypes(): libonlp.onlp_led_show.restype = None libonlp.onlp_led_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) +# onlp/onlp_config.h + +# don't need the actual config structure, since we'll be using lookups + +def onlp_config_init_prototypes(): + + libonlp.onlp_config_lookup.restype = ctypes.c_char_p + libonlp.onlp_config_lookup.argtypes = (ctypes.c_char_p,) + + libonlp.onlp_config_show.restype = ctypes.c_int + libonlp.onlp_config_show.argtypes = (ctypes.POINTER(aim_pvs),) + # onlp/onlp.h def onlp_init(): @@ -351,3 +363,4 @@ def onlp_init(): onlp_sys_init_prototypes() onlp_fan_init_prototypes() onlp_led_init_prototypes() + onlp_config_init_prototypes() From ee34d51928d6fd1179cf6dfb4c1085f5d5e4c7ee Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 19 Sep 2017 16:57:09 -0700 Subject: [PATCH 018/244] config lookup conditional was wrong --- packages/base/any/onlp/src/onlp/module/src/onlp_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_config.c b/packages/base/any/onlp/src/onlp/module/src/onlp_config.c index 7b90cf44..0a2dbe60 100644 --- a/packages/base/any/onlp/src/onlp/module/src/onlp_config.c +++ b/packages/base/any/onlp/src/onlp/module/src/onlp_config.c @@ -145,7 +145,7 @@ onlp_config_lookup(const char* setting) { int i; for(i = 0; onlp_config_settings[i].name; i++) { - if(strcmp(onlp_config_settings[i].name, setting)) { + if(!strcmp(onlp_config_settings[i].name, setting)) { return onlp_config_settings[i].value; } } From 11064e23facec7ed2c9c47a3368bc3806e5d9b66 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 19 Sep 2017 16:57:45 -0700 Subject: [PATCH 019/244] Added tests for onlp_config.h --- .../module/python/onlp/test/OnlpApiTest.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index 6daf811f..dc70d6ff 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -1015,6 +1015,30 @@ class LedTest(OnlpTestMixin, finally: libonlp.onlp_led_mode_set(oid, saveMode) +class ConfigTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/onlp_config.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testConfig(self): + + s = libonlp.onlp_config_lookup("ONLP_CONFIG_INFO_STR_MAX") + self.assertEqual('64', s) + + s = libonlp.onlp_config_lookup("foo") + self.assertIsNone(s) + + def testConfigShow(self): + + libonlp.onlp_config_show(self.aim_pvs_buffer_p) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + self.assertIn("ONLP_CONFIG_INFO_STR_MAX = 64\n", buf.string_at()) + if __name__ == "__main__": logging.basicConfig() unittest.main() From 7f1f6e5dd491f46182ac37f50f15d34c6e0327cf Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 19 Sep 2017 18:27:48 -0700 Subject: [PATCH 020/244] Added bindings for thermal.h --- .../onlp/module/python/onlp/onlp/__init__.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index 6d924f16..cd6516de 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -353,6 +353,38 @@ def onlp_config_init_prototypes(): libonlp.onlp_config_show.restype = ctypes.c_int libonlp.onlp_config_show.argtypes = (ctypes.POINTER(aim_pvs),) +# onlp/thermal.h + +class onlp_thermal_info_thresholds(ctypes.Structure): + _fields_ = [('warning', ctypes.c_int,), + ('error', ctypes.c_int,), + ('shutdown', ctypes.c_int,),] + +class onlp_thermal_info(ctypes.Structure): + _fields_ = [('hdr', onlp_oid_hdr,), + ('status', ctypes.c_uint,), + ('caps', ctypes.c_uint,), + ('mcelcius', ctypes.c_int,), + ('thresholds', onlp_thermal_info_thresholds,),] + +def onlp_thermal_init_prototypes(): + + libonlp.onlp_thermal_init.restype = ctypes.c_int + + libonlp.onlp_thermal_info_get.restype = ctypes.c_int + libonlp.onlp_thermal_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_thermal_info),) + + libonlp.onlp_thermal_hdr_get.restype = ctypes.c_int + libonlp.onlp_thermal_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) + + libonlp.onlp_thermal_ioctl.restype = ctypes.c_int + + libonlp.onlp_thermal_dump.restype = None + libonlp.onlp_thermal_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs),) + + libonlp.onlp_thermal_show.restype = None + libonlp.onlp_thermal_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs),) + # onlp/onlp.h def onlp_init(): @@ -364,3 +396,4 @@ def onlp_init(): onlp_fan_init_prototypes() onlp_led_init_prototypes() onlp_config_init_prototypes() + onlp_thermal_init_prototypes() From 83830a6afafabc17f572d1919080b9aa732d7ebb Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 19 Sep 2017 18:28:13 -0700 Subject: [PATCH 021/244] Unit tests for thermal.h --- .../module/python/onlp/test/OnlpApiTest.py | 84 ++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index dc70d6ff..f751f92d 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -508,7 +508,7 @@ class FanTest(OnlpTestMixin, else: self.log.warn("fan does not support PCT get") - if self.FAN_MODE_VALID: + if self.fan_mode: self.assertNotEqual(onlp.onlp.ONLP_FAN_MODE.OFF, fan.mode) # default, fan should be running @@ -1016,7 +1016,7 @@ class LedTest(OnlpTestMixin, libonlp.onlp_led_mode_set(oid, saveMode) class ConfigTest(OnlpTestMixin, - unittest.TestCase): + unittest.TestCase): """Test interfaces in onlp/onlp_config.h.""" def setUp(self): @@ -1039,6 +1039,86 @@ class ConfigTest(OnlpTestMixin, buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) self.assertIn("ONLP_CONFIG_INFO_STR_MAX = 64\n", buf.string_at()) +class ThermalTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/thermal.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_thermal_init() + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testFindThermal(self): + + class V(OidIterator): + + def __init__(self, log): + super(V, self).__init__(log) + self.oids = [] + + def visit(self, oid, cookie): + self.log.info("found thermal oid %d", oid) + self.oids.append(oid) + return onlp.onlp.ONLP_STATUS.OK + + v = V(log=self.log.getChild("thermal")) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, + onlp.onlp.ONLP_OID_TYPE.THERMAL, + v.cvisit(), 0) + self.assert_(v.oids) + + self.auditThermalOid(v.oids[0]) + + def auditThermalOid(self, oid): + + hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_thermal_hdr_get(oid, ctypes.byref(hdr)) + self.assertEqual(oid, hdr._id) + + thm = onlp.onlp.onlp_thermal_info() + libonlp.onlp_thermal_info_get(oid, ctypes.byref(thm)) + + self.assertEqual(oid, thm.hdr._id) + + self.assert_(thm.caps) + # should support some non-empty set of capabilities + + self.assert_(thm.caps & onlp.onlp.ONLP_THERMAL_CAPS.GET_TEMPERATURE) + # sensor should at least report temperature + + self.log.info("auditing thermal %d", + oid & 0xFFFFFF) + + self.assert_(thm.status & onlp.onlp.ONLP_THERMAL_STATUS.PRESENT) + # sensor should be present + + self.assertGreater(thm.mcelcius, 20000) + self.assertLess(thm.mcelcius, 35000) + # temperature should be non-crazy + + # retrieve thermal status separately + sts = ctypes.c_uint() + libonlp.onlp_thermal_status_get(oid, ctypes.byref(sts)) + self.assert_(onlp.onlp.ONLP_THERMAL_STATUS.PRESENT & sts.value) + + # test ioctl + code = libonlp.onlp_thermal_ioctl(9999) + self.assertEqual(onlp.onlp.ONLP_STATUS.E_UNSUPPORTED, code) + + flags = 0 + libonlp.onlp_thermal_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("thermal @", bufStr) + + libonlp.onlp_thermal_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("thermal @", bufStr) + if __name__ == "__main__": logging.basicConfig() unittest.main() From f1a53e3c600be92e62b42a1fe246b1c77bc2d3c6 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 21 Sep 2017 14:42:05 -0700 Subject: [PATCH 022/244] Fixed deadlock --- packages/base/any/onlp/src/onlp/module/src/psu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/any/onlp/src/onlp/module/src/psu.c b/packages/base/any/onlp/src/onlp/module/src/psu.c index 5aaf166c..724ae42f 100644 --- a/packages/base/any/onlp/src/onlp/module/src/psu.c +++ b/packages/base/any/onlp/src/onlp/module/src/psu.c @@ -69,7 +69,7 @@ onlp_psu_status_get_locked__(onlp_oid_t id, uint32_t* status) } if(ONLP_UNSUPPORTED(rv)) { onlp_psu_info_t pi; - rv = onlp_psu_info_get(id, &pi); + rv = onlp_psui_info_get(id, &pi); *status = pi.status; } return rv; From 3ac42136f871d13a66a0cb11cb45e89aabf6855b Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 21 Sep 2017 14:42:46 -0700 Subject: [PATCH 023/244] Added bindings for psu.h - also cleaned up module init --- .../onlp/module/python/onlp/onlp/__init__.py | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index cd6516de..d6d628f0 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -6,6 +6,7 @@ Module init for onlp.onlp import ctypes libonlp = ctypes.cdll.LoadLibrary("libonlp.so") +libonlp.onlp_init() import ctypes.util libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) @@ -113,17 +114,20 @@ def aim_pvs_init_prototypes(): # onlp.yml +##ONLP_CONFIG_INFO_STR_MAX = int(libonlp.onlp_config_lookup("ONLP_CONFIG_INFO_STR_MAX")) ONLP_CONFIG_INFO_STR_MAX = 64 -# XXX roth -- no cdefs support (yet) +# prototype for onlp_config_lookup is not defined yet, see below # onlp/oids.h onlp_oid = ctypes.c_uint ONLP_OID_SYS = (ONLP_OID_TYPE.SYS<<24) | 1 +# XXX not a config option ONLP_OID_DESC_SIZE = 128 ONLP_OID_TABLE_SIZE = 32 +# XXX not a config option class OidTableIterator(object): @@ -374,6 +378,9 @@ def onlp_thermal_init_prototypes(): libonlp.onlp_thermal_info_get.restype = ctypes.c_int libonlp.onlp_thermal_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_thermal_info),) + libonlp.onlp_thermal_status_get.restype = ctypes.c_int + libonlp.onlp_thermal_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + libonlp.onlp_thermal_hdr_get.restype = ctypes.c_int libonlp.onlp_thermal_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) @@ -385,15 +392,58 @@ def onlp_thermal_init_prototypes(): libonlp.onlp_thermal_show.restype = None libonlp.onlp_thermal_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs),) +# onlp/psu.h + +class onlp_psu_info(ctypes.Structure): + _fields_ = [("hdr", onlp_oid_hdr,), + ("model", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,), + ("serial", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,), + ("status", ctypes.c_uint,), + ("caps", ctypes.c_uint,), + ("mvin", ctypes.c_int,), + ("mvout", ctypes.c_int,), + ("miin", ctypes.c_int,), + ("miout", ctypes.c_int,), + ("mpin", ctypes.c_int,), + ("mpout", ctypes.c_int,),] + +def onlp_psu_init_prototypes(): + + libonlp.onlp_psu_init.restype = ctypes.c_int + + libonlp.onlp_psu_info_get.restype = ctypes.c_int + libonlp.onlp_psu_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_psu_info),) + + libonlp.onlp_psu_status_get.restype = ctypes.c_int + libonlp.onlp_psu_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + + libonlp.onlp_psu_hdr_get.restype = ctypes.c_int + libonlp.onlp_psu_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) + + libonlp.onlp_psu_ioctl.restype = ctypes.c_int + + libonlp.onlp_psu_dump.restype = None + libonlp.onlp_psu_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs),) + + libonlp.onlp_psu_show.restype = None + libonlp.onlp_psu_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs),) + # onlp/onlp.h -def onlp_init(): - libonlp.onlp_init() +def init_prototypes(): aim_memory_init_prototypes() aim_pvs_init_prototypes() onlp_oid_init_prototypes() onlp_sys_init_prototypes() onlp_fan_init_prototypes() onlp_led_init_prototypes() + onlp_config_init_prototypes() + + if ONLP_CONFIG_INFO_STR_MAX != int(libonlp.onlp_config_lookup("ONLP_CONFIG_INFO_STR_MAX")): + raise AssertionError("ONLP_CONFIG_INFO_STR_MAX changed") + onlp_thermal_init_prototypes() + onlp_psu_init_prototypes() + +init_prototypes() From ab71552654b56c80734e75dd1aa90447ee0d0b86 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 21 Sep 2017 14:42:57 -0700 Subject: [PATCH 024/244] Tests for fan.h --- .../module/python/onlp/test/OnlpApiTest.py | 96 ++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index f751f92d..2121474c 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -11,7 +11,6 @@ import time import subprocess import onlp.onlp -onlp.onlp.onlp_init() libonlp = onlp.onlp.libonlp @@ -508,7 +507,7 @@ class FanTest(OnlpTestMixin, else: self.log.warn("fan does not support PCT get") - if self.fan_mode: + if self.FAN_MODE_VALID: self.assertNotEqual(onlp.onlp.ONLP_FAN_MODE.OFF, fan.mode) # default, fan should be running @@ -1119,6 +1118,99 @@ class ThermalTest(OnlpTestMixin, bufStr = buf.string_at() self.assertIn("thermal @", bufStr) +class PsuTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/psu.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_psu_init() + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + def testFindPsu(self): + + class V(OidIterator): + + def __init__(self, log): + super(V, self).__init__(log) + self.oids = [] + + def visit(self, oid, cookie): + self.log.info("found psu oid %d", oid) + self.oids.append(oid) + return onlp.onlp.ONLP_STATUS.OK + + v = V(log=self.log.getChild("psu")) + libonlp.onlp_oid_iterate(onlp.onlp.ONLP_OID_SYS, + onlp.onlp.ONLP_OID_TYPE.PSU, + v.cvisit(), 0) + self.assert_(v.oids) + + self.auditPsuOid(v.oids[0]) + + def auditPsuOid(self, oid): + + hdr = onlp.onlp.onlp_oid_hdr() + libonlp.onlp_psu_hdr_get(oid, ctypes.byref(hdr)) + self.assertEqual(oid, hdr._id) + + psu = onlp.onlp.onlp_psu_info() + libonlp.onlp_psu_info_get(oid, ctypes.byref(psu)) + + self.assertEqual(oid, psu.hdr._id) + + self.assert_(psu.caps + & (onlp.onlp.ONLP_PSU_CAPS.AC + | onlp.onlp.ONLP_PSU_CAPS.DC12 + | onlp.onlp.ONLP_PSU_CAPS.DC48)) + # should support some non-empty set of capabilities + + self.log.info("auditing psu %d", + oid & 0xFFFFFF) + + self.assert_(psu.status & onlp.onlp.ONLP_PSU_STATUS.PRESENT) + # sensor should be present + + if (psu.caps + & onlp.onlp.ONLP_PSU_CAPS.AC + & onlp.onlp.ONLP_PSU_CAPS.VOUT): + self.assertGreater(psu.mvout, 100000) + self.assertLess(psu.mvout, 125000) + if (psu.caps + & onlp.onlp.ONLP_PSU_CAPS.DC12 + & onlp.onlp.ONLP_PSU_CAPS.VOUT): + self.assertGreater(psu.mvout, 11000) + self.assertLess(psu.mvout, 13000) + if (psu.caps + & onlp.onlp.ONLP_PSU_CAPS.DC48 + & onlp.onlp.ONLP_PSU_CAPS.VOUT): + self.assertGreater(psu.mvout, 47000) + self.assertLess(psu.mvout, 49000) + # output voltage should be non-crazy + + # retrieve psu status separately + sts = ctypes.c_uint() + libonlp.onlp_psu_status_get(oid, ctypes.byref(sts)) + self.assert_(onlp.onlp.ONLP_PSU_STATUS.PRESENT & sts.value) + + # test ioctl + code = libonlp.onlp_psu_ioctl(9999) + self.assertEqual(onlp.onlp.ONLP_STATUS.E_UNSUPPORTED, code) + + flags = 0 + libonlp.onlp_psu_dump(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("psu @", bufStr) + + libonlp.onlp_psu_show(oid, self.aim_pvs_buffer_p, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + bufStr = buf.string_at() + self.assertIn("psu @", bufStr) + if __name__ == "__main__": logging.basicConfig() unittest.main() From 75b4fa3f34150c88f7216c9f72dcbe3e55231d8f Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Tue, 26 Sep 2017 18:17:17 -0700 Subject: [PATCH 025/244] as7312 PSU bug fix --- .../onlp/builds/src/module/src/platform_lib.c | 3 +-- .../onlp/builds/src/module/src/platform_lib.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c index ef569b1e..7d7d8d31 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c @@ -99,8 +99,7 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) /* Check AC model name */ - node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name); - + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model); if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { return PSU_TYPE_UNKNOWN; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h index f4cc8161..7fb175b0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h @@ -46,8 +46,8 @@ #define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node #define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node -#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/11-0051/" -#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/10-0050/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/11-0051/" +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/10-0050/" #define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node #define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node From e662a9b6699dd26c9694fa37a6d8e1ea2e00270b Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Wed, 27 Sep 2017 13:26:03 -0700 Subject: [PATCH 026/244] check for SFP28 first. --- .../base/any/onlp/src/sff/module/src/sff.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/base/any/onlp/src/sff/module/src/sff.c b/packages/base/any/onlp/src/sff/module/src/sff.c index 52279a43..f059fa4a 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff.c +++ b/packages/base/any/onlp/src/sff/module/src/sff.c @@ -142,6 +142,16 @@ sff_module_type_get(const uint8_t* eeprom) return SFF_MODULE_TYPE_40G_BASE_ER4; } + if (SFF8472_MODULE_SFP(eeprom) + && _sff8472_media_sfp28_cr(eeprom)) { + return SFF_MODULE_TYPE_25G_BASE_CR; + } + + if (SFF8472_MODULE_SFP(eeprom) + && _sff8472_media_sfp28_sr(eeprom)) { + return SFF_MODULE_TYPE_25G_BASE_SR; + } + if (SFF8472_MODULE_SFP(eeprom) && SFF8472_MEDIA_XGE_SR(eeprom) && !_sff8472_media_gbe_sx_fc_hack(eeprom)) @@ -182,16 +192,6 @@ sff_module_type_get(const uint8_t* eeprom) return SFF_MODULE_TYPE_10G_BASE_CR; } - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_sfp28_cr(eeprom)) { - return SFF_MODULE_TYPE_25G_BASE_CR; - } - - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_sfp28_sr(eeprom)) { - return SFF_MODULE_TYPE_25G_BASE_SR; - } - if (SFF8472_MODULE_SFP(eeprom) && SFF8472_MEDIA_GBE_SX(eeprom)) return SFF_MODULE_TYPE_1G_BASE_SX; From db1d98dea09d102dfcb9bb1a60aeff7429e82caf Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 27 Sep 2017 16:10:16 -0700 Subject: [PATCH 027/244] Updated strcmp for enum lookup --- packages/base/any/onlp/src/sff/module/src/sff_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/any/onlp/src/sff/module/src/sff_config.c b/packages/base/any/onlp/src/sff/module/src/sff_config.c index 400b7a72..cf770933 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_config.c +++ b/packages/base/any/onlp/src/sff/module/src/sff_config.c @@ -70,7 +70,7 @@ sff_config_lookup(const char* setting) { int i; for(i = 0; sff_config_settings[i].name; i++) { - if(strcmp(sff_config_settings[i].name, setting)) { + if(!strcmp(sff_config_settings[i].name, setting)) { return sff_config_settings[i].value; } } From ea2c56af005d924eae72c0c36e57c8ac3c6005f5 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 27 Sep 2017 16:10:48 -0700 Subject: [PATCH 028/244] Wrap the sff module --- .../base/any/onlp/src/sff/module/auto/make.mk | 2 +- .../base/any/onlp/src/sff/module/auto/sff.yml | 2 + .../sff/module/python/onlp/sff/__init__.py | 34 +++++++++ .../src/sff/module/python/onlp/sff/enums.py | 70 +++++++++++++++++++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py create mode 100644 packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py diff --git a/packages/base/any/onlp/src/sff/module/auto/make.mk b/packages/base/any/onlp/src/sff/module/auto/make.mk index 1232f5e6..88b2ad6f 100644 --- a/packages/base/any/onlp/src/sff/module/auto/make.mk +++ b/packages/base/any/onlp/src/sff/module/auto/make.mk @@ -4,6 +4,6 @@ # ############################################################################### sff_AUTO_DEFS := module/auto/sff.yml -sff_AUTO_DIRS := module/inc/sff module/src +sff_AUTO_DIRS := module/inc/sff module/src module/python/onlp/sff include $(BUILDER)/auto.mk diff --git a/packages/base/any/onlp/src/sff/module/auto/sff.yml b/packages/base/any/onlp/src/sff/module/auto/sff.yml index 295fe6bf..1cb31d4d 100644 --- a/packages/base/any/onlp/src/sff/module/auto/sff.yml +++ b/packages/base/any/onlp/src/sff/module/auto/sff.yml @@ -152,6 +152,8 @@ definitions: sff_media_type: members: *sff_media_types + pyenum: *enums + xenum: SFF_ENUMERATION_ENTRY: members: *enums diff --git a/packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py b/packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py new file mode 100644 index 00000000..f6028f01 --- /dev/null +++ b/packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py @@ -0,0 +1,34 @@ +"""__init__.py + +Module init for onlp/sff +""" + +from onlp.sff.enums import * + +import ctypes + +sff_media_type = ctypes.c_int +sff_module_caps = ctypes.c_int +sff_module_type = ctypes.c_int +sff_sfp_type = ctypes.c_int + +class sff_info(ctypes.Structure): + _fields_ = [("vendor", ctypes.c_char * 17), + ("model", ctypes.c_char * 17), + ("serial", ctypes.c_char * 17), + ("sfp_type", sff_sfp_type), + ("sfp_type_name", ctypes.c_char_p), + ("module_type", sff_module_type), + ("module_type_name", ctypes.c_char_p), + ("media_type", sff_media_type), + ("media_type_name", ctypes.c_char_p), + ("caps", sff_module_caps), + ("length", ctypes.c_int), + ("desc", ctypes.c_char * 16),] + +class sff_eeprom(ctypes.Structure): + _fields_ = [("eeprom", ctypes.c_ubyte * 256), + ("cc_base", ctypes.c_ubyte), + ("cc_ext", ctypes.c_ubyte), + ("identified", ctypes.c_int), + ("info", sff_info),] diff --git a/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py b/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py new file mode 100644 index 00000000..5499f7cd --- /dev/null +++ b/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py @@ -0,0 +1,70 @@ +"""enums.py + +Enumerations from the SFF auto.yml. +""" + +class Enumeration(object): + @classmethod + def name(klass, value): + for (k, v) in klass.__dict__.iteritems(): + if v == value: + return k + return None + +# +class SFF_MEDIA_TYPE(Enumeration): + COPPER = 0 + FIBER = 1 + + +class SFF_MODULE_CAPS(Enumeration): + F_100 = 1 + F_1G = 2 + F_10G = 4 + F_25G = 8 + F_40G = 16 + F_100G = 32 + + +class SFF_MODULE_TYPE(Enumeration): + _100G_AOC = 0 + _100G_BASE_CR4 = 1 + _100G_BASE_SR4 = 2 + _100G_BASE_LR4 = 3 + _100G_CWDM4 = 4 + _100G_PSM4 = 5 + _40G_BASE_CR4 = 6 + _40G_BASE_SR4 = 7 + _40G_BASE_LR4 = 8 + _40G_BASE_LM4 = 9 + _40G_BASE_ACTIVE = 10 + _40G_BASE_CR = 11 + _40G_BASE_SR2 = 12 + _40G_BASE_SM4 = 13 + _40G_BASE_ER4 = 14 + _25G_BASE_CR = 15 + _10G_BASE_SR = 16 + _10G_BASE_LR = 17 + _10G_BASE_LRM = 18 + _10G_BASE_ER = 19 + _10G_BASE_CR = 20 + _10G_BASE_SX = 21 + _10G_BASE_LX = 22 + _10G_BASE_ZR = 23 + _10G_BASE_SRL = 24 + _1G_BASE_SX = 25 + _1G_BASE_LX = 26 + _1G_BASE_CX = 27 + _1G_BASE_T = 28 + _100_BASE_LX = 29 + _100_BASE_FX = 30 + _4X_MUX = 31 + + +class SFF_SFP_TYPE(Enumeration): + SFP = 0 + QSFP = 1 + QSFP_PLUS = 2 + QSFP28 = 3 + +# From adbc8cc62aaac78300a571c016b50a4683527214 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 27 Sep 2017 16:14:18 -0700 Subject: [PATCH 029/244] Added Sfp.h and sff.h support - fix references to uint32 - add enough bitmap support to handle SFP bitmaps --- .../onlp/module/python/onlp/onlp/__init__.py | 265 ++++++++++++++++-- 1 file changed, 234 insertions(+), 31 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index d6d628f0..022764e4 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -12,6 +12,7 @@ import ctypes.util libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) import onlp.onlplib +import onlp.sff from onlp.onlp.enums import * @@ -93,7 +94,7 @@ class aim_pvs(ctypes.Structure): ("description", ctypes.c_char_p,), ("vprintf", aim_vprintf_f,), ("enabled", ctypes.c_int,), - ("counter", ctypes.c_uint,), + ("counter", ctypes.c_uint32,), ("isatty", aim_vprintf_f,),] def aim_pvs_init_prototypes(): @@ -112,6 +113,102 @@ def aim_pvs_init_prototypes(): libonlp.aim_pvs_buffer_reset.restype = None libonlp.aim_pvs_buffer_reset.argtypes = (ctypes.POINTER(aim_pvs),) +# AIM/aim_bitmap.h + +aim_bitmap_word = ctypes.c_uint32 +AIM_BITMAP_BITS_PER_WORD = 32 + +def AIM_BITMAP_WORD_COUNT(bitcount): + return ((bitcount // AIM_BITMAP_BITS_PER_WORD) + + (1 if (bitcount % AIM_BITMAP_BITS_PER_WORD) else 0)) + +# ugh, most of aim_bitmap.h is inline C + +def AIM_BITMAP_HDR_WORD_GET(hdr, word): + """Return a specific ctypes word.""" + return hdr.words[word] + +def AIM_BITMAP_HDR_BIT_WORD_GET(hdr, bit): + """Return the ctypes word holding this bit.""" + return hdr.words[bit/AIM_BITMAP_BITS_PER_WORD] + +def AIM_BITMAP_HDR_BIT_WORD_SET(hdr, bit, word): + """Return the ctypes word holding this bit.""" + hdr.words[bit/AIM_BITMAP_BITS_PER_WORD] = word + +def AIM_BITMAP_BIT_POS(bit): + return (1<<(bit % AIM_BITMAP_BITS_PER_WORD)) + +def AIM_BITMAP_INIT(bitmap, count): + """Initialize a static bitmap.""" + libc.memset(ctypes.byref(bitmap), 0, ctypes.sizeof(bitmap)) + bitmap.hdr.maxbit = count + bitmap.hdr.words = ctypes.cast(ctypes.byref(bitmap.words), ctypes.POINTER(ctypes.c_uint)) + bitmap.hdr.wordcount = AIM_BITMAP_WORD_COUNT(count) + +class aim_bitmap_hdr(ctypes.Structure): + _fields_ = [("wordcount", ctypes.c_int,), + ("words", ctypes.POINTER(aim_bitmap_word),), + ("maxbit", ctypes.c_int,), + ("allocated", ctypes.c_int,),] + +class aim_bitmap(ctypes.Structure): + _fields_ = [("hdr", aim_bitmap_hdr,),] + + @classmethod + def fromAim(cls, bitcount): + """Return a pointer to a bitmap from aim_alloc(). + + Pre-initialized; needs to be freed with aim_free(). + """ + return libonlp.aim_bitmap_alloc(None, bitcount) + +class aim_bitmap256(aim_bitmap): + """Statically-allocated AIM bitmap.""" + _fields_ = [("words", aim_bitmap_word * AIM_BITMAP_WORD_COUNT(256),),] + + def __init__(self): + super(aim_bitmap256, self).__init__() + AIM_BITMAP_INIT(self, 255) + +def aim_bitmap_set(hdr, bit): + word = AIM_BITMAP_HDR_BIT_WORD_GET(hdr, bit) + word |= AIM_BITMAP_BIT_POS(bit) + AIM_BITMAP_HDR_BIT_WORD_SET(hdr, bit, word) + +def aim_bitmap_clr(hdr, bit): + word = AIM_BITMAP_HDR_BIT_WORD_GET(hdr, bit) + word &= ~(AIM_BITMAP_BIT_POS(bit)) + AIM_BITMAP_HDR_BIT_WORD_SET(hdr, bit, word) + +def aim_bitmap_mod(hdr, bit, value): + if value: + aim_bitmap_set(hdr, bit) + else: + aim_bitmap_clr(hdr, bit) + +def aim_bitmap_get(hdr, bit): + val = AIM_BITMAP_HDR_BIT_WORD_GET(hdr,bit) & AIM_BITMAP_BIT_POS(bit) + return 1 if val else 0 + +# Huh, these is inline too, but calls into glibc memset + +def aim_bitmap_set_all(hdr): + libc.memset(ctypes.byref(hdr.words), 0xFF, hdr.wordcount*ctypes.sizeof(aim_bitmap_word)) + +def aim_bitmap_clr_all(hdr): + libc.memset(ctypes.byref(hdr.words), 0x00, hdr.wordcount*ctypes.sizeof(aim_bitmap_word)) + +# XXX aim_bitmap_count is left out + +def aim_bitmap_init_prototypes(): + + libonlp.aim_bitmap_alloc.restype = ctypes.POINTER(aim_bitmap) + libonlp.aim_bitmap_alloc.argtypes = (ctypes.POINTER(aim_bitmap), ctypes.c_int,) + + libonlp.aim_bitmap_free.restype = None + libonlp.aim_bitmap_free.argtypes = (ctypes.POINTER(aim_bitmap),) + # onlp.yml ##ONLP_CONFIG_INFO_STR_MAX = int(libonlp.onlp_config_lookup("ONLP_CONFIG_INFO_STR_MAX")) @@ -120,7 +217,7 @@ ONLP_CONFIG_INFO_STR_MAX = 64 # onlp/oids.h -onlp_oid = ctypes.c_uint +onlp_oid = ctypes.c_uint32 ONLP_OID_SYS = (ONLP_OID_TYPE.SYS<<24) | 1 # XXX not a config option @@ -182,16 +279,16 @@ onlp_oid_iterate_f = ctypes.CFUNCTYPE(ctypes.c_int, onlp_oid, ctypes.c_void_p) def onlp_oid_init_prototypes(): libonlp.onlp_oid_dump.restype = None - libonlp.onlp_oid_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_oid_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_oid_table_dump.restype = None - libonlp.onlp_oid_table_dump.argtypes = (ctypes.POINTER(onlp_oid), ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_oid_table_dump.argtypes = (ctypes.POINTER(onlp_oid), ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_oid_show.restype = None - libonlp.onlp_oid_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_oid_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_oid_table_show.restype = None - libonlp.onlp_oid_table_show.argtypes = (ctypes.POINTER(onlp_oid), ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_oid_table_show.argtypes = (ctypes.POINTER(onlp_oid), ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_oid_iterate.restype = ctypes.c_int libonlp.onlp_oid_iterate.argtypes = (onlp_oid, ctypes.c_int, @@ -228,10 +325,10 @@ def onlp_sys_init_prototypes(): libonlp.onlp_sys_hdr_get.argtypes = (ctypes.POINTER(onlp_oid_hdr),) libonlp.onlp_sys_dump.restype = None - libonlp.onlp_sys_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_sys_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_sys_show.restype = None - libonlp.onlp_sys_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_sys_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_sys_ioctl.restype = ctypes.c_int # leave the parameters empty (varargs) @@ -257,11 +354,11 @@ def onlp_sys_init_prototypes(): class onlp_fan_info(ctypes.Structure): _fields_ = [("hdr", onlp_oid_hdr,), - ("status", ctypes.c_uint,), - ("caps", ctypes.c_uint,), + ("status", ctypes.c_uint32,), + ("caps", ctypes.c_uint32,), ("rpm", ctypes.c_int,), ("percentage", ctypes.c_int,), - ("mode", ctypes.c_uint,), + ("mode", ctypes.c_uint32,), ("model", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,), ("serial", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,),] @@ -285,7 +382,7 @@ def onlp_fan_init_prototypes(): libonlp.onlp_fan_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_fan_info),) libonlp.onlp_fan_status_get.restype = ctypes.c_int - libonlp.onlp_fan_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + libonlp.onlp_fan_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint32),) libonlp.onlp_fan_hdr_get.restype = ctypes.c_int libonlp.onlp_fan_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) @@ -297,24 +394,24 @@ def onlp_fan_init_prototypes(): libonlp.onlp_fan_percentage_set.argtypes = (onlp_oid, ctypes.c_int,) libonlp.onlp_fan_mode_set.restype = ctypes.c_int - libonlp.onlp_fan_mode_set.argtypes = (onlp_oid, ctypes.c_uint,) + libonlp.onlp_fan_mode_set.argtypes = (onlp_oid, ctypes.c_uint32,) libonlp.onlp_fan_dir_set.restype = ctypes.c_int - libonlp.onlp_fan_dir_set.argtypes = (onlp_oid, ctypes.c_uint,) + libonlp.onlp_fan_dir_set.argtypes = (onlp_oid, ctypes.c_uint32,) libonlp.onlp_fan_dump.restype = None - libonlp.onlp_fan_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_fan_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_fan_show.restype = None - libonlp.onlp_fan_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_fan_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) # onlp/led.h class onlp_led_info(ctypes.Structure): _fields_ = [("hdr", onlp_oid_hdr,), - ("status", ctypes.c_uint,), - ("caps", ctypes.c_uint,), - ("mode", ctypes.c_uint,), + ("status", ctypes.c_uint32,), + ("caps", ctypes.c_uint32,), + ("mode", ctypes.c_uint32,), ("character", ctypes.c_char,),] def onlp_led_init_prototypes(): @@ -325,7 +422,7 @@ def onlp_led_init_prototypes(): libonlp.onlp_led_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_led_info),) libonlp.onlp_led_status_get.restype = ctypes.c_int - libonlp.onlp_led_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + libonlp.onlp_led_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint32),) libonlp.onlp_led_hdr_get.restype = ctypes.c_int libonlp.onlp_led_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) @@ -334,16 +431,16 @@ def onlp_led_init_prototypes(): libonlp.onlp_led_set.argtypes = (onlp_oid, ctypes.c_int,) libonlp.onlp_led_mode_set.restype = ctypes.c_int - libonlp.onlp_led_mode_set.argtypes = (onlp_oid, ctypes.c_uint,) + libonlp.onlp_led_mode_set.argtypes = (onlp_oid, ctypes.c_uint32,) libonlp.onlp_led_char_set.restype = ctypes.c_int libonlp.onlp_led_char_set.argtypes = (onlp_oid, ctypes.c_char,) libonlp.onlp_led_dump.restype = None - libonlp.onlp_led_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_led_dump.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) libonlp.onlp_led_show.restype = None - libonlp.onlp_led_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint,) + libonlp.onlp_led_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs), ctypes.c_uint32,) # onlp/onlp_config.h @@ -366,8 +463,8 @@ class onlp_thermal_info_thresholds(ctypes.Structure): class onlp_thermal_info(ctypes.Structure): _fields_ = [('hdr', onlp_oid_hdr,), - ('status', ctypes.c_uint,), - ('caps', ctypes.c_uint,), + ('status', ctypes.c_uint32,), + ('caps', ctypes.c_uint32,), ('mcelcius', ctypes.c_int,), ('thresholds', onlp_thermal_info_thresholds,),] @@ -379,7 +476,7 @@ def onlp_thermal_init_prototypes(): libonlp.onlp_thermal_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_thermal_info),) libonlp.onlp_thermal_status_get.restype = ctypes.c_int - libonlp.onlp_thermal_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + libonlp.onlp_thermal_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint32),) libonlp.onlp_thermal_hdr_get.restype = ctypes.c_int libonlp.onlp_thermal_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) @@ -398,8 +495,8 @@ class onlp_psu_info(ctypes.Structure): _fields_ = [("hdr", onlp_oid_hdr,), ("model", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,), ("serial", ctypes.c_char * ONLP_CONFIG_INFO_STR_MAX,), - ("status", ctypes.c_uint,), - ("caps", ctypes.c_uint,), + ("status", ctypes.c_uint32,), + ("caps", ctypes.c_uint32,), ("mvin", ctypes.c_int,), ("mvout", ctypes.c_int,), ("miin", ctypes.c_int,), @@ -415,7 +512,7 @@ def onlp_psu_init_prototypes(): libonlp.onlp_psu_info_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_psu_info),) libonlp.onlp_psu_status_get.restype = ctypes.c_int - libonlp.onlp_psu_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint),) + libonlp.onlp_psu_status_get.argtypes = (onlp_oid, ctypes.POINTER(ctypes.c_uint32),) libonlp.onlp_psu_hdr_get.restype = ctypes.c_int libonlp.onlp_psu_hdr_get.argtypes = (onlp_oid, ctypes.POINTER(onlp_oid_hdr),) @@ -428,11 +525,113 @@ def onlp_psu_init_prototypes(): libonlp.onlp_psu_show.restype = None libonlp.onlp_psu_show.argtypes = (onlp_oid, ctypes.POINTER(aim_pvs),) +# sff/sff.h + +def sff_init_prototypes(): + + libonlp.sff_sfp_type_get.restype = onlp.sff.sff_sfp_type + libonlp.sff_sfp_type_get.argtypes = (ctypes.POINTER(ctypes.c_ubyte),) + + libonlp.sff_module_type_get.restype = onlp.sff.sff_module_type + libonlp.sff_module_type_get.argtypes = (ctypes.POINTER(ctypes.c_ubyte),) + + libonlp.sff_media_type_get.restype = onlp.sff.sff_media_type + libonlp.sff_media_type_get.argtypes = (onlp.sff.sff_module_type,) + + libonlp.sff_module_caps_get.restype = ctypes.c_int + libonlp.sff_module_caps_get.argtypes = (onlp.sff.sff_module_type, ctypes.POINTER(ctypes.c_uint32),) + + libonlp.sff_eeprom_parse.restype = ctypes.c_int + libonlp.sff_eeprom_parse.argtypes = (ctypes.POINTER(onlp.sff.sff_eeprom), ctypes.POINTER(ctypes.c_ubyte),) + + libonlp.sff_eeprom_parse_file.restype = ctypes.c_int + libonlp.sff_eeprom_parse_file.argtypes = (ctypes.POINTER(onlp.sff.sff_eeprom), ctypes.c_char_p,) + + libonlp.sff_eeprom_invalidate.restype = None + libonlp.sff_eeprom_invalidate.argtypes = (ctypes.POINTER(onlp.sff.sff_eeprom),) + + libonlp.sff_eeprom_validate.restype = ctypes.c_int + libonlp.sff_eeprom_validate.argtypes = (ctypes.POINTER(onlp.sff.sff_eeprom), ctypes.c_int,) + + libonlp.sff_info_show.restype = None + libonlp.sff_info_show.argtypes = (ctypes.POINTER(onlp.sff.sff_info), ctypes.POINTER(aim_pvs),) + + libonlp.sff_info_init.restype = ctypes.c_int + libonlp.sff_info_init.argtypes = (ctypes.POINTER(onlp.sff.sff_info), onlp.sff.sff_module_type, + ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, + ctypes.c_int,) + +# onlp/sff.h + +onlp_sfp_bitmap = aim_bitmap256 + +onlp_sfp_control = ctypes.c_int + +def onlp_sfp_init_prototypes(): + + libonlp.onlp_sfp_init.restype = ctypes.c_int + + libonlp.onlp_sfp_bitmap_t_init.restype = None + libonlp.onlp_sfp_bitmap_t_init.argtypes = (ctypes.POINTER(onlp_sfp_bitmap),) + + libonlp.onlp_sfp_bitmap_get.restype = ctypes.c_int + libonlp.onlp_sfp_bitmap_get.argtypes = (ctypes.POINTER(onlp_sfp_bitmap),) + + libonlp.onlp_sfp_port_valid.restype = ctypes.c_int + libonlp.onlp_sfp_port_valid.argtypes = (ctypes.c_int,) + + libonlp.onlp_sfp_is_present.restype = ctypes.c_int + libonlp.onlp_sfp_is_present.argtypes = (ctypes.c_int,) + + libonlp.onlp_sfp_presence_bitmap_get.restype = ctypes.c_int + libonlp.onlp_sfp_presence_bitmap_get.argtypes = (ctypes.POINTER(onlp_sfp_bitmap),) + + libonlp.onlp_sfp_eeprom_read.restype = ctypes.c_int + libonlp.onlp_sfp_eeprom_read.argtypes = (ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ctypes.c_ubyte,)),) + + libonlp.onlp_sfp_dom_read.restype = ctypes.c_int + libonlp.onlp_sfp_dom_read.argtypes = (ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ctypes.c_ubyte)),) + + libonlp.onlp_sfp_denit.restype = ctypes.c_int + + libonlp.onlp_sfp_rx_los_bitmap_get.restype = ctypes.c_int + libonlp.onlp_sfp_rx_los_bitmap_get.argtypes = (ctypes.POINTER(onlp_sfp_bitmap),) + + libonlp.onlp_sfp_dev_readb.restype = ctypes.c_int + libonlp.onlp_sfp_dev_readb.argtypes = (ctypes.c_int, ctypes.c_ubyte, ctypes.c_ubyte,) + + libonlp.onlp_sfp_dev_writeb.restype = ctypes.c_int + libonlp.onlp_sfp_dev_writeb.argtypes = (ctypes.c_int, ctypes.c_ubyte, ctypes.c_ubyte, ctypes.c_ubyte) + + libonlp.onlp_sfp_dev_readw.restype = ctypes.c_int + libonlp.onlp_sfp_dev_readw.argtypes = (ctypes.c_int, ctypes.c_ubyte, ctypes.c_ubyte,) + + libonlp.onlp_sfp_dev_writew.restype = ctypes.c_int + libonlp.onlp_sfp_dev_writew.argtypes = (ctypes.c_int, ctypes.c_ubyte, ctypes.c_ubyte, ctypes.c_ushort) + + libonlp.onlp_sfp_dump.restype = None + libonlp.onlp_sfp_dump.argtypes = (ctypes.POINTER(aim_pvs),) + + libonlp.onlp_sfp_ioctl.restype = ctypes.c_int + + libonlp.onlp_sfp_post_insert.restype = ctypes.c_int + libonlp.onlp_sfp_post_insert.argtypes = (ctypes.c_int, ctypes.POINTER(onlp.sff.sff_info),) + + libonlp.onlp_sfp_control_set.restype = ctypes.c_int + libonlp.onlp_sfp_control_set.argtypes = (ctypes.c_int, onlp_sfp_control, ctypes.c_int,) + + libonlp.onlp_sfp_control_get.restype = ctypes.c_int + libonlp.onlp_sfp_control_get.argtypes = (ctypes.c_int, onlp_sfp_control, ctypes.POINTER(ctypes.c_int)) + + libonlp.onlp_sfp_control_flags_get.restype = ctypes.c_int + libonlp.onlp_sfp_control_flags_get.argtyeps = (ctypes.c_int, ctypes.POINTER(ctypes.c_uint32),) + # onlp/onlp.h def init_prototypes(): aim_memory_init_prototypes() aim_pvs_init_prototypes() + aim_bitmap_init_prototypes() onlp_oid_init_prototypes() onlp_sys_init_prototypes() onlp_fan_init_prototypes() @@ -440,10 +639,14 @@ def init_prototypes(): onlp_config_init_prototypes() - if ONLP_CONFIG_INFO_STR_MAX != int(libonlp.onlp_config_lookup("ONLP_CONFIG_INFO_STR_MAX")): - raise AssertionError("ONLP_CONFIG_INFO_STR_MAX changed") + strMax = int(libonlp.onlp_config_lookup("ONLP_CONFIG_INFO_STR_MAX")) + if ONLP_CONFIG_INFO_STR_MAX != strMax: + raise AssertionError("ONLP_CONFIG_INFO_STR_MAX changed from %d to %d" + % (ONLP_CONFIG_INFO_STR_MAX, strMax,)) onlp_thermal_init_prototypes() onlp_psu_init_prototypes() + sff_init_prototypes() + onlp_sfp_init_prototypes() init_prototypes() From ee9062a361e4089de6a20cc78a4a0e744255821e Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 27 Sep 2017 16:14:33 -0700 Subject: [PATCH 030/244] Wrap the sff module --- packages/base/any/onlp/APKG.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml index 7ab08aa3..4597e63d 100644 --- a/packages/base/any/onlp/APKG.yml +++ b/packages/base/any/onlp/APKG.yml @@ -31,6 +31,7 @@ packages: ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/onlp: ${PY_INSTALL}/onlp/onlp ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/test: ${PY_INSTALL}/onlp/test ${ONL}/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib: ${PY_INSTALL}/onlp/onlplib + ${ONL}/packages/base/any/onlp/src/sff/module/python/onlp/sff: ${PY_INSTALL}/onlp/sff init: $ONL/packages/base/any/onlp/src/onlpd.init From 0f659905a78743910fda6e461976d741a9de207a Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 27 Sep 2017 16:14:55 -0700 Subject: [PATCH 031/244] Test sfp.h and sff.h --- .../module/python/onlp/test/OnlpApiTest.py | 315 ++++++++++++++++++ 1 file changed, 315 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index 2121474c..57fd82a8 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -9,8 +9,12 @@ import logging import re import time import subprocess +import random +import tempfile +import os import onlp.onlp +import onlp.sff libonlp = onlp.onlp.libonlp @@ -1211,6 +1215,317 @@ class PsuTest(OnlpTestMixin, bufStr = buf.string_at() self.assertIn("psu @", bufStr) +class Eeprom(ctypes.Structure): + _fields_ = [('eeprom', ctypes.c_ubyte * 256,),] + +class SfpTest(OnlpTestMixin, + unittest.TestCase): + """Test interfaces in onlp/psu.h.""" + + def setUp(self): + OnlpTestMixin.setUp(self) + + libonlp.onlp_sfp_init() + + self.bitmap = onlp.onlp.aim_bitmap256() + + def tearDown(self): + OnlpTestMixin.tearDown(self) + + libonlp.onlp_sfp_denit() + + def bitmap2list(self, bitmap=None): + outBits = [] + bitmap = bitmap or self.bitmap + for pos in range(256): + outBits.append(onlp.onlp.aim_bitmap_get(bitmap.hdr, pos)) + return outBits + + def testBitmap(self): + """Verify that our aim_bitmap implementation is sound.""" + + refBits = [] + for pos in range(256): + val = random.randint(0, 1) + refBits.append(val) + onlp.onlp.aim_bitmap_mod(self.bitmap.hdr, pos, val) + + for i in range(1000): + pos = random.randint(0, 255) + val = refBits[pos] ^ 1 + refBits[pos] = val + onlp.onlp.aim_bitmap_mod(self.bitmap.hdr, pos, val) + + self.assertEqual(refBits, self.bitmap2list()) + + refBits = [0] * 256 + libonlp.onlp_sfp_bitmap_t_init(ctypes.byref(self.bitmap)) + self.assertEqual(refBits, self.bitmap2list()) + + def testValid(self): + """Test for valid SFP ports.""" + + libonlp.onlp_sfp_bitmap_t_init(ctypes.byref(self.bitmap)) + sts = libonlp.onlp_sfp_bitmap_get(ctypes.byref(self.bitmap)) + self.assertStatusOK(sts) + refBits = [0] * 256 + + ports = [x[0] for x in enumerate(self.bitmap2list()) if x[1]] + self.log.info("found %d SFP ports", len(ports)) + self.assert_(ports) + + self.assertEqual(0, ports[0]) + self.assertEqual(len(ports)-1, ports[-1]) + # make sure the ports are contiguous, starting from 1 + + # make sure the per-port valid bits are correct + for i in range(256): + valid = libonlp.onlp_sfp_port_valid(i) + if i < len(ports): + self.assertEqual(1, valid) + else: + self.assertEqual(0, valid) + + # see if any of them are present + # XXX this test requires at least one of the SFPs to be present. + bm = onlp.onlp.aim_bitmap256() + sts = libonlp.onlp_sfp_presence_bitmap_get(ctypes.byref(bm)) + self.assertStatusOK(sts) + present = [x[0] for x in enumerate(self.bitmap2list(bm)) if x[1]] + self.log.info("found %d SFPs", len(present)) + self.assert_(present) + + presentSet = set(present) + portSet = set(ports) + + for port in presentSet: + if port not in portSet: + raise AssertionError("invalid SFP %d not valid" + % (port,)) + + for i in range(256): + valid = libonlp.onlp_sfp_is_present(i) + if i in presentSet: + self.assertEqual(1, valid) + elif i in portSet: + self.assertEqual(0, valid) + else: + self.assertGreater(0, valid) + + # test the rx_los bitmap + # (tough to be more detailed since it depends on connectivity) + sts = libonlp.onlp_sfp_rx_los_bitmap_get(ctypes.byref(bm)) + if sts != onlp.onlp.ONLP_STATUS.E_UNSUPPORTED: + self.assertStatusOK(sts) + rxLos = [x[0] for x in enumerate(self.bitmap2list(bm)) if x[1]] + + # any port exhibiting rx_los should actually be a port + for i in rxLos: + self.assertIn(i, portSet) + + # any missing SFP should *NOT* be exhibiting rx_los + rxLosSet = set(rxLos) + for i in portSet: + if not i in presentSet: + self.assertNotIn(i, rxLosSet) + + port = ports[0] + + self.auditIoctl(port) + self.auditControl(port) + + eeprom = ctypes.POINTER(ctypes.c_ubyte)() + sts = libonlp.onlp_sfp_eeprom_read(port, ctypes.byref(eeprom)) + self.assertStatusOK(sts) + + try: + + # try to read in the data manually + for i in range(128): + b = libonlp.onlp_sfp_dev_readb(port, 0x50, i) + if b != eeprom[i]: + raise AssertionError("eeprom mismatch at 0x50.%d" % i) + + monType = eeprom[92] & 0x40 + # See e.g. https://www.optcore.net/wp-content/uploads/2017/04/SFF_8472.pdf + + self.auditEeprom(eeprom) + + finally: + ptr = onlp.onlp.aim_void_p(ctypes.cast(eeprom, ctypes.c_void_p).value) + del ptr + + if monType: + + domData = ctypes.POINTER(ctypes.c_ubyte)() + sts = libonlp.onlp_sfp_dom_read(port, ctypes.byref(domData)) + self.assertStatusOK(sts) + + try: + self.auditDom(domData) + finally: + ptr = onlp.onlp.aim_void_p(ctypes.cast(domData, ctypes.c_void_p).value) + del ptr + + def auditEeprom(self, eeprom): + """Audit that the entries for this SFP are valid.""" + + sffEeprom = onlp.sff.sff_eeprom() + sts = libonlp.sff_eeprom_parse(ctypes.byref(sffEeprom), eeprom) + self.assertStatusOK(sts) + + self.assertEqual(1, sffEeprom.identified) + + # XXX info strings include space padding + vendor = sffEeprom.info.vendor.strip() + self.assert_(vendor) + model = sffEeprom.info.model.strip() + self.assert_(model) + serial = sffEeprom.info.serial.strip() + self.assert_(serial) + + self.log.info("found SFP: %s %s (S/N %s)", + vendor, model, serial) + + self.log.info("%s (%s %s)", + sffEeprom.info.module_type_name, + sffEeprom.info.media_type_name, + sffEeprom.info.sfp_type_name) + + sffType = libonlp.sff_sfp_type_get(eeprom) + self.assertEqual(sffType, sffEeprom.info.sfp_type) + + moduleType = libonlp.sff_module_type_get(eeprom) + self.assertEqual(moduleType, sffEeprom.info.module_type) + + mediaType = libonlp.sff_media_type_get(sffEeprom.info.module_type) + self.assertEqual(mediaType, sffEeprom.info.media_type) + + caps = ctypes.c_uint32() + sts = libonlp.sff_module_caps_get(sffEeprom.info.module_type, ctypes.byref(caps)) + self.assertStatusOK(sts) + self.assert_(caps) + cl = [] + for i in range(32): + fl = 1< Date: Wed, 27 Sep 2017 17:02:00 -0700 Subject: [PATCH 032/244] typos --- .../any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index 57fd82a8..121ae40d 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -1220,7 +1220,7 @@ class Eeprom(ctypes.Structure): class SfpTest(OnlpTestMixin, unittest.TestCase): - """Test interfaces in onlp/psu.h.""" + """Test interfaces in onlp/sfp.h.""" def setUp(self): OnlpTestMixin.setUp(self) @@ -1460,7 +1460,7 @@ class SfpTest(OnlpTestMixin, self.assertEqual(sts, 0) def auditDom(self, domData): - unittest.skipn("not implemented") + unittest.skip("not implemented") def testDump(self): unittest.skip("this is a really slow command") From b1757efe70bd15d8462a55102c690a0b293a3f8e Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Wed, 23 Aug 2017 14:41:14 +0800 Subject: [PATCH 033/244] [Quanta-LY6,LY8,LY9,IX1,IX2] Update ONLP: 1. Export GPIO of fan direction --- .../builds/src/x86_64_quanta_ix1_rangeley/module/src/sysi.c | 5 +++++ .../builds/src/x86_64_quanta_ix2_rangeley/module/src/sysi.c | 5 +++++ .../builds/src/x86_64_quanta_ly6_rangeley/module/src/sysi.c | 4 ++++ .../builds/src/x86_64_quanta_ly8_rangeley/module/src/sysi.c | 4 ++++ .../builds/src/x86_64_quanta_ly9_rangeley/module/src/sysi.c | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sysi.c index ad7b5469..34c79129 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sysi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/sysi.c @@ -79,6 +79,11 @@ onlp_sysi_init(void) onlp_gpio_export(QUANTA_IX1_FAN_PRSNT_N_2, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_IX1_FAN_PRSNT_N_3, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_IX1_FAN_PRSNT_N_4, ONLP_GPIO_DIRECTION_IN); + /* FAN Direction */ + onlp_gpio_export(QUANTA_IX1_FAN_BF_DET1, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1_FAN_BF_DET2, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1_FAN_BF_DET3, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX1_FAN_BF_DET4, ONLP_GPIO_DIRECTION_IN); /* Set LED to green */ onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/sysi.c index 3455aad3..36195e35 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/sysi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/sysi.c @@ -79,6 +79,11 @@ onlp_sysi_init(void) onlp_gpio_export(QUANTA_IX2_FAN_PRSNT_N_2, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_IX2_FAN_PRSNT_N_3, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_IX2_FAN_PRSNT_N_4, ONLP_GPIO_DIRECTION_IN); + /* FAN Direction */ + onlp_gpio_export(QUANTA_IX2_FAN_BF_DET1, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX2_FAN_BF_DET2, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX2_FAN_BF_DET3, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_IX2_FAN_BF_DET4, ONLP_GPIO_DIRECTION_IN); /* Set LED to green */ onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/sysi.c index b181aa30..ca308623 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/sysi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/sysi.c @@ -74,6 +74,10 @@ onlp_sysi_init(void) onlp_gpio_export(QUANTA_LY6_FAN_PRSNT_N_1, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_LY6_FAN_PRSNT_N_2, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_LY6_FAN_PRSNT_N_3, ONLP_GPIO_DIRECTION_IN); + /* FAN Direction */ + onlp_gpio_export(QUANTA_LY6_FAN_BF_DET1, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_LY6_FAN_BF_DET2, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_LY6_FAN_BF_DET3, ONLP_GPIO_DIRECTION_IN); /* Set LED to green */ onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sysi.c index cf39ba5b..5a57b17a 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sysi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sysi.c @@ -74,6 +74,10 @@ onlp_sysi_init(void) onlp_gpio_export(QUANTA_LY8_FAN_PRSNT_N_1, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_LY8_FAN_PRSNT_N_2, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_LY8_FAN_PRSNT_N_3, ONLP_GPIO_DIRECTION_IN); + /* FAN Direction */ + onlp_gpio_export(QUANTA_LY8_FAN_BF_DET1, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_LY8_FAN_BF_DET2, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_LY8_FAN_BF_DET3, ONLP_GPIO_DIRECTION_IN); /* Set LED to green */ onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/sysi.c index a6902ee9..60624a02 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/sysi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/sysi.c @@ -74,6 +74,10 @@ onlp_sysi_init(void) onlp_gpio_export(QUANTA_LY9_FAN_PRSNT_N_1, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_LY9_FAN_PRSNT_N_2, ONLP_GPIO_DIRECTION_IN); onlp_gpio_export(QUANTA_LY9_FAN_PRSNT_N_3, ONLP_GPIO_DIRECTION_IN); + /* FAN Direction */ + onlp_gpio_export(QUANTA_LY9_FAN_BF_DET1, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_LY9_FAN_BF_DET2, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(QUANTA_LY9_FAN_BF_DET3, ONLP_GPIO_DIRECTION_IN); /* Set LED to green */ onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); From ca66e4ee0e1f87b526dd5beb70a546d5bf874cb2 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Mon, 2 Oct 2017 14:27:48 +0800 Subject: [PATCH 034/244] [as7716-32x] Fix fan control rountine not working issue --- .../x86-64-accton-as7716-32x/onlp/builds/src/module/src/fani.c | 2 +- .../x86-64-accton-as7716-32x/onlp/builds/src/module/src/sysi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/fani.c index 58e436b5..0e8bfcda 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/fani.c @@ -59,7 +59,7 @@ typedef struct fan_path_S #define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ { #prj"fan"#id"_present", #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \ - #prj"fan"#id"_direction", #prj"fan"#id"_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" } + #prj"fan"#id"_direction", #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) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sysi.c index 21157648..32aa1030 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sysi.c @@ -170,7 +170,7 @@ onlp_sysi_platform_manage_fans(void) /* Decision 1: Set fan as full speed if any fan is failed. */ - if (fan_info.status & ONLP_FAN_STATUS_FAILED) { + if (fan_info.status & ONLP_FAN_STATUS_FAILED || !(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i); return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); } From e1baa8133c4def90f2098e6638f0fba16081b6d4 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 4 Oct 2017 21:49:05 +0000 Subject: [PATCH 035/244] The AS7312 should report as 48x25+6x100. --- .../r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py index f34210bb..2342af5f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py @@ -2,7 +2,7 @@ from onl.platform.base import * from onl.platform.accton import * class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, - OnlPlatformPortConfig_48x10_6x40): + OnlPlatformPortConfig_48x25_6x100): PLATFORM='x86-64-accton-as7312-54x-r0' MODEL="AS7312-54X" @@ -48,7 +48,7 @@ class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, ('ym2651', 0x58, 10), ]) - + ########### initialize I2C bus 1 ########### @@ -127,5 +127,3 @@ class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, ) self.new_i2c_device('24c02', 0x57, 1) return True - - From 2cc3cf66d69b774d9e2082aee92cccfaaa19156a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 5 Oct 2017 00:41:18 +0000 Subject: [PATCH 036/244] Add CPLD versions to sysfs. --- .../builds/x86-64-accton-as7312-54x-cpld.c | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c index 4794b54d..576d84e8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c @@ -60,14 +60,14 @@ static const unsigned short normal_i2c[] = { 0x31, 0x35, 0x60, 0x62, 0x64, I2C_C static void accton_i2c_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - + if (!node) { dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); return; } - + node->client = client; - + mutex_lock(&list_lock); list_add(&node->list, &cpld_client_list); mutex_unlock(&list_lock); @@ -78,27 +78,41 @@ static void accton_i2c_cpld_remove_client(struct i2c_client *client) struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; int found = 0; - + mutex_lock(&list_lock); list_for_each(list_node, &cpld_client_list) { cpld_node = list_entry(list_node, struct cpld_client_node, list); - + if (cpld_node->client == client) { found = 1; break; } } - + if (found) { list_del(list_node); kfree(cpld_node); } - + mutex_unlock(&list_lock); } +static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + u8 reg = 0x1; + struct i2c_client *client; + int len; + + client = to_i2c_client(dev); + len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); + + return len; +} + +static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); + static int accton_i2c_cpld_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { @@ -112,7 +126,8 @@ static int accton_i2c_cpld_probe(struct i2c_client *client, dev_info(&client->dev, "chip found\n"); accton_i2c_cpld_add_client(client); - + + sysfs_create_file(&client->dev.kobj, &ver.attr); return 0; exit: @@ -121,9 +136,10 @@ exit: static int accton_i2c_cpld_remove(struct i2c_client *client) { - accton_i2c_cpld_remove_client(client); - - return 0; + sysfs_remove_file(&client->dev.kobj, &ver.attr); + accton_i2c_cpld_remove_client(client); + + return 0; } static const struct i2c_device_id accton_i2c_cpld_id[] = { @@ -148,7 +164,7 @@ int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; int ret = -EPERM; - + mutex_lock(&list_lock); list_for_each(list_node, &cpld_client_list) @@ -160,7 +176,7 @@ int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) break; } } - + mutex_unlock(&list_lock); return ret; @@ -172,19 +188,19 @@ int as7312_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; int ret = -EIO; - + mutex_lock(&list_lock); list_for_each(list_node, &cpld_client_list) { cpld_node = list_entry(list_node, struct cpld_client_node, list); - + if (cpld_node->client->addr == cpld_addr) { ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); break; } } - + mutex_unlock(&list_lock); return ret; From 3b931532683d3993d3d69e4d166dbeeb1d0c4551 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 6 Oct 2017 14:34:46 +0000 Subject: [PATCH 037/244] Additional file utilities. --- .../src/onlplib/module/inc/onlplib/file.h | 51 ++++++++++ .../any/onlp/src/onlplib/module/src/file.c | 94 +++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/packages/base/any/onlp/src/onlplib/module/inc/onlplib/file.h b/packages/base/any/onlp/src/onlplib/module/inc/onlplib/file.h index 250047c3..33096eaf 100644 --- a/packages/base/any/onlp/src/onlplib/module/inc/onlplib/file.h +++ b/packages/base/any/onlp/src/onlplib/module/inc/onlplib/file.h @@ -27,6 +27,20 @@ #include +/** + * @brief Read the size of the given file. + * @param fmt Filename format string. + * @param vargs Filename format arguments. + */ +int onlp_file_vsize(const char* fmt, va_list vargs); + +/** + * @brief Read the size of the given file. + * @param fmt Filename format string. + * @param ... Filename format arguments. + */ +int onlp_file_size(const char* fmt, ...); + /** * @brief Read and return the contents of the given file. * @param data Receives the data. @@ -47,6 +61,43 @@ int onlp_file_vread(uint8_t* data, int max, int* len, const char* fmt, va_list v */ int onlp_file_read(uint8_t* data, int max, int* len, const char* fmt, ...); + +/** + * @brief Read and return the contents of the given file. + * @param[out] data Receives the contents. + * @param fmt The filename format string. + * @param vargs The filename format args. + */ +int onlp_file_vread_all(uint8_t** data, const char* fmt, va_list vargs); + +/** + * @brief Read and return the contents of the given file. + * @param[out] data Receives the contents. + * @param fmt The filename format string. + * @param ... The filename format args. + */ +int onlp_file_read_all(uint8_t** data, const char* fmt, ...); + +/** + * @brief Read and return the contents of the given file. + * @param[out] rv Receives the contents. + * @param fmt The filename format string. + * @param vargs The filename format args. + * @note The contents of the file are assumed to be a string. + * Trailing newlines are removed. + */ +int onlp_file_vread_str(char** str, const char* fmt, va_list vargs); + +/** + * @brief Read and return the contents of the given file. + * @param[out] rv Receives the contents. + * @param fmt The filename format string. + * @param ... The filename format args. + * @note The contents of the file are assumed to be a string. + * Trailing newlines are removed. + */ +int onlp_file_read_str(char** str, const char* fmt, ...); + /** * @brief Read and return the integer contents of the given file. * @param value Receives the integer value. diff --git a/packages/base/any/onlp/src/onlplib/module/src/file.c b/packages/base/any/onlp/src/onlplib/module/src/file.c index a1abd74d..ef31b840 100644 --- a/packages/base/any/onlp/src/onlplib/module/src/file.c +++ b/packages/base/any/onlp/src/onlplib/module/src/file.c @@ -112,6 +112,34 @@ vopen__(char** dst, int flags, const char* fmt, va_list vargs) return (fd > 0) ? fd : ONLP_STATUS_E_MISSING; } +int +onlp_file_vsize(const char* fmt, va_list vargs) +{ + int rv; + struct stat sb; + + char* fname = aim_vfstrdup(fmt, vargs); + if(stat(fname, &sb) != -1) { + rv = sb.st_size; + } + else { + rv = ONLP_STATUS_E_MISSING; + } + aim_free(fname); + return rv; +} + +int +onlp_file_size(const char* fmt, ...) +{ + int rv; + va_list vargs; + va_start(vargs, fmt); + rv = onlp_file_vsize(fmt, vargs); + va_end(vargs); + return rv; +} + int onlp_file_vread(uint8_t* data, int max, int* len, const char* fmt, va_list vargs) @@ -149,6 +177,72 @@ onlp_file_read(uint8_t* data, int max, int* len, const char* fmt, ...) return rv; } +int +onlp_file_vread_all(uint8_t** data, const char* fmt, va_list vargs) +{ + int rv; + uint8_t* contents = NULL; + char * fname = NULL; + int fsize, rsize; + + if(data == NULL || fmt == NULL) { + return ONLP_STATUS_E_PARAM; + } + + fname = aim_vdfstrdup(fmt, vargs); + + *data = NULL; + + if((fsize = onlp_file_size(fname)) > 0) { + contents = aim_zmalloc(fsize); + if((rv = onlp_file_read(contents, fsize, &rsize, fname)) >= 0) { + *data = contents; + rv = rsize; + } + } + else { + rv = fsize; + } + aim_free(fname); + return rv; +} + +int +onlp_file_read_all(uint8_t** data, const char* fmt, ...) +{ + int rv; + va_list vargs; + va_start(vargs, fmt); + rv = onlp_file_vread_all(data, fmt, vargs); + va_end(vargs); + return rv; +} + +int +onlp_file_vread_str(char** str, const char* fmt, va_list vargs) +{ + int rv = onlp_file_vread_all((uint8_t**)str, fmt, vargs); + if(rv > 0) { + while(rv && ( (*str)[rv-1] == '\n' || (*str)[rv-1] == '\r')) { + (*str)[rv-1] = 0; + rv--; + } + } + return rv; + +} + +int +onlp_file_read_str(char** str, const char* fmt, ...) +{ + int rv; + va_list vargs; + va_start(vargs, fmt); + rv = onlp_file_vread_str(str, fmt, vargs); + va_end(vargs); + return rv; +} + int onlp_file_vread_int(int* value, const char* fmt, va_list vargs) { From de66432e199cb2128396dc7b0e5df4348f37e202 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 9 Oct 2017 13:01:14 -0700 Subject: [PATCH 038/244] Initial attempt to clean up memory managment with weakref --- .../onlp/module/python/onlp/onlp/__init__.py | 9 +- .../module/python/onlp/onlp/aim_weakref.py | 82 +++++++++ .../module/python/onlp/test/OnlpApiTest.py | 164 ++++++++++-------- 3 files changed, 177 insertions(+), 78 deletions(-) create mode 100644 packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index 022764e4..9c58179e 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -13,16 +13,23 @@ libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) import onlp.onlplib import onlp.sff +from onlp.onlp import aim_weakref from onlp.onlp.enums import * # AIM/aim_memory.h -class aim_void_p(ctypes.c_void_p): +class _aim_void_p(ctypes.c_void_p): """Generic data allocated by AIM.""" def __del__(self): libonlp.aim_free(self) +class aim_void_p(aim_weakref.AimPointer): + + @classmethod + def deletePointer(cls, aimPtr): + libonlp.aim_free(aimPtr) + class aim_char_p(aim_void_p): """AIM data that is a printable string.""" diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py new file mode 100644 index 00000000..5c6e7246 --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py @@ -0,0 +1,82 @@ +"""aim_weakref.py + +Use weakref to implement smart AIM pointers. + +See e.g. +http://code.activestate.com/recipes/577242-calling-c-level-finalizers-without-__del__/ +""" + +import ctypes +import logging +import weakref + +logger = logging.getLogger("weakref") + +def getLogger(): + global logger + return logger + +class AimOwnerRef(weakref.ref): + pass + +def _run_finalizer(ref): + """Internal weakref callback to run finalizers""" + del _finalize_refs[id(ref)] + finalizer = ref.finalizer + item = ref.item + try: + getLogger().info("finalizing object at %s", item) + finalizer(item) + except Exception: + getLogger().exception("finalizer failed") + +_finalize_refs = {} + +def track_for_finalization(owner, item, finalizer): + """Register an object for finalization. + + ``owner`` is the the object which is responsible for ``item``. + ``finalizer`` will be called with ``item`` as its only argument when + ``owner`` is destroyed by the garbage collector. + """ + getLogger().info("tracking object at %s", item) + ref = AimOwnerRef(owner, _run_finalizer) + ref.item = item + ref.finalizer = finalizer + _finalize_refs[id(ref)] = ref + +class AimReference(object): + """Manage an AIM pointer using reference semantics.""" + + @classmethod + def deleteReference(cls, aimPtr): + """Override this with the proper delete semantics.""" + raise NotImplementedError + + def __init__(self, aimPtr): + self.ptr = aimPtr + track_for_finalization(self, self.ptr, self.deleteReference) + + def __getattr__(self, attr, dfl='__none__'): + if dfl == '__none__': + return getattr(self.ptr.contents, attr) + else: + return getattr(self.ptr.contents, attr, dfl) + + def __setattr___(self, attr, val): + setattr(self.ptr.contents, attr, val) + +class AimPointer(ctypes.c_void_p): + """Manage an AIM pointer using pointer semantics.""" + + @classmethod + def deletePointer(cls, aimPtr): + """Override this with the proper delete semantics.""" + raise NotImplementedError + + def __init__(self, aimPtr): + + super(ctypes.c_void_p, self).__init__(aimPtr) + # XXX roth -- casting may be necessary + + track_for_finalization(self, aimPtr, self.deletePointer) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py index 121ae40d..3ff776c0 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/test/OnlpApiTest.py @@ -18,6 +18,8 @@ import onlp.sff libonlp = onlp.onlp.libonlp +import onlp.onlp.aim_weakref + def isVirtual(): with open("/etc/onl/platform") as fd: buf = fd.read() @@ -26,6 +28,20 @@ def isVirtual(): def skipIfVirtual(reason="this test only works with a physical device"): return unittest.skipIf(isVirtual(), reason) +class aim_pvs_buffer(onlp.onlp.aim_weakref.AimReference): + + def __init__(self): + ptr = libonlp.aim_pvs_buffer_create() + super(aim_pvs_buffer, self).__init__(ptr) + + @classmethod + def deleteReference(self, ptr): + libonlp.aim_pvs_destroy(ptr) + + def string_at(self): + buf = libonlp.aim_pvs_buffer_get(self.ptr) + return buf.string_at() + class OnlpTestMixin(object): def setUp(self): @@ -33,12 +49,12 @@ class OnlpTestMixin(object): self.log = logging.getLogger("onlp") self.log.setLevel(logging.DEBUG) - self.aim_pvs_buffer_p = libonlp.aim_pvs_buffer_create() - self.aim_pvs_buffer = self.aim_pvs_buffer_p.contents + self.aim_pvs_buffer = aim_pvs_buffer() + + onlp.onlp.aim_weakref.logger = self.log.getChild("weakref") def tearDown(self): - - libonlp.aim_pvs_destroy(self.aim_pvs_buffer_p) + pass def assertStatusOK(self, sts): if sts == onlp.onlp.ONLP_STATUS.OK: @@ -61,25 +77,19 @@ class InitTest(OnlpTestMixin, def testBuffer(self): """Verify that the AIM buffer type is usable.""" - nullString = onlp.onlp.aim_char_p(None) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) - self.assertEqual(nullString, buf) + self.assertIsNone(self.aim_pvs_buffer.string_at()) - libonlp.aim_printf(self.aim_pvs_buffer_p, "hello\n") - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) - self.assertEqual("hello\n", buf.string_at()) + libonlp.aim_printf(self.aim_pvs_buffer.ptr, "hello\n") + self.assertEqual("hello\n", self.aim_pvs_buffer.string_at()) - libonlp.aim_printf(self.aim_pvs_buffer_p, "world\n") - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) - self.assertEqual("hello\nworld\n", buf.string_at()) + libonlp.aim_printf(self.aim_pvs_buffer.ptr, "world\n") + self.assertEqual("hello\nworld\n", self.aim_pvs_buffer.string_at()) - libonlp.aim_printf(self.aim_pvs_buffer_p, "%d\n", 42) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) - self.assertEqual("hello\nworld\n42\n", buf.string_at()) + libonlp.aim_printf(self.aim_pvs_buffer.ptr, "%d\n", 42) + self.assertEqual("hello\nworld\n42\n", self.aim_pvs_buffer.string_at()) - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) - self.assertEqual(nullString, buf) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) + self.assertIsNone(self.aim_pvs_buffer.string_at()) class OnlpTest(OnlpTestMixin, unittest.TestCase): @@ -95,8 +105,8 @@ class OnlpTest(OnlpTestMixin, """Verify basic platform dump output.""" flags = 0 - libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_platform_dump(self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("System Information:", bufStr) self.assertIn("thermal @ 1", bufStr) @@ -105,17 +115,17 @@ class OnlpTest(OnlpTestMixin, """Verify platform dump flags are honored.""" flags = 0 - libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_platform_dump(self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("psu @ 1", bufStr) self.assertNotIn("PSU-1 Fan", bufStr) - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) flags = onlp.onlp.ONLP_OID_DUMP.RECURSE - libonlp.onlp_platform_dump(self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_platform_dump(self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("psu @ 1", bufStr) self.assertIn("PSU-1 Fan", bufStr) @@ -127,8 +137,8 @@ class OnlpTest(OnlpTestMixin, """Verify basic platform show output.""" flags = 0 - libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_platform_show(self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("System Information:", bufStr) @@ -136,17 +146,17 @@ class OnlpTest(OnlpTestMixin, """Verify that onlp_platform_show honors flags.""" flags = 0 - libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_platform_show(self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertNotIn("PSU 1", bufStr) self.assertNotIn("PSU-1 Fan", bufStr) - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) flags = onlp.onlp.ONLP_OID_SHOW.RECURSE - libonlp.onlp_platform_show(self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_platform_show(self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("PSU 1", bufStr) self.assertIn("PSU-1 Fan", bufStr) @@ -288,18 +298,18 @@ class SysTest(OnlpTestMixin, oid = onlp.onlp.ONLP_OID_SYS flags = 0 - libonlp.onlp_sys_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_sys_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("System Information", bufStr) - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) # this is not the system OID oid = self.sys_info.hdr.coids[0] - libonlp.onlp_sys_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_sys_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIsNone(bufStr) @@ -308,18 +318,18 @@ class SysTest(OnlpTestMixin, oid = onlp.onlp.ONLP_OID_SYS flags = 0 - libonlp.onlp_sys_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_sys_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("System Information", bufStr) - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) # this is not the system OID oid = self.sys_info.hdr.coids[0] - libonlp.onlp_sys_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_sys_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIsNone(bufStr) @@ -431,15 +441,15 @@ class OidTest(OnlpTestMixin, def testOidDump(self): oid = self.hdr.coids[0] flags = 0 - libonlp.onlp_oid_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_oid_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) self.assertIn("Description:", buf.string_at()) def testOidTableDump(self): tbl = self.hdr.coids flags = 0 - libonlp.onlp_oid_table_dump(tbl, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_oid_table_dump(tbl, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) lines = buf.string_at().splitlines(False) lines = [x for x in lines if 'Description' in x] self.assertGreater(len(lines), 1) @@ -447,15 +457,15 @@ class OidTest(OnlpTestMixin, def testOidShow(self): oid = self.hdr.coids[0] flags = 0 - libonlp.onlp_oid_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_oid_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) self.assertIn("Description:", buf.string_at()) def testOidTableShow(self): tbl = self.hdr.coids flags = 0 - libonlp.onlp_oid_table_show(tbl, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_oid_table_show(tbl, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) lines = buf.string_at().splitlines(False) lines = [x for x in lines if 'Description' in x] self.assertGreater(len(lines), 1) @@ -544,13 +554,13 @@ class FanTest(OnlpTestMixin, self.auditFanDir(oid) flags = 0 - libonlp.onlp_fan_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_fan_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("Fan", bufStr) - libonlp.onlp_fan_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_fan_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("Fan", bufStr) @@ -814,13 +824,13 @@ class LedTest(OnlpTestMixin, flags = 0 - libonlp.onlp_led_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_led_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("led @", bufStr) - libonlp.onlp_led_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_led_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("led @", bufStr) @@ -1038,8 +1048,8 @@ class ConfigTest(OnlpTestMixin, def testConfigShow(self): - libonlp.onlp_config_show(self.aim_pvs_buffer_p) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_config_show(self.aim_pvs_buffer.ptr) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) self.assertIn("ONLP_CONFIG_INFO_STR_MAX = 64\n", buf.string_at()) class ThermalTest(OnlpTestMixin, @@ -1112,13 +1122,13 @@ class ThermalTest(OnlpTestMixin, self.assertEqual(onlp.onlp.ONLP_STATUS.E_UNSUPPORTED, code) flags = 0 - libonlp.onlp_thermal_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_thermal_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("thermal @", bufStr) - libonlp.onlp_thermal_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_thermal_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("thermal @", bufStr) @@ -1205,13 +1215,13 @@ class PsuTest(OnlpTestMixin, self.assertEqual(onlp.onlp.ONLP_STATUS.E_UNSUPPORTED, code) flags = 0 - libonlp.onlp_psu_dump(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_psu_dump(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("psu @", bufStr) - libonlp.onlp_psu_show(oid, self.aim_pvs_buffer_p, flags) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.onlp_psu_show(oid, self.aim_pvs_buffer.ptr, flags) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) bufStr = buf.string_at() self.assertIn("psu @", bufStr) @@ -1412,8 +1422,8 @@ class SfpTest(OnlpTestMixin, cl.append(onlp.sff.SFF_MODULE_CAPS.name(fl)) self.log.info("module caps %s", "+".join(cl)) - libonlp.sff_info_show(ctypes.byref(sffEeprom.info), self.aim_pvs_buffer_p) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.sff_info_show(ctypes.byref(sffEeprom.info), self.aim_pvs_buffer.ptr) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) self.assertIn("Vendor:", buf.string_at()) # cons up a new info structure @@ -1428,9 +1438,9 @@ class SfpTest(OnlpTestMixin, sffEeprom.info.length) self.assertStatusOK(sts) - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) - libonlp.sff_info_show(ctypes.byref(info), self.aim_pvs_buffer_p) - buf2 = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) + libonlp.sff_info_show(ctypes.byref(info), self.aim_pvs_buffer.ptr) + buf2 = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) self.assertEqual(buf2.string_at(), buf.string_at()) # test parsing from a file @@ -1465,9 +1475,9 @@ class SfpTest(OnlpTestMixin, def testDump(self): unittest.skip("this is a really slow command") return - libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer_p) - libonlp.onlp_sfp_dump(self.aim_pvs_buffer_p) - buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer_p) + libonlp.aim_pvs_buffer_reset(self.aim_pvs_buffer.ptr) + libonlp.onlp_sfp_dump(self.aim_pvs_buffer.ptr) + buf = libonlp.aim_pvs_buffer_get(self.aim_pvs_buffer.ptr) self.assertIn("Presence Bitmap", buf.string_at()) def auditIoctl(self, port): From 531ff17684f7681cb84ad6abf8e1cb337d2035a1 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 11 Oct 2017 17:08:10 -0700 Subject: [PATCH 039/244] Unmount the EFI directory before doing a re-install --- .../vendor-config-onl/src/python/onl/install/SystemInstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py index 25d51928..ad6ce72e 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -195,7 +195,7 @@ class App(SubprocessMixin): pdir,)) for m in pm.mounts: - if m.dir.startswith('/mnt/onl'): + if m.dir.startswith('/mnt/onl') or m.dir.startswith('/boot'): if not self.force: self.log.error("directory %s is still mounted (try --force)", m.dir) return 1 From c04a9a2604cf256ebee9d9388fa8af221ec0790e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Oct 2017 20:28:49 +0000 Subject: [PATCH 040/244] Handle problems accessing the ONIE eeprom more gracefully. --- .../base/all/vendor-config-onl/src/python/onl/platform/base.py | 1 + packages/base/any/onlp/src/onlp/module/src/sys.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index e804b184..aed2e0f7 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -164,6 +164,7 @@ class OnlPlatformBase(object): except ValueError, e: if required: raise e + self.add_info_dict(name, {}, klass) elif required: raise RuntimeError("A required system file (%s) is missing." % f) diff --git a/packages/base/any/onlp/src/onlp/module/src/sys.c b/packages/base/any/onlp/src/onlp/module/src/sys.c index ad6fc49f..09d3f03b 100644 --- a/packages/base/any/onlp/src/onlp/module/src/sys.c +++ b/packages/base/any/onlp/src/onlp/module/src/sys.c @@ -143,7 +143,8 @@ onlp_sys_info_get_locked__(onlp_sys_info_t* rv) } else { if(onlp_sysi_onie_info_get(&rv->onie_info) != 0) { - return ONLP_STATUS_E_INTERNAL; + memset(&rv->onie_info, 0, sizeof(rv->onie_info)); + list_init(&rv->onie_info.vx_list); } } From a3c3ebb263ea08181d1f571d5490fd9961c82795 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Oct 2017 21:15:00 +0000 Subject: [PATCH 041/244] Add infrastructure to support unparsable cables by vendor and model number. Conflicts: packages/base/any/onlp/src/sff/module/src/sff.c packages/base/any/onlp/src/sff/module/src/sff_db.c --- .../any/onlp/src/sff/module/inc/sff/sff.h | 2 + .../any/onlp/src/sff/module/src/nonstandard.c | 36 ++++++ .../base/any/onlp/src/sff/module/src/sff.c | 9 ++ .../base/any/onlp/src/sff/module/src/sff_db.c | 117 +++++++++++++++++- .../any/onlp/src/sff/module/src/sff_int.h | 1 + 5 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 packages/base/any/onlp/src/sff/module/src/nonstandard.c diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff.h b/packages/base/any/onlp/src/sff/module/inc/sff/sff.h index d011a5da..ce580cf4 100644 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff.h +++ b/packages/base/any/onlp/src/sff/module/inc/sff/sff.h @@ -361,6 +361,8 @@ int sff_info_init(sff_info_t* pinfo, sff_module_type_t type, int length); +int sff_info_from_module_type(sff_info_t* info, sff_sfp_type_t st, + sff_module_type_t mt); #ifdef DEPENDMODULE_INCLUDE_CJSON_UTIL diff --git a/packages/base/any/onlp/src/sff/module/src/nonstandard.c b/packages/base/any/onlp/src/sff/module/src/nonstandard.c new file mode 100644 index 00000000..4b1da720 --- /dev/null +++ b/packages/base/any/onlp/src/sff/module/src/nonstandard.c @@ -0,0 +1,36 @@ +/** + * These parts must be special-cased by vendor and model + * due to nonstandard eeprom contents. + */ +#include + +typedef struct sff_ns_entry_s { + const char* vendor; + const char* model; + sff_module_type_t mt; + int len; +} sff_ns_entry_t; + +static sff_ns_entry_t nonstandard_modules__[] = + { + { "CISCO-OEM ", "QSFP-4SFP+-CU2M ", SFF_MODULE_TYPE_40G_BASE_CR4, 2 }, + { "CISCO-OEM ", "QSFP-4SFP+-CU3M ", SFF_MODULE_TYPE_40G_BASE_CR4, 3 }, + { "CISCO-OEM ", "QSFP-4SFP+-CU5M ", SFF_MODULE_TYPE_40G_BASE_CR4, 5 }, + { "Mellanox ", "MC2206130-001 ", SFF_MODULE_TYPE_40G_BASE_CR4, 1 }, + {}, + }; + + +int +sff_nonstandard_lookup(sff_info_t* info) +{ + sff_ns_entry_t* p; + for(p = nonstandard_modules__; p->vendor; p++) { + if(!strcmp(info->vendor, p->vendor) && !strcmp(info->model, p->model)) { + sff_info_from_module_type(info, info->sfp_type, p->mt); + info->length = p->len; + return 0; + } + } + return -1; +} diff --git a/packages/base/any/onlp/src/sff/module/src/sff.c b/packages/base/any/onlp/src/sff/module/src/sff.c index f059fa4a..45ec110c 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff.c +++ b/packages/base/any/onlp/src/sff/module/src/sff.c @@ -28,6 +28,7 @@ #include #include "sff_log.h" #include +#include "sff_int.h" sff_sfp_type_t sff_sfp_type_get(const uint8_t* eeprom) @@ -665,6 +666,14 @@ sff_eeprom_parse_nonstandard__(sff_eeprom_t* se, uint8_t* eeprom) se->info.length); return 0; } + + if (sff_nonstandard_lookup(&se->info) == 0) { + se->identified = 1; + SFF_SNPRINTF(se->info.length_desc, sizeof(se->info.length_desc), "%dm", + se->info.length); + return 0; + } + return -1; } diff --git a/packages/base/any/onlp/src/sff/module/src/sff_db.c b/packages/base/any/onlp/src/sff/module/src/sff_db.c index 30a7c2b2..fa48081c 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_db.c +++ b/packages/base/any/onlp/src/sff/module/src/sff_db.c @@ -1448,6 +1448,122 @@ static sff_db_entry_t sff_database__[] = -1, } } + }, + { + { + .eeprom = { + 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0xed, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0xa0, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x53, 0x46, + 0x50, 0x2b, 0x2d, 0x43, 0x55, 0x32, 0x4d, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x54, 0x4f, 0x55, 0x30, 0x38, 0x31, 0x30, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x37, 0x30, 0x36, 0x32, 0x38, 0x20, 0x20, 0x2e, 0x00, 0xe1, 0x8f, + 0xe1, 0x00, 0x11, 0x07, 0xe0, 0x78, 0x3c, 0x38, 0x70, 0xdc, 0x23, 0x54, 0x6f, 0x20, 0xce, 0xa0, + 0x17, 0x22, 0xd7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x38, 0xfe, 0x76 + }, + .info = { + "CISCO-OEM ", + "QSFP-4SFP+-CU2M ", + "GTOU0810 ", + SFF_40G_BASE_CR4_PROPERTIES, + 2, + }, + }, + }, + { + { + .eeprom = { + 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x80, 0x45, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x05, 0xa0, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x53, 0x46, + 0x50, 0x2b, 0x2d, 0x43, 0x55, 0x35, 0x4d, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0c, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x54, 0x49, 0x59, 0x32, 0x34, 0x35, 0x35, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x37, 0x30, 0x36, 0x32, 0x38, 0x20, 0x20, 0x2e, 0x00, 0xe2, 0x95, + 0xe2, 0x00, 0x11, 0x18, 0x0f, 0x39, 0xf6, 0x13, 0x6a, 0x40, 0x77, 0x21, 0x63, 0x2a, 0xec, 0xcf, + 0xd7, 0x4d, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x50, 0xe8, 0xf4, + }, + .info = { + "CISCO-OEM ", + "QSFP-4SFP+-CU5M ", + "GTIY2455 ", + SFF_40G_BASE_CR4_PROPERTIES, + 5, + }, + }, + }, + { + { + .eeprom = { + 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xcb, 0x00, 0x00, 0x7e, 0x8c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0xa0, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x53, 0x46, + 0x50, 0x2b, 0x2d, 0x43, 0x55, 0x33, 0x4d, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x54, 0x47, 0x52, 0x38, 0x36, 0x38, 0x30, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x37, 0x30, 0x36, 0x32, 0x38, 0x20, 0x20, 0x2e, 0x00, 0xe1, 0x91, + 0xe1, 0x00, 0x11, 0x9f, 0xfa, 0xcd, 0xf5, 0xd3, 0x56, 0xb3, 0x83, 0x78, 0x28, 0xf6, 0x50, 0x52, + 0xd7, 0x72, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x2f, 0xae, 0x0a, + }, + .info = { + "CISCO-OEM ", + "QSFP-4SFP+-CU3M ", + "GTGR8680 ", + SFF_40G_BASE_CR4_PROPERTIES, + 3, + }, + }, + }, + { + { + .eeprom = { + 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xa0, 0x4d, 0x65, 0x6c, 0x6c, 0x61, 0x6e, 0x6f, 0x78, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x07, 0x00, 0x02, 0xc9, 0x4d, 0x43, 0x32, 0x32, 0x30, 0x36, 0x31, 0x33, + 0x30, 0x2d, 0x30, 0x30, 0x31, 0x20, 0x20, 0x20, 0x41, 0x20, 0x06, 0x0a, 0x00, 0x00, 0x46, 0xa6, + 0x00, 0x00, 0x00, 0x00, 0x4d, 0x53, 0x2d, 0x31, 0x31, 0x31, 0x37, 0x35, 0x30, 0x33, 0x31, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x30, 0x32, 0x32, 0x34, 0x20, 0x20, 0x00, 0x00, 0x00, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .info = { + "Mellanox ", + "MC2206130-001 ", + "MS-11175031 ", + SFF_40G_BASE_CR4_PROPERTIES, + 1, + }, + }, }, { { @@ -1478,7 +1594,6 @@ static sff_db_entry_t sff_database__[] = }, }, }, - #endif /** SFF_CONFIG_INCLUDE_DATABASE */ }; diff --git a/packages/base/any/onlp/src/sff/module/src/sff_int.h b/packages/base/any/onlp/src/sff/module/src/sff_int.h index 3a44e241..a67245ac 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_int.h +++ b/packages/base/any/onlp/src/sff/module/src/sff_int.h @@ -8,5 +8,6 @@ #include +int sff_nonstandard_lookup(sff_info_t* info); #endif /* __SFF_INT_H__ */ From 91fae41cc67cd7d9feb0f2ed75029226bfe81b6b Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Mon, 16 Oct 2017 14:40:44 +0800 Subject: [PATCH 042/244] Add new accton platform, AS7816_64X. --- .../src/python/onl/platform/base.py | 4 + packages/base/any/kernels/modules/ym2651y.c | 91 +- .../x86-64-accton-as7816-64x/.gitignore | 3 + .../x86-64/x86-64-accton-as7816-64x/Makefile | 1 + .../x86-64-accton-as7816-64x/modules/Makefile | 1 + .../x86-64-accton-as7816-64x/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as7816-64x-fan.c | 456 +++++ .../builds/x86-64-accton-as7816-64x-leds.c | 460 +++++ .../builds/x86-64-accton-as7816-64x-psu.c | 239 +++ .../builds/x86-64-accton-as7816-64x-sfp.c | 1576 +++++++++++++++++ .../x86-64-accton-as7816-64x/onlp/Makefile | 1 + .../x86-64-accton-as7816-64x/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../module/auto/x86_64_accton_as7816_64x.yml | 50 + .../x86_64_accton_as7816_64x.x | 14 + .../x86_64_accton_as7816_64x_config.h | 137 ++ .../x86_64_accton_as7816_64x_dox.h | 26 + .../x86_64_accton_as7816_64x_porting.h | 107 ++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 280 +++ .../onlp/builds/src/module/src/ledi.c | 241 +++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 126 ++ .../onlp/builds/src/module/src/platform_lib.h | 101 ++ .../onlp/builds/src/module/src/psui.c | 170 ++ .../onlp/builds/src/module/src/sfpi.c | 179 ++ .../onlp/builds/src/module/src/sysi.c | 336 ++++ .../onlp/builds/src/module/src/thermali.c | 139 ++ .../src/x86_64_accton_as7816_64x_config.c | 81 + .../src/x86_64_accton_as7816_64x_enums.c | 10 + .../module/src/x86_64_accton_as7816_64x_int.h | 12 + .../module/src/x86_64_accton_as7816_64x_log.c | 18 + .../module/src/x86_64_accton_as7816_64x_log.h | 12 + .../src/x86_64_accton_as7816_64x_module.c | 24 + .../src/x86_64_accton_as7816_64x_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-as7816-64x-r0.yml | 33 + .../x86_64_accton_as7816_64x_r0/__init__.py | 129 ++ 49 files changed, 5251 insertions(+), 14 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-fan.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/x86_64_accton_as7816_64x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/lib/x86-64-accton-as7816-64x-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index aed2e0f7..026aed28 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -502,6 +502,10 @@ class OnlPlatformPortConfig_32x100(object): PORT_COUNT=32 PORT_CONFIG="32x100" +class OnlPlatformPortConfig_64x100(object): + PORT_COUNT=64 + PORT_CONFIG="64x100" + class OnlPlatformPortConfig_24x1_4x10(object): PORT_COUNT=28 PORT_CONFIG="24x1 + 4x10" diff --git a/packages/base/any/kernels/modules/ym2651y.c b/packages/base/any/kernels/modules/ym2651y.c index 7101aa41..649200d2 100644 --- a/packages/base/any/kernels/modules/ym2651y.c +++ b/packages/base/any/kernels/modules/ym2651y.c @@ -31,8 +31,11 @@ #include #include #include +#include -#define MAX_FAN_DUTY_CYCLE 100 +#define MAX_FAN_DUTY_CYCLE 100 +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ /* Addresses scanned */ @@ -41,6 +44,7 @@ static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; enum chips { YM2651, YM2401, + YM2851, }; /* Each client has this additional data @@ -67,6 +71,7 @@ struct ym2651y_data { u8 mfr_id[10]; /* Register value */ u8 mfr_model[16]; /* Register value */ u8 mfr_revsion[3]; /* Register value */ + u8 mfr_serial[20]; /* Register value */ u16 mfr_vin_min; /* Register value */ u16 mfr_vin_max; /* Register value */ u16 mfr_iin_max; /* Register value */ @@ -112,6 +117,7 @@ enum ym2651y_sysfs_attributes { PSU_MFR_ID, PSU_MFR_MODEL, PSU_MFR_REVISION, + PSU_MFR_SERIAL, PSU_MFR_VIN_MIN, PSU_MFR_VIN_MAX, PSU_MFR_VOUT_MIN, @@ -140,6 +146,7 @@ static SENSOR_DEVICE_ATTR(psu_pmbus_revision,S_IRUGO, show_byte, NULL, PSU_PMB static SENSOR_DEVICE_ATTR(psu_mfr_id, S_IRUGO, show_ascii, NULL, PSU_MFR_ID); static SENSOR_DEVICE_ATTR(psu_mfr_model, S_IRUGO, show_ascii, NULL, PSU_MFR_MODEL); static SENSOR_DEVICE_ATTR(psu_mfr_revision, S_IRUGO, show_ascii, NULL, PSU_MFR_REVISION); +static SENSOR_DEVICE_ATTR(psu_mfr_serial, S_IRUGO, show_ascii, NULL, PSU_MFR_SERIAL); static SENSOR_DEVICE_ATTR(psu_mfr_vin_min, S_IRUGO, show_linear, NULL, PSU_MFR_VIN_MIN); static SENSOR_DEVICE_ATTR(psu_mfr_vin_max, S_IRUGO, show_linear, NULL, PSU_MFR_VIN_MAX); static SENSOR_DEVICE_ATTR(psu_mfr_vout_min, S_IRUGO, show_linear, NULL, PSU_MFR_VOUT_MIN); @@ -166,6 +173,7 @@ static struct attribute *ym2651y_attributes[] = { &sensor_dev_attr_psu_mfr_id.dev_attr.attr, &sensor_dev_attr_psu_mfr_model.dev_attr.attr, &sensor_dev_attr_psu_mfr_revision.dev_attr.attr, + &sensor_dev_attr_psu_mfr_serial.dev_attr.attr, &sensor_dev_attr_psu_mfr_vin_min.dev_attr.attr, &sensor_dev_attr_psu_mfr_vin_max.dev_attr.attr, &sensor_dev_attr_psu_mfr_pout_max.dev_attr.attr, @@ -370,6 +378,9 @@ static ssize_t show_ascii(struct device *dev, struct device_attribute *da, case PSU_MFR_REVISION: /* psu_mfr_revision */ ptr = data->mfr_revsion + 1; /* The first byte is the count byte of string. */ break; + case PSU_MFR_SERIAL: /* psu_mfr_serial */ + ptr = data->mfr_serial + 1; /* The first byte is the count byte of string. */ + break; default: return 0; } @@ -477,6 +488,7 @@ static int ym2651y_remove(struct i2c_client *client) static const struct i2c_device_id ym2651y_id[] = { { "ym2651", YM2651 }, { "ym2401", YM2401 }, + { "ym2851", YM2851 }, {} }; MODULE_DEVICE_TABLE(i2c, ym2651y_id); @@ -494,35 +506,75 @@ static struct i2c_driver ym2651y_driver = { static int ym2651y_read_byte(struct i2c_client *client, u8 reg) { - return i2c_smbus_read_byte_data(client, reg); + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; } static int ym2651y_read_word(struct i2c_client *client, u8 reg) { - return i2c_smbus_read_word_data(client, reg); + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_word_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; } static int ym2651y_write_word(struct i2c_client *client, u8 reg, u16 value) { - return i2c_smbus_write_word_data(client, reg, value); + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_word_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; } static int ym2651y_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len) { - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + int status = 0, retry = I2C_RW_RETRY_COUNT; - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; } - result = 0; - -abort: - return result; + return status; } struct reg_data_byte { @@ -651,6 +703,17 @@ static struct ym2651y_data *ym2651y_update_device(struct device *dev) goto exit; } + /* Read mfr_serial */ + command = 0x9e; + status = ym2651y_read_block(client, command, data->mfr_serial, + ARRAY_SIZE(data->mfr_serial)-1); + data->mfr_serial[ARRAY_SIZE(data->mfr_serial)-1] = '\0'; + + if (status < 0) { + dev_dbg(&client->dev, "reg %d, err %d\n", command, status); + goto exit; + } + data->last_updated = jiffies; data->valid = 1; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/.gitignore new file mode 100644 index 00000000..38161e48 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*as7816*64x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/PKG.yml new file mode 100644 index 00000000..ce9eb1ed --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as7816-64x ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/Makefile new file mode 100644 index 00000000..d1e88548 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as7816-64x +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-fan.c new file mode 100644 index 00000000..1bc7198b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-fan.c @@ -0,0 +1,456 @@ +/* + * A hwmon driver for the Accton as7816-64x fan + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as7816_64x_fan" + +static struct as7816_64x_fan_data *as7816_64x_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x80, /* fan 1-4 present status */ + 0x81, /* fan 1-4 direction(0:F2B 1:B2F) */ + 0x87, /* fan PWM(for all fan) */ + 0x90, /* front fan 1 speed(rpm) */ + 0x91, /* front fan 2 speed(rpm) */ + 0x92, /* front fan 3 speed(rpm) */ + 0x93, /* front fan 4 speed(rpm) */ + 0x98, /* rear fan 1 speed(rpm) */ + 0x99, /* rear fan 2 speed(rpm) */ + 0x9A, /* rear fan 3 speed(rpm) */ + 0x9B, /* rear fan 4 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as7816_64x_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DIRECTION_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN1_DIRECTION, + FAN2_DIRECTION, + FAN3_DIRECTION, + FAN4_DIRECTION, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT +}; + +/* Define attributes + */ +#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 + +#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +/* 6 fan direction attribute in this platform */ +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); + +static struct attribute *as7816_64x_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_FAULT_ATTR(4), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_DIRECTION_ATTR(1), + DECLARE_FAN_DIRECTION_ATTR(2), + DECLARE_FAN_DIRECTION_ATTR(3), + DECLARE_FAN_DIRECTION_ATTR(4), + DECLARE_FAN_DUTY_CYCLE_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as7816_64x_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as7816_64x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + + if (!reg_val) { + return 0; + } + + if (reg_val == 0xF) { + return FAN_MAX_DUTY_CYCLE; + } + + return (reg_val * 6) + 10; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + if (duty_cycle < 16) { + return 0; + } + + if (duty_cycle >= 100) { + return 0xF; + } + + return (duty_cycle - 10) / 6; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + return !!(reg_val & mask); +} + +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + return !(reg_val & mask); +} + +static u8 is_fan_fault(struct as7816_64x_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as7816_64x_fan_write_value(client, 0x28, 0); /* Disable fan speed watch dog */ + as7816_64x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7816_64x_fan_data *data = as7816_64x_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + { + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + } + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIRECTION: + case FAN2_DIRECTION: + case FAN3_DIRECTION: + case FAN4_DIRECTION: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], + attr->index - FAN1_DIRECTION)); + break; + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as7816_64x_fan_group = { + .attrs = as7816_64x_fan_attributes, +}; + +static struct as7816_64x_fan_data *as7816_64x_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7816_64x_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as7816_64x_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as7816_64x_fan_read_value(client, fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as7816_64x_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7816_64x_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7816_64x_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7816_64x_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7816_64x_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7816_64x_fan_remove(struct i2c_client *client) +{ + struct as7816_64x_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7816_64x_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static const struct i2c_device_id as7816_64x_fan_id[] = { + { "as7816_64x_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7816_64x_fan_id); + +static struct i2c_driver as7816_64x_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as7816_64x_fan_probe, + .remove = as7816_64x_fan_remove, + .id_table = as7816_64x_fan_id, + .address_list = normal_i2c, +}; + +static int __init as7816_64x_fan_init(void) +{ + return i2c_add_driver(&as7816_64x_fan_driver); +} + +static void __exit as7816_64x_fan_exit(void) +{ + i2c_del_driver(&as7816_64x_fan_driver); +} + +module_init(as7816_64x_fan_init); +module_exit(as7816_64x_fan_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7816_64x_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c new file mode 100644 index 00000000..3d1e7be6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c @@ -0,0 +1,460 @@ +/* + * A LED driver for the as7816_64x_led + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*#define DEBUG*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +extern void led_classdev_unregister(struct led_classdev *led_cdev); +extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); +extern void led_classdev_resume(struct led_classdev *led_cdev); +extern void led_classdev_suspend(struct led_classdev *led_cdev); + +#define DRVNAME "as7816_64x_led" + +struct as7816_64x_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[1]; /* only 1 register*/ +}; + +static struct as7816_64x_led_data *ledctl = NULL; + +/* LED related data + */ + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x03) +#define LED_MODE_DIAG_YELLOW_VALUE (0x00) +#define LED_MODE_DIAG_RED_VALUE (0x01) +#define LED_MODE_DIAG_GREEN_VALUE (0x02) +#define LED_MODE_DIAG_OFF_VALUE (0x03) + +#define LED_TYPE_LOC_REG_MASK (0x10) +#define LED_MODE_LOC_ORANGE_VALUE (0x00) +#define LED_MODE_LOC_OFF_VALUE (0x10) + +#define LED_TYPE_FAN_REG_MASK (0x0C) +#define LED_MODE_FAN_ORANGE_VALUE (0x04) +#define LED_MODE_FAN_GREEN_VALUE_1 (0x00) +#define LED_MODE_FAN_GREEN_VALUE_2 (0x08) +#define LED_MODE_FAN_OFF_VALUE (0x0C) + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +struct led_reg { + u32 types; + u8 reg_addr; +}; + +static const struct led_reg led_reg_map[] = { + {(1 << LED_TYPE_LOC) | (1 << LED_TYPE_DIAG) | (1 << LED_TYPE_FAN), 0x30}, +}; + +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +struct led_type_mode { + enum led_type type; + enum led_light_mode mode; + int reg_bit_mask; + int mode_value; +}; + +static struct led_type_mode led_type_mode_data[] = { +{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE}, +{LED_TYPE_LOC, LED_MODE_ORANGE,LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_ORANGE_VALUE}, +{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE}, +{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE}, +{LED_TYPE_DIAG, LED_MODE_RED, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_RED_VALUE}, +{LED_TYPE_DIAG, LED_MODE_YELLOW,LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_YELLOW_VALUE}, +{LED_TYPE_FAN, LED_MODE_OFF, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_OFF_VALUE}, +{LED_TYPE_FAN, LED_MODE_GREEN, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_GREEN_VALUE_1}, +{LED_TYPE_FAN, LED_MODE_GREEN, LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_GREEN_VALUE_2}, +{LED_TYPE_FAN, LED_MODE_ORANGE,LED_TYPE_FAN_REG_MASK, LED_MODE_FAN_ORANGE_VALUE} +}; + +static int get_led_reg(enum led_type type, u8 *reg) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(led_reg_map); i++) { + if(led_reg_map[i].types & (1 << type)) { + *reg = led_reg_map[i].reg_addr; + return 0; + } + } + + return 1; +} + +static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + + if (type != led_type_mode_data[i].type) + continue; + + if ((led_type_mode_data[i].reg_bit_mask & reg_val) == + led_type_mode_data[i].mode_value) + { + return led_type_mode_data[i].mode; + } + } + + return 0; +} + +static u8 led_light_mode_to_reg_val(enum led_type type, + enum led_light_mode mode, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + if (type != led_type_mode_data[i].type) + continue; + + if (mode != led_type_mode_data[i].mode) + continue; + + reg_val = led_type_mode_data[i].mode_value | + (reg_val & (~led_type_mode_data[i].reg_bit_mask)); + break; + } + + return reg_val; +} + +static int as7816_64x_led_read_value(u8 reg) +{ + return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); +} + +static int as7816_64x_led_write_value(u8 reg, u8 value) +{ + return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); +} + +static void as7816_64x_led_update(void) +{ + mutex_lock(&ledctl->update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting as7816_64x_led update\n"); + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = as7816_64x_led_read_value(led_reg_map[i].reg_addr); + + if (status < 0) { + ledctl->valid = 0; + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); + goto exit; + } + else + { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void as7816_64x_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + enum led_type type) +{ + int reg_val; + u8 reg ; + mutex_lock(&ledctl->update_lock); + + if( !get_led_reg(type, ®)) { + dev_dbg(&ledctl->pdev->dev, "Not match register for %d.\n", type); + } + + reg_val = as7816_64x_led_read_value(reg); + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + as7816_64x_led_write_value(reg, reg_val); + + /* to prevent the slow-update issue */ + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + + +static void as7816_64x_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + as7816_64x_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); +} + +static enum led_brightness as7816_64x_led_diag_get(struct led_classdev *cdev) +{ + as7816_64x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static void as7816_64x_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + as7816_64x_led_set(led_cdev, led_light_mode, LED_TYPE_LOC); +} + +static enum led_brightness as7816_64x_led_loc_get(struct led_classdev *cdev) +{ + as7816_64x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void as7816_64x_led_fan_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + as7816_64x_led_set(led_cdev, led_light_mode, LED_TYPE_FAN); +} + +static enum led_brightness as7816_64x_led_fan_get(struct led_classdev *cdev) +{ + as7816_64x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_FAN, ledctl->reg_val[0]); +} + +static void as7816_64x_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness as7816_64x_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static struct led_classdev as7816_64x_leds[] = { + [LED_TYPE_DIAG] = { + .name = "as7816_64x_led::diag", + .default_trigger = "unused", + .brightness_set = as7816_64x_led_diag_set, + .brightness_get = as7816_64x_led_diag_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_LOC] = { + .name = "as7816_64x_led::loc", + .default_trigger = "unused", + .brightness_set = as7816_64x_led_loc_set, + .brightness_get = as7816_64x_led_loc_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_ORANGE, + }, + [LED_TYPE_FAN] = { + .name = "as7816_64x_led::fan", + .default_trigger = "unused", + .brightness_set = as7816_64x_led_fan_set, + .brightness_get = as7816_64x_led_fan_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_PSU1] = { + .name = "as7816_64x_led::psu1", + .default_trigger = "unused", + .brightness_set = as7816_64x_led_auto_set, + .brightness_get = as7816_64x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "as7816_64x_led::psu2", + .default_trigger = "unused", + .brightness_set = as7816_64x_led_auto_set, + .brightness_get = as7816_64x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int as7816_64x_led_suspend(struct platform_device *dev, + pm_message_t state) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(as7816_64x_leds); i++) { + led_classdev_suspend(&as7816_64x_leds[i]); + } + + return 0; +} + +static int as7816_64x_led_resume(struct platform_device *dev) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(as7816_64x_leds); i++) { + led_classdev_resume(&as7816_64x_leds[i]); + } + + return 0; +} + +static int as7816_64x_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(as7816_64x_leds); i++) { + ret = led_classdev_register(&pdev->dev, &as7816_64x_leds[i]); + + if (ret < 0) + break; + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(as7816_64x_leds)){ + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&as7816_64x_leds[i]); + } + } + + return ret; +} + +static int as7816_64x_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(as7816_64x_leds); i++) { + led_classdev_unregister(&as7816_64x_leds[i]); + } + + return 0; +} + +static struct platform_driver as7816_64x_led_driver = { + .probe = as7816_64x_led_probe, + .remove = as7816_64x_led_remove, + .suspend = as7816_64x_led_suspend, + .resume = as7816_64x_led_resume, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init as7816_64x_led_init(void) +{ + int ret; + + ret = platform_driver_register(&as7816_64x_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct as7816_64x_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + platform_driver_unregister(&as7816_64x_led_driver); + goto exit; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + platform_driver_unregister(&as7816_64x_led_driver); + kfree(ledctl); + goto exit; + } + +exit: + return ret; +} + +static void __exit as7816_64x_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&as7816_64x_led_driver); + kfree(ledctl); +} + +module_init(as7816_64x_led_init); +module_exit(as7816_64x_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7816_64x_led driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c new file mode 100644 index 00000000..c5bbd1ff --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c @@ -0,0 +1,239 @@ +/* + * An hwmon driver for accton as7816_64x Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PSU_STATUS_I2C_ADDR 0x60 +#define PSU_STATUS_I2C_REG_OFFSET 0x03 + +#define IS_POWER_GOOD(id, value) (!!(value & BIT(2+id))) +#define IS_PRESENT(id, value) (!(value & BIT(id))) + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static struct as7816_64x_psu_data *as7816_64x_psu_update_device(struct device *dev); +extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as7816_64x_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ +}; + +enum as7816_64x_psu_sysfs_attributes { + PSU_PRESENT, + PSU_POWER_GOOD +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as7816_64x_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7816_64x_psu_data *data = as7816_64x_psu_update_device(dev); + u8 status = 0; + + if (!data->valid) { + return -EIO; + } + + if (attr->index == PSU_PRESENT) { + status = IS_PRESENT(data->index, data->status); + } + else { /* PSU_POWER_GOOD */ + status = IS_POWER_GOOD(data->index, data->status); + } + + return sprintf(buf, "%d\n", status); +} + +static const struct attribute_group as7816_64x_psu_group = { + .attrs = as7816_64x_psu_attributes, +}; + +static int as7816_64x_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7816_64x_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7816_64x_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7816_64x_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7816_64x_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7816_64x_psu_remove(struct i2c_client *client) +{ + struct as7816_64x_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7816_64x_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as7816_64x_psu1, + as7816_64x_psu2 +}; + +static const struct i2c_device_id as7816_64x_psu_id[] = { + { "as7816_64x_psu1", as7816_64x_psu1 }, + { "as7816_64x_psu2", as7816_64x_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7816_64x_psu_id); + +static struct i2c_driver as7816_64x_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7816_64x_psu", + }, + .probe = as7816_64x_psu_probe, + .remove = as7816_64x_psu_remove, + .id_table = as7816_64x_psu_id, + .address_list = normal_i2c, +}; + +static struct as7816_64x_psu_data *as7816_64x_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7816_64x_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + + data->valid = 0; + dev_dbg(&client->dev, "Starting as7816_64x update\n"); + + /* Read psu status */ + status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); + goto exit; + } + else { + data->status = status; + } + + data->last_updated = jiffies; + data->valid = 1; + } + +exit: + mutex_unlock(&data->update_lock); + + return data; +} + +static int __init as7816_64x_psu_init(void) +{ + return i2c_add_driver(&as7816_64x_psu_driver); +} + +static void __exit as7816_64x_psu_exit(void) +{ + i2c_del_driver(&as7816_64x_psu_driver); +} + +module_init(as7816_64x_psu_init); +module_exit(as7816_64x_psu_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7816_64x_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c new file mode 100644 index 00000000..28047a46 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c @@ -0,0 +1,1576 @@ +/* + * SFP driver for accton as7816_64x sfp + * + * Copyright (C) Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "as7816_64x_sfp" /* Platform dependent */ + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 24 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL +}; + +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +as7816_64x_port1, as7816_64x_port2, as7816_64x_port3, as7816_64x_port4, +as7816_64x_port5, as7816_64x_port6, as7816_64x_port7, as7816_64x_port8, +as7816_64x_port9, as7816_64x_port10, as7816_64x_port11, as7816_64x_port12, +as7816_64x_port13, as7816_64x_port14, as7816_64x_port15, as7816_64x_port16, +as7816_64x_port17, as7816_64x_port18, as7816_64x_port19, as7816_64x_port20, +as7816_64x_port21, as7816_64x_port22, as7816_64x_port23, as7816_64x_port24, +as7816_64x_port25, as7816_64x_port26, as7816_64x_port27, as7816_64x_port28, +as7816_64x_port29, as7816_64x_port30, as7816_64x_port31, as7816_64x_port32, +as7816_64x_port33, as7816_64x_port34, as7816_64x_port35, as7816_64x_port36, +as7816_64x_port37, as7816_64x_port38, as7816_64x_port39, as7816_64x_port40, +as7816_64x_port41, as7816_64x_port42, as7816_64x_port43, as7816_64x_port44, +as7816_64x_port45, as7816_64x_port46, as7816_64x_port47, as7816_64x_port48, +as7816_64x_port49, as7816_64x_port50, as7816_64x_port51, as7816_64x_port52, +as7816_64x_port53, as7816_64x_port54, as7816_64x_port55, as7816_64x_port56, +as7816_64x_port57, as7816_64x_port58, as7816_64x_port59, as7816_64x_port60, +as7816_64x_port61, as7816_64x_port62, as7816_64x_port63, as7816_64x_port64 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as7816_64x_port1), +I2C_DEV_ID(as7816_64x_port2), +I2C_DEV_ID(as7816_64x_port3), +I2C_DEV_ID(as7816_64x_port4), +I2C_DEV_ID(as7816_64x_port5), +I2C_DEV_ID(as7816_64x_port6), +I2C_DEV_ID(as7816_64x_port7), +I2C_DEV_ID(as7816_64x_port8), +I2C_DEV_ID(as7816_64x_port9), +I2C_DEV_ID(as7816_64x_port10), +I2C_DEV_ID(as7816_64x_port11), +I2C_DEV_ID(as7816_64x_port12), +I2C_DEV_ID(as7816_64x_port13), +I2C_DEV_ID(as7816_64x_port14), +I2C_DEV_ID(as7816_64x_port15), +I2C_DEV_ID(as7816_64x_port16), +I2C_DEV_ID(as7816_64x_port17), +I2C_DEV_ID(as7816_64x_port18), +I2C_DEV_ID(as7816_64x_port19), +I2C_DEV_ID(as7816_64x_port20), +I2C_DEV_ID(as7816_64x_port21), +I2C_DEV_ID(as7816_64x_port22), +I2C_DEV_ID(as7816_64x_port23), +I2C_DEV_ID(as7816_64x_port24), +I2C_DEV_ID(as7816_64x_port25), +I2C_DEV_ID(as7816_64x_port26), +I2C_DEV_ID(as7816_64x_port27), +I2C_DEV_ID(as7816_64x_port28), +I2C_DEV_ID(as7816_64x_port29), +I2C_DEV_ID(as7816_64x_port30), +I2C_DEV_ID(as7816_64x_port31), +I2C_DEV_ID(as7816_64x_port32), +I2C_DEV_ID(as7816_64x_port33), +I2C_DEV_ID(as7816_64x_port34), +I2C_DEV_ID(as7816_64x_port35), +I2C_DEV_ID(as7816_64x_port36), +I2C_DEV_ID(as7816_64x_port37), +I2C_DEV_ID(as7816_64x_port38), +I2C_DEV_ID(as7816_64x_port39), +I2C_DEV_ID(as7816_64x_port40), +I2C_DEV_ID(as7816_64x_port41), +I2C_DEV_ID(as7816_64x_port42), +I2C_DEV_ID(as7816_64x_port43), +I2C_DEV_ID(as7816_64x_port44), +I2C_DEV_ID(as7816_64x_port45), +I2C_DEV_ID(as7816_64x_port46), +I2C_DEV_ID(as7816_64x_port47), +I2C_DEV_ID(as7816_64x_port48), +I2C_DEV_ID(as7816_64x_port49), +I2C_DEV_ID(as7816_64x_port50), +I2C_DEV_ID(as7816_64x_port51), +I2C_DEV_ID(as7816_64x_port52), +I2C_DEV_ID(as7816_64x_port53), +I2C_DEV_ID(as7816_64x_port54), +I2C_DEV_ID(as7816_64x_port55), +I2C_DEV_ID(as7816_64x_port56), +I2C_DEV_ID(as7816_64x_port57), +I2C_DEV_ID(as7816_64x_port58), +I2C_DEV_ID(as7816_64x_port59), +I2C_DEV_ID(as7816_64x_port60), +I2C_DEV_ID(as7816_64x_port61), +I2C_DEV_ID(as7816_64x_port62), +I2C_DEV_ID(as7816_64x_port63), +I2C_DEV_ID(as7816_64x_port64), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP, + DRIVER_TYPE_XFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} + +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0; + int status = -1; + u8 regs[] = {0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77}; + + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 1~64 */ + data->present = 0; + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = accton_i2c_cpld_read(0x60, regs[i]); + + if (status < 0) { + DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); + data->present |= (u64)status << (i*8); + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + int i; + u8 values[8] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } + + /* Return values 1 -> 64 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3], + values[4], values[5], values[6], values[7]); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d\n", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP || + port_data->driver_type == DRIVER_TYPE_XFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as7816_64x_port1 || dev_id->driver_data > as7816_64x_port64) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as7816_64x_sfp driver"); +MODULE_LICENSE("GPL"); + +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/PKG.yml new file mode 100644 index 00000000..ba43c4cd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7816-64x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/lib/Makefile new file mode 100644 index 00000000..eb25a458 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as7816-64x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as7816_64x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as7816-64x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..ad16e632 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as7816_64x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.module new file mode 100644 index 00000000..576dafed --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as7816_64x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile new file mode 100644 index 00000000..bb75e4bf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_as7816_64x +AUTOMODULE := x86_64_accton_as7816_64x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/README new file mode 100644 index 00000000..d54e5ba8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as7816_64x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..7bf095d4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_as7816_64x Autogeneration +# +############################################################################### +x86_64_accton_as7816_64x_AUTO_DEFS := module/auto/x86_64_accton_as7816_64x.yml +x86_64_accton_as7816_64x_AUTO_DIRS := module/inc/x86_64_accton_as7816_64x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/x86_64_accton_as7816_64x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/x86_64_accton_as7816_64x.yml new file mode 100644 index 00000000..e3196b89 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/auto/x86_64_accton_as7816_64x.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_accton_as7816_64x Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_AS7816_64X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as7816_64x_config + + portingmacro: + x86_64_accton_as7816_64x: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x.x b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x.x new file mode 100644 index 00000000..1b13b5ac --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_config.h new file mode 100644 index 00000000..6012ae33 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7816_64x Configuration Header + * + * @addtogroup x86_64_accton_as7816_64x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7816_64X_CONFIG_H__ +#define __X86_64_ACCTON_AS7816_64X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_AS7816_64X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as7816_64x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as7816_64x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as7816_64x_config_settings table. */ +extern x86_64_accton_as7816_64x_config_settings_t x86_64_accton_as7816_64x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as7816_64x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as7816_64x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as7816_64x_porting.h" + +#endif /* __X86_64_ACCTON_AS7816_64X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_dox.h new file mode 100644 index 00000000..19365a0a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as7816_64x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7816_64X_DOX_H__ +#define __X86_64_ACCTON_AS7816_64X_DOX_H__ + +/** + * @defgroup x86_64_accton_as7816_64x x86_64_accton_as7816_64x - x86_64_accton_as7816_64x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as7816_64x-x86_64_accton_as7816_64x Public Interface + * @defgroup x86_64_accton_as7816_64x-config Compile Time Configuration + * @defgroup x86_64_accton_as7816_64x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_AS7816_64X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h new file mode 100644 index 00000000..bb203a77 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7816_64x Porting Macros. + * + * @addtogroup x86_64_accton_as7816_64x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7816_64X_PORTING_H__ +#define __X86_64_ACCTON_AS7816_64X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_as7816_64x_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_as7816_64x_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_MALLOC malloc + #else + #error The macro x86_64_accton_as7816_64x_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_as7816_64x_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_FREE free + #else + #error The macro x86_64_accton_as7816_64x_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_as7816_64x_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_MEMSET memset + #else + #error The macro x86_64_accton_as7816_64x_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_as7816_64x_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_MEMCPY memcpy + #else + #error The macro x86_64_accton_as7816_64x_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_as7816_64x_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_STRNCPY strncpy + #else + #error The macro x86_64_accton_as7816_64x_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_as7816_64x_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_as7816_64x_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_as7816_64x_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_SNPRINTF snprintf + #else + #error The macro x86_64_accton_as7816_64x_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7816_64x_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_as7816_64x_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7816_64x_STRLEN strlen + #else + #error The macro x86_64_accton_as7816_64x_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_AS7816_64X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..cbf5a4d3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as7816_64x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as7816_64x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as7816_64x_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7816_64x ucli:x86_64_accton_as7816_64x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..f1ff7510 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as7816_64x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..76fc16b9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/fani.c @@ -0,0 +1,280 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2 +}; + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 18000 + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + PSU_FAN_INFO(1, 1), + PSU_FAN_INFO(2, 1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value; + + /* get fan present status + */ + if (onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid) < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; /* fan is not present */ + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + if (onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid) < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + if (onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid) < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_B2F : ONLP_FAN_STATUS_F2B; + + + /* get front fan speed + */ + if (onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid) < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + if (onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid) < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = psu_type_get(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + switch (psu_type) { + case PSU_TYPE_AC_YM2851_F2B: + return ONLP_FAN_STATUS_F2B; + case PSU_TYPE_AC_YM2851_B2F: + return ONLP_FAN_STATUS_B2F; + default: + return 0; + }; + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + if (onlp_file_write_int(p, path) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..445be0e7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,241 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define LED_FORMAT "/sys/class/leds/as7816_64x_led::%s/brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ + +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_DIAG, LED_MODE_YELLOW,ONLP_LED_MODE_YELLOW}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_ORANGE,ONLP_LED_MODE_ORANGE}, +{LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_FAN, LED_MODE_ORANGE,ONLP_LED_MODE_ORANGE}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char *leds[] = /* must map with onlp_led_id */ +{ + "reserved", + "psu1", + "psu2", + "fan", + "diag", + "loc", +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 1 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 2 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 4 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 5 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * LED Off + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Get LED mode */ + if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) { + DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid; + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..c6e01f8f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as7816_64x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..015bf647 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,126 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_MODEL_NAME_LEN 8 +#define PSU_SERIAL_NUMBER_LEN 14 +#define PSU_NODE_MAX_PATH_LEN 64 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + +psu_type_t psu_type_get(int id, char* modelname, int modelname_len) +{ + int value = 0; + int ret = ONLP_STATUS_OK; + char model[PSU_MODEL_NAME_LEN + 1] = {0}; + char *prefix = NULL; + + if (modelname && modelname_len < PSU_MODEL_NAME_LEN) { + return PSU_TYPE_UNKNOWN; + } + + /* Check if the psu is power good + */ + prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; + if (onlp_file_read_int(&value, "%s%s", prefix, "psu_power_good") < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, "psu_power_good"); + return ONLP_STATUS_E_INTERNAL; + } + + if (!value) { + return PSU_TYPE_UNKNOWN; + } + + /* Read mode name */ + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + ret = onlp_file_read((uint8_t*)model, PSU_MODEL_NAME_LEN, &value, "%s%s", prefix, "psu_mfr_model"); + if (ret != ONLP_STATUS_OK || value != PSU_MODEL_NAME_LEN) { + return PSU_TYPE_UNKNOWN; + + } + + if (modelname) { + memcpy(modelname, model, sizeof(model)); + } + + if (strncmp(model, "YM-2851F", strlen("YM-2851F")) == 0) { + return PSU_TYPE_AC_YM2851_F2B; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + char *prefix = NULL; + *value = 0; + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char *prefix = NULL; + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + if (onlp_file_write_int(value, "%s%s", prefix, node) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s%s)\r\n", prefix, node); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..54d03dd4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,101 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_as7816_64x_log.h" + +#define CHASSIS_FAN_COUNT 4 +#define CHASSIS_THERMAL_COUNT 7 +#define CHASSIS_LED_COUNT 5 +#define CHASSIS_PSU_COUNT 2 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/10-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/9-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/10-0053/" +#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/9-0050/" + +#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node +#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/17-0068/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/bus/i2c/devices/0-0056/eeprom" + +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_PSU1, + LED_PSU2, + LED_FAN, + LED_DIAG, + LED_LOC +}; + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_6_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_YM2851_F2B, + PSU_TYPE_AC_YM2851_B2F +} psu_type_t; + +psu_type_t psu_type_get(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..a80b5627 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c @@ -0,0 +1,170 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + char *prefix = NULL; + *value = 0; + + prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; + if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node); + return ONLP_STATUS_E_INTERNAL; + } + + return 0; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + psu_serial_number_get(index, info->serial, sizeof(info->serial)); + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = psu_type_get(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_YM2851_F2B: + case PSU_TYPE_AC_YM2851_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..3b0fa4be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,179 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define NUM_OF_SFP_PORT 64 +static const int port_bus_index[NUM_OF_SFP_PORT] = { +37, 38, 39, 40, 42, 41, 44, 43, +33, 34, 35, 36, 45, 46, 47, 48, +49, 50, 51, 52, 61, 62, 63, 64, +53, 54, 55, 56, 57, 58, 59, 60, +69, 70, 71, 72, 77, 78, 79, 80, +65, 66, 67, 68, 73, 74, 75, 76, +85, 86, 87, 88, 31, 32, 29, 30, +81, 82, 83, 84, 25, 26, 27, 28 +}; + +#define QSFP_BUS_INDEX(port) (port_bus_index[port]) +#define QSFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 16} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + if (onlp_file_read_int(&present, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_is_present") < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[8]; + char path[64] = {0}; + FILE* fp; + + sprintf(path, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(0), "sfp_is_present_all"); + fp = fopen(path, "r"); + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x %x %x %x %x", + bytes+0, bytes+1, bytes+2, bytes+3, + bytes+4, bytes+5, bytes+6, bytes+7); + fclose(fp); + if(count != AIM_ARRAYSIZE(bytes)) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + int size = 0; + + if(onlp_file_read(data, 256, &size, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { + if(size == 256) { + return ONLP_STATUS_OK; + } + } + + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = QSFP_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = QSFP_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = QSFP_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = QSFP_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..ada5a5d2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,336 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_as7816_64x_int.h" +#include "x86_64_accton_as7816_64x_log.h" + +#define CPLD_VERSION_FORMAT "/sys/bus/i2c/devices/%s/version" +#define NUM_OF_CPLD 4 + +static char* cpld_path[NUM_OF_CPLD] = +{ + "19-0060", + "20-0062", + "21-0064", + "22-0066" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as7816-64x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 5 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 1 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 2 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int i, v[NUM_OF_CPLD] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(cpld_path); i++) { + v[i] = 0; + + if(onlp_file_read_int(v+i, CPLD_VERSION_FORMAT , cpld_path[i]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + } + + pi->cpld_versions = aim_fstrdup("%d.%d.%d.%d", v[0], v[1], v[2], v[3]); + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ + aim_free(pi->cpld_versions); +} + +int +onlp_sysi_platform_manage_init(void) +{ + return 0; +} + +#define FAN_DUTY_MAX (100) +#define FAN_DUTY_MIN (52) + +static int +sysi_fanctrl_fan_fault_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* Bring fan speed to FAN_DUTY_MAX if any fan is not operational */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + if (!(fi[i].status & ONLP_FAN_STATUS_FAILED)) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_fan_absent_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* Bring fan speed to FAN_DUTY_MAX if fan is not present */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + if (fi[i].status & ONLP_FAN_STATUS_PRESENT) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_fan_unknown_speed_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i, match = 0; + int fanduty; + int legal_duties[] = {FAN_DUTY_MIN, 64, 76, 88, FAN_DUTY_MAX}; + + *adjusted = 0; + + if (onlp_file_read_int(&fanduty, FAN_NODE(fan_duty_cycle_percentage)) < 0) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN); + } + + /* Bring fan speed to min if current speed is not expected + */ + for (i = 0; i < AIM_ARRAYSIZE(legal_duties); i++) { + if (fanduty != legal_duties[i]) { + continue; + } + + match = 1; + break; + } + + if (!match) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_overall_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i, num_of_sensor = 0, temp_avg = 0; + + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_6_ON_MAIN_BROAD); i++) { + num_of_sensor++; + temp_avg += ti[i-1].mcelsius; + } + + temp_avg /= num_of_sensor; + *adjusted = 1; + + if (temp_avg > 57000) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + else if (temp_avg > 52000) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), 88); + } + else if (temp_avg > 46000) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), 76); + } + else if (temp_avg > 43000) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), 64); + } + + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN); +} + +typedef int (*fan_control_policy)(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted); + +fan_control_policy fan_control_policies[] = { +sysi_fanctrl_fan_fault_policy, +sysi_fanctrl_fan_absent_policy, +sysi_fanctrl_fan_unknown_speed_policy, +sysi_fanctrl_overall_thermal_sensor_policy, +}; + +int +onlp_sysi_platform_manage_fans(void) +{ + int i, rc; + onlp_fan_info_t fi[CHASSIS_FAN_COUNT]; + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT]; + + memset(fi, 0, sizeof(fi)); + memset(ti, 0, sizeof(ti)); + + /* Get fan status + */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fi[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i+1); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Get thermal sensor status + */ + for (i = 0; i < CHASSIS_THERMAL_COUNT; i++) { + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i+1), &ti[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + AIM_LOG_ERROR("Unable to get thermal(%d) status\r\n", i+1); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Apply thermal policy according the policy list, + * If fan duty is adjusted by one of the policies, skip the others + */ + for (i = 0; i < AIM_ARRAYSIZE(fan_control_policies); i++) { + int adjusted = 0; + + rc = fan_control_policies[i](fi, ti, &adjusted); + if (!adjusted) { + continue; + } + + return rc; + } + + return ONLP_STATUS_OK; +} +int +onlp_sysi_platform_manage_leds(void) +{ + int i = 0, fan_fault = 0; + + /* Get each fan status + */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + if (!(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { + AIM_LOG_ERROR("Fan(%d) is not present, set the fan system led as orange\r\n", i); + fan_fault = 1; + break; + } + + if (fan_info.status & ONLP_FAN_STATUS_FAILED) { + AIM_LOG_ERROR("Fan(%d) is not working, set the fan system led as orange\r\n", i); + fan_fault = 1; + break; + } + } + + return fan_fault ? onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_ORANGE) : + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_GREEN); +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..31cf3a27 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,139 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + "reserved", + NULL, /* CPU_CORE files */ + "/sys/bus/i2c/devices/18-0048*temp1_input", + "/sys/bus/i2c/devices/18-0049*temp1_input", + "/sys/bus/i2c/devices/18-004a*temp1_input", + "/sys/bus/i2c/devices/18-004b*temp1_input", + "/sys/bus/i2c/devices/17-004d*temp1_input", + "/sys/bus/i2c/devices/17-004e*temp1_input", + "/sys/bus/i2c/devices/10-005b*psu_temp1_input", + "/sys/bus/i2c/devices/9-0058*psu_temp1_input", +}; +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + + + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "Chassis Thermal Sensor 5", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "Chassis Thermal Sensor 6", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if(tid == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[tid]); +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c new file mode 100644 index 00000000..46c2b302 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(_x) +x86_64_accton_as7816_64x_config_settings_t x86_64_accton_as7816_64x_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_AS7816_64X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7816_64x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE +#undef __x86_64_accton_as7816_64x_config_STRINGIFY_NAME + +const char* +x86_64_accton_as7816_64x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as7816_64x_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_as7816_64x_config_settings[i].name, setting)) { + return x86_64_accton_as7816_64x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as7816_64x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as7816_64x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as7816_64x_config_settings[i].name, x86_64_accton_as7816_64x_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_enums.c new file mode 100644 index 00000000..176be589 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_int.h new file mode 100644 index 00000000..6e818fd9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as7816_64x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7816_64x_INT_H__ +#define __x86_64_accton_as7816_64x_INT_H__ + +#include + + +#endif /* __x86_64_accton_as7816_64x_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.c new file mode 100644 index 00000000..e8f94d69 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7816_64x_log.h" +/* + * x86_64_accton_as7816_64x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS7816_64X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7816_64X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS7816_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.h new file mode 100644 index 00000000..6affb979 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7816_64x_LOG_H__ +#define __x86_64_accton_as7816_64x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as7816_64x +#include + +#endif /* __x86_64_accton_as7816_64x_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_module.c new file mode 100644 index 00000000..bf881cef --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7816_64x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as7816_64x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as7816_64x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_ucli.c new file mode 100644 index 00000000..35afb5c3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as7816_64x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as7816_64x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7816_64x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as7816_64x_ucli_module__ = + { + "x86_64_accton_as7816_64x_ucli", + NULL, + x86_64_accton_as7816_64x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as7816_64x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as7816_64x_ucli_module__); + n = ucli_node_create("x86_64_accton_as7816_64x", NULL, &x86_64_accton_as7816_64x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7816_64x")); + return n; +} + +#else +void* +x86_64_accton_as7816_64x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/PKG.yml new file mode 100644 index 00000000..31d19514 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as7816-64x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/lib/x86-64-accton-as7816-64x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/lib/x86-64-accton-as7816-64x-r0.yml new file mode 100644 index 00000000..9cc40f43 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/lib/x86-64-accton-as7816-64x-r0.yml @@ -0,0 +1,33 @@ +--- + +###################################################################### +# +# platform-config for AS7816 +# +###################################################################### + +x86-64-accton-as7816-64x-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,115200n8 + tg3.short_preamble=1 + tg3.bcm5718s_reset=1 + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py new file mode 100644 index 00000000..67359750 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py @@ -0,0 +1,129 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_64x100): + PLATFORM='x86-64-accton-as7816-64x-r0' + MODEL="AS7816-64x" + SYS_OBJECT_ID=".7816.64" + + def baseconfig(self): + + self.insmod("ym2651y") + self.insmod('accton_i2c_cpld') + self.insmod_platform() + + ########### initialize I2C bus 0 ########### + self.new_i2c_devices([ + # initialize multiplexer (PCA9548) + ('pca9548', 0x77, 0), + + # initiate leaf multiplexer (PCA9548) + ('pca9548', 0x71, 1), + ('pca9548', 0x76, 1), + ('pca9548', 0x73, 1), + + # initiate PSU-1 + ('as7816_64x_psu1', 0x53, 10), + ('ym2851', 0x5b, 10), + + # initiate PSU-2 + ('as7816_64x_psu2', 0x50, 9), + ('ym2851', 0x58, 9), + + # initiate chassis fan + ('as7816_64x_fan', 0x68, 17), + + # inititate LM75 + ('lm75', 0x48, 18), + ('lm75', 0x49, 18), + ('lm75', 0x4a, 18), + ('lm75', 0x4b, 18), + ('lm75', 0x4d, 17), + ('lm75', 0x4e, 17), + + #initiate CPLD + ('accton_i2c_cpld', 0x60, 19), + ('accton_i2c_cpld', 0x62, 20), + ('accton_i2c_cpld', 0x64, 21), + ('accton_i2c_cpld', 0x66, 22), + + # initiate leaf multiplexer (PCA9548) + ('pca9548', 0x70, 2), + ('pca9548', 0x71, 2), + ('pca9548', 0x72, 2), + ('pca9548', 0x73, 2), + ('pca9548', 0x74, 2), + ('pca9548', 0x75, 2), + ('pca9548', 0x76, 2), + + # initialize QSFP port 1-64 + ('as7816_64x_port61', 0x50, 25), + ('as7816_64x_port62', 0x50, 26), + ('as7816_64x_port63', 0x50, 27), + ('as7816_64x_port64', 0x50, 28), + ('as7816_64x_port55', 0x50, 29), + ('as7816_64x_port56', 0x50, 30), + ('as7816_64x_port53', 0x50, 31), + ('as7816_64x_port54', 0x50, 32), + ('as7816_64x_port9', 0x50, 33), + ('as7816_64x_port10', 0x50, 34), + ('as7816_64x_port11', 0x50, 35), + ('as7816_64x_port12', 0x50, 36), + ('as7816_64x_port1', 0x50, 37), + ('as7816_64x_port2', 0x50, 38), + ('as7816_64x_port3', 0x50, 39), + ('as7816_64x_port4', 0x50, 40), + ('as7816_64x_port6', 0x50, 41), + ('as7816_64x_port5', 0x50, 42), + ('as7816_64x_port8', 0x50, 43), + ('as7816_64x_port7', 0x50, 44), + ('as7816_64x_port13', 0x50, 45), + ('as7816_64x_port14', 0x50, 46), + ('as7816_64x_port15', 0x50, 47), + ('as7816_64x_port16', 0x50, 48), + ('as7816_64x_port17', 0x50, 49), + ('as7816_64x_port18', 0x50, 50), + ('as7816_64x_port19', 0x50, 51), + ('as7816_64x_port20', 0x50, 52), + ('as7816_64x_port25', 0x50, 53), + ('as7816_64x_port26', 0x50, 54), + ('as7816_64x_port27', 0x50, 55), + ('as7816_64x_port28', 0x50, 56), + ('as7816_64x_port29', 0x50, 57), + ('as7816_64x_port30', 0x50, 58), + ('as7816_64x_port31', 0x50, 59), + ('as7816_64x_port32', 0x50, 60), + ('as7816_64x_port21', 0x50, 61), + ('as7816_64x_port22', 0x50, 62), + ('as7816_64x_port23', 0x50, 63), + ('as7816_64x_port24', 0x50, 64), + ('as7816_64x_port41', 0x50, 65), + ('as7816_64x_port42', 0x50, 66), + ('as7816_64x_port43', 0x50, 67), + ('as7816_64x_port44', 0x50, 68), + ('as7816_64x_port33', 0x50, 69), + ('as7816_64x_port34', 0x50, 70), + ('as7816_64x_port35', 0x50, 71), + ('as7816_64x_port36', 0x50, 72), + ('as7816_64x_port45', 0x50, 73), + ('as7816_64x_port46', 0x50, 74), + ('as7816_64x_port47', 0x50, 75), + ('as7816_64x_port48', 0x50, 76), + ('as7816_64x_port37', 0x50, 77), + ('as7816_64x_port38', 0x50, 78), + ('as7816_64x_port39', 0x50, 79), + ('as7816_64x_port40', 0x50, 80), + ('as7816_64x_port57', 0x50, 81), + ('as7816_64x_port58', 0x50, 82), + ('as7816_64x_port59', 0x50, 83), + ('as7816_64x_port60', 0x50, 84), + ('as7816_64x_port49', 0x50, 85), + ('as7816_64x_port50', 0x50, 86), + ('as7816_64x_port51', 0x50, 87), + ('as7816_64x_port52', 0x50, 88), + + ('24c02', 0x56, 0), + ]) + + return True From 21e0949a9843494e5d7492a28004c7805a947eec Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 16 Oct 2017 11:36:31 -0700 Subject: [PATCH 043/244] Add weakref wrapper for partially-malloc'd struct data --- .../onlp/module/python/onlp/onlp/aim_weakref.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py index 5c6e7246..e639de57 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py @@ -80,3 +80,17 @@ class AimPointer(ctypes.c_void_p): # XXX roth -- casting may be necessary track_for_finalization(self, aimPtr, self.deletePointer) + +class AimStruct(ctypes.Structure): + """Manage an AIM struct with internally-allocated data.""" + + @classmethod + def deleteStruct(cls, aimPtr): + """Override this with the proper delete semantics.""" + raise NotImplementedError + + def __init__(self): + + super(ctypes.Structure, self).__init__() + + track_for_finalization(self, self, self.deleteStruct) From fe36fc46f813f9d0edd5766f2cda49094de50cbb Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 16 Oct 2017 11:47:17 -0700 Subject: [PATCH 044/244] Switch bitmap and sys_info to use weakrefs --- .../onlp/module/python/onlp/onlp/__init__.py | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py index 9c58179e..d32ce721 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/__init__.py @@ -19,11 +19,6 @@ from onlp.onlp.enums import * # AIM/aim_memory.h -class _aim_void_p(ctypes.c_void_p): - """Generic data allocated by AIM.""" - def __del__(self): - libonlp.aim_free(self) - class aim_void_p(aim_weakref.AimPointer): @classmethod @@ -162,13 +157,18 @@ class aim_bitmap_hdr(ctypes.Structure): class aim_bitmap(ctypes.Structure): _fields_ = [("hdr", aim_bitmap_hdr,),] - @classmethod - def fromAim(cls, bitcount): - """Return a pointer to a bitmap from aim_alloc(). +class aim_bitmap_ref(aim_weakref.AimReference): + """Dynamically allocated aim_bitmap.""" - Pre-initialized; needs to be freed with aim_free(). - """ - return libonlp.aim_bitmap_alloc(None, bitcount) + _fields_ = aim_bitmap._fields_ + + def __init__(self, bitcount): + ptr = libonlp.aim_bitmap_alloc(None, bitcount) + super(aim_bitmap_ref, self).__init__(ptr) + + @classmethod + def deleteReference(self, aimPtr): + libonlp.aim_free(aimPtr) class aim_bitmap256(aim_bitmap): """Statically-allocated AIM bitmap.""" @@ -306,16 +306,19 @@ def onlp_oid_init_prototypes(): # onlp/sys.h -class onlp_sys_info(ctypes.Structure): - - initialized = False +class onlp_sys_info(aim_weakref.AimStruct): _fields_ = [("hdr", onlp_oid_hdr,), ("onie_info", onlp.onlplib.onlp_onie_info,), ("platform_info", onlp.onlplib.onlp_platform_info,),] - def __del__(self): - if self.initialized: + def __init__(self): + self.initialized = False + super(onlp_sys_info, self).__init__() + + def deleteStruct(self): + initialized, self.initialized = self.initialized, False + if initialized: libonlp.onlp_sys_info_free(ctypes.byref(self)) def onlp_sys_init_prototypes(): From ff333b2d5078e36fbebd8d1a436f5f995227ea96 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 16 Oct 2017 19:40:30 +0000 Subject: [PATCH 045/244] The media setting for 1G_BASE_{T,CX} in sff_info_init should be Copper. --- .../base/any/onlp/src/sff/module/src/sff.c | 7 +++- .../base/any/onlp/src/sff/module/src/sff_db.c | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/base/any/onlp/src/sff/module/src/sff.c b/packages/base/any/onlp/src/sff/module/src/sff.c index 45ec110c..bb916944 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff.c +++ b/packages/base/any/onlp/src/sff/module/src/sff.c @@ -765,10 +765,15 @@ sff_info_init(sff_info_t* info, sff_module_type_t mt, case SFF_MODULE_TYPE_1G_BASE_SX: case SFF_MODULE_TYPE_1G_BASE_LX: + info->sfp_type = SFF_SFP_TYPE_SFP; + info->media_type = SFF_MEDIA_TYPE_FIBER; + info->caps = SFF_MODULE_CAPS_F_1G; + break; + case SFF_MODULE_TYPE_1G_BASE_CX: case SFF_MODULE_TYPE_1G_BASE_T: info->sfp_type = SFF_SFP_TYPE_SFP; - info->media_type = SFF_MEDIA_TYPE_FIBER; + info->media_type = SFF_MEDIA_TYPE_COPPER; info->caps = SFF_MODULE_CAPS_F_1G; break; diff --git a/packages/base/any/onlp/src/sff/module/src/sff_db.c b/packages/base/any/onlp/src/sff/module/src/sff_db.c index fa48081c..6249867a 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_db.c +++ b/packages/base/any/onlp/src/sff/module/src/sff_db.c @@ -5,6 +5,9 @@ *****************************************************************************/ #include +#define SFF_1G_BASE_T_PROPERTIES \ + SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_1G_BASE_T, "1GBASE-T", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_1G + #define SFF_1G_BASE_SX_PROPERTIES \ SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_1G_BASE_SX, "1GBASE-SX", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_1G @@ -1565,6 +1568,35 @@ static sff_db_entry_t sff_database__[] = }, }, }, + { + { + .eeprom = { + 0x03, 0x04, 0x22, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x64, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, + 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x43, 0x4c, 0x46, 0x38, 0x35, 0x32, 0x32, + 0x50, 0x32, 0x42, 0x54, 0x4c, 0x2d, 0x44, 0x4c, 0x41, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x33, + 0x00, 0x12, 0x00, 0x00, 0x50, 0x54, 0x4d, 0x33, 0x41, 0x4e, 0x57, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x30, 0x35, 0x32, 0x34, 0x20, 0xff, 0x00, 0x00, 0x00, 0x8c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + }, + .info = { + "FINISAR CORP. ", + "FCLF8522P2BTL-DL", + "PTM3ANW ", + SFF_1G_BASE_T_PROPERTIES, + 100, + }, + }, + }, { { .eeprom = { From 81320398bc13a068fed466deaef8b5faeb92b7ff Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 16 Oct 2017 14:16:48 -0700 Subject: [PATCH 046/244] Clean up logging --- .../any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py index e639de57..27823738 100644 --- a/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py +++ b/packages/base/any/onlp/src/onlp/module/python/onlp/onlp/aim_weakref.py @@ -25,7 +25,6 @@ def _run_finalizer(ref): finalizer = ref.finalizer item = ref.item try: - getLogger().info("finalizing object at %s", item) finalizer(item) except Exception: getLogger().exception("finalizer failed") @@ -39,7 +38,6 @@ def track_for_finalization(owner, item, finalizer): ``finalizer`` will be called with ``item`` as its only argument when ``owner`` is destroyed by the garbage collector. """ - getLogger().info("tracking object at %s", item) ref = AimOwnerRef(owner, _run_finalizer) ref.item = item ref.finalizer = finalizer From ed9a13a10b69946194564ac96dafeb49247d0aea Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Oct 2017 16:08:59 +0000 Subject: [PATCH 047/244] The onlp-snmpd daemon now exports the current utilization via domain socket. --- .../onlp_snmp/module/src/onlp_snmp_platform.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_platform.c b/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_platform.c index c97a3972..8b4aebfa 100644 --- a/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_platform.c +++ b/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_platform.c @@ -259,9 +259,29 @@ us_to_next_update(void) return MIN(period - deltat, period); } +#include + +static int +cpu_utilization_handler__(int fd, void* cookie) +{ + char svalue[64]; + resources_t *curr = get_curr_resources(); + sprintf(svalue, "%d", curr->utilization_percent); + write(fd, svalue, strlen(svalue)); + close(fd); + return 0; +} + static void * do_update(void *arg) { + onlp_file_uds_t* uds; + if(ONLP_SUCCESS(onlp_file_uds_create(&uds))) { + onlp_file_uds_add(uds, + "/var/run/onl/cpu-utilization", + cpu_utilization_handler__, NULL); + } + for (;;) { resource_update(); usleep(us_to_next_update()); From 12116102f132a3b2f97465648682556ae1ac71f0 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Oct 2017 21:22:12 +0000 Subject: [PATCH 048/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 5336dac8..ab1e0396 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 5336dac8f6fb1a602061256d2e0c76e5065d975e +Subproject commit ab1e0396cb725abba9d57c4d2d28993463a38261 From c896d729b01aafaf67b9b37b500e8bf2d82d4436 Mon Sep 17 00:00:00 2001 From: hans Date: Mon, 31 Jul 2017 16:43:43 +0800 Subject: [PATCH 049/244] fixed the relative speed of fan and thermal Signed-off-by: hans Signed-off-by: duobliu1 --- .../onlp/builds/src/module/src/sysi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c index 3695fc17..22214e61 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c @@ -58,27 +58,27 @@ decide_percentage(int *percentage, int temper) { int level; - if(temper <= 25) + if(temper < 65) { - *percentage = 40; + *percentage = 50; level = 0; } - else if(temper > 25 && temper <= 40) + else if(temper >= 65 && temper <= 70) { *percentage = 60; level = 1; } - else if(temper > 40 && temper <= 55) + else if(temper > 70 && temper <= 75) { - *percentage = 80; + *percentage = 70; level = 2; } - else if(temper > 55 && temper <= 75) + else if(temper > 75 && temper <= 80) { - *percentage = 90; + *percentage = 85; level = 3; } - else if(temper > 75) + else if(temper > 80) { *percentage = 100; level = 4; From 4b402202ba7aebb3d62dc7c05c9d9eaf857b23ec Mon Sep 17 00:00:00 2001 From: hans Date: Wed, 16 Aug 2017 10:54:46 +0800 Subject: [PATCH 050/244] 1. fix the pus voltage value 2. modify the shut down thermal temperature Signed-off-by: hans Signed-off-by: duobliu1 --- .../modules/builds/dni_ag5648_psu.c | 7 +++---- .../onlp/builds/src/module/src/thermali.c | 18 ++++++++++++------ .../python/x86_64_delta_ag5648_r0/__init__.py | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c index 6c7a1fa1..eae7970e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c @@ -201,10 +201,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent)); + return (exponent > 0) ? sprintf(buf, "%d\n", \ + mantissa * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c index 7545b743..22448190 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c @@ -38,6 +38,12 @@ } \ } while(0) +#define dni_onlp_thermal_threshold(WARNING_DEFAULT, ERROR_DEFAULT, SHUTDOWN_DEFAULT){ \ + WARNING_DEFAULT, \ + ERROR_DEFAULT, \ + SHUTDOWN_DEFAULT, \ +} + static char* last_path[] = /* must map with onlp_thermal_id */ { "reserved", @@ -70,27 +76,27 @@ static onlp_thermal_info_t linfo[] = { }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(70000,80000,85000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BOARD), "Thermal sensor near DC fan (U334, Middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, ONLP_THERMAL_STATUS_PRESENT, diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py index 490bc6bf..336790ff 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py @@ -48,6 +48,21 @@ class OnlPlatform_x86_64_delta_ag5648_r0(OnlPlatformDelta, os.system("echo 0x04 > /sys/bus/i2c/devices/2-0039/addr") os.system("echo 0x10 > /sys/bus/i2c/devices/2-0039/data") + #set thermal Thigh & Tlow + os.system("echo 80000 > /sys/class/hwmon/hwmon5/temp1_max") + os.system("echo 70000 > /sys/class/hwmon/hwmon6/temp1_max") + os.system("echo 60000 > /sys/class/hwmon/hwmon7/temp1_max") + os.system("echo 85000 > /sys/class/hwmon/hwmon8/temp1_max") + os.system("echo 65000 > /sys/class/hwmon/hwmon9/temp1_max") + os.system("echo 60000 > /sys/class/hwmon/hwmon10/temp1_max") + + os.system("echo 75000 > /sys/class/hwmon/hwmon5/temp1_max_hyst") + os.system("echo 65000 > /sys/class/hwmon/hwmon6/temp1_max_hyst") + os.system("echo 55000 > /sys/class/hwmon/hwmon7/temp1_max_hyst") + os.system("echo 80000 > /sys/class/hwmon/hwmon8/temp1_max_hyst") + os.system("echo 60000 > /sys/class/hwmon/hwmon9/temp1_max_hyst") + os.system("echo 55000 > /sys/class/hwmon/hwmon10/temp1_max_hyst") + return True From b73f7826d40c6aba33fe75ea70baffbb25d95acd Mon Sep 17 00:00:00 2001 From: hans Date: Mon, 25 Sep 2017 17:01:50 +0800 Subject: [PATCH 051/244] 1. Fixed bug: 1.1 shows the correct percentage speed display on fan 1.2 add the shutdown temperature level to the thermal 1.3 show the correct PSU voltage output 1.4 se the correct max fan speed of PSU 1.5 modify the corresponding LED capability Signed-off-by: hans Signed-off-by: duobliu1 --- .../modules/builds/dni_ag9032v1_psu.c | 7 +- .../modules/builds/dni_emc2305.c | 35 +- .../onlp/builds/src/module/src/fani.c | 8 +- .../onlp/builds/src/module/src/ledi.c | 324 +++++++----------- .../onlp/builds/src/module/src/platform_lib.c | 27 ++ .../onlp/builds/src/module/src/platform_lib.h | 2 + .../onlp/builds/src/module/src/sysi.c | 218 +++++++++--- .../onlp/builds/src/module/src/thermali.c | 16 +- .../x86_64_delta_ag9032v1_r0/__init__.py | 16 +- 9 files changed, 381 insertions(+), 272 deletions(-) mode change 100644 => 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c old mode 100644 new mode 100755 index acd64822..8a0da3c7 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c @@ -243,10 +243,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent)); + return (exponent > 0) ? sprintf(buf, "%d\n", \ + mantissa * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_emc2305.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_emc2305.c index aec0b756..77af5d55 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_emc2305.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_emc2305.c @@ -32,6 +32,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf); static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf); +static ssize_t show_fan_percentage(struct device *dev, struct device_attribute *devattr, + char *buf); static ssize_t set_fan(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count); static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *devattr, @@ -98,11 +100,11 @@ static SENSOR_DEVICE_ATTR(fan2_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 1); static SENSOR_DEVICE_ATTR(fan3_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 2); static SENSOR_DEVICE_ATTR(fan4_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 3); static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); -static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 0); -static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 1); -static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 2); -static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 3); -static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 4); +static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 0); +static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 1); +static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 2); +static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 3); +static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan_percentage, set_fan_percentage, 4); static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); @@ -172,6 +174,29 @@ static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *d return count; } +static ssize_t show_fan_percentage(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct emc2305_data *data = i2c_get_clientdata(client); + int val; + int rpm; + int rpm_percentage; + + MUX_SELECT; + + mutex_lock(&data->lock); + val = i2c_smbus_read_word_swapped(client, + EMC2305_REG_FAN_TACH(attr->index)); + mutex_unlock(&data->lock); + /* Left shift 3 bits for showing correct RPM */ + val = val >> 3; + rpm = 3932160 * 2 / (val > 0 ? val : 1); + rpm_percentage = rpm / 230; + return sprintf(buf, "%d\n", rpm_percentage); +} + static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/fani.c index 107e3eb7..b4801ac1 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/fani.c @@ -30,7 +30,7 @@ #include #define MAX_FAN_SPEED 23000 -#define MAX_PSU_FAN_SPEED 19328 +#define MAX_PSU_FAN_SPEED 18380 typedef struct fan_path_S { @@ -60,7 +60,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { \ { ONLP_FAN_ID_CREATE(FAN_##id##_ON_FAN_BOARD), "Chassis Fan "#id, 0 }, \ 0x0, \ - (ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ 0, \ 0, \ ONLP_FAN_MODE_INVALID, \ @@ -70,7 +70,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { \ { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ 0x0, \ - (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + ( ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ 0, \ 0, \ ONLP_FAN_MODE_INVALID, \ @@ -316,7 +316,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) case FAN_8_ON_FAN_BOARD: case FAN_9_ON_FAN_BOARD: case FAN_10_ON_FAN_BOARD: - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed); break; default: return ONLP_STATUS_E_INVALID; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c index 2241fbff..e72f9ab5 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c @@ -53,17 +53,17 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_FRONT_PWR1), "FRONT LED (PWR1 LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_FRONT_PWR2), "FRONT LED (PWR2 LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, @@ -92,34 +92,6 @@ static onlp_led_info_t linfo[] = }, }; -/* Function to check fan 1-10 speed normally*/ -static int dni_fan_speed_good() -{ - int rpm = 0, rpm1 = 0, speed_good = 0; - - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); - if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) - speed_good++; - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); - if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) - speed_good++; - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) - speed_good++; - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); - if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) - speed_good++; - rpm = dni_i2c_lock_read_attribute(NULL, FAN5_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN5_REAR); - if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) - speed_good++; - return speed_good; -} - /* * This function will be called prior to any other onlp_ledi_* functions. @@ -141,6 +113,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) /* Set front panel's mode of leds */ r_data = dni_lock_swpld_read_attribute(LED_REG); int local_id = ONLP_OID_ID_GET(id); + dev_info_t dev_info; dev_info.bus = I2C_BUS_3; dev_info.offset = 0x00; @@ -149,22 +122,29 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) mux_info_t mux_info; mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG; mux_info.flags = DEFAULT_FLAG; + switch(local_id) { case LED_FRONT_FAN: - if((r_data & 0x01) == 0x01) + if((r_data & 0x03) == 0x01) info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x02) == 0x02) + else if((r_data & 0x03) == 0x02) info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0x03) == 0x03 || (r_data & 0x03) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_SYS: - if((r_data & 0x04) == 0x04) + if((r_data & 0x0C) == 0x04) info->mode = ONLP_LED_MODE_GREEN; else if((r_data & 0x0C) == 0x0C) - info->mode = ONLP_LED_MODE_ORANGE; - else if((r_data & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else if((r_data & 0x0C) == 0x08) info->mode = ONLP_LED_MODE_GREEN_BLINKING; - else + else if((r_data & 0x0C) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_PWR1: @@ -289,14 +269,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) int onlp_ledi_set(onlp_oid_t id, int on_or_off) { - VALIDATE(id); -// int local_id = ONLP_OID_ID_GET(id); - if(on_or_off == 0) - onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - else - onlp_ledi_mode_set(id,ONLP_LED_MODE_AUTO); + if (!on_or_off) + { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } - return ONLP_STATUS_OK; + return ONLP_STATUS_E_UNSUPPORTED; } /* @@ -310,210 +288,165 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0; - int state = 0, fantray_present = -1, rpm = 0, rpm1 = 0; - uint8_t front_panel_led_value, power_state,fan_tray_led_reg_value,fan_tray_led_reg_2_value; + uint8_t front_panel_led_value, fan_tray_led_reg_value,fan_tray_led_reg_2_value; - mux_info_t mux_info; - mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG; - mux_info.flags = DEFAULT_FLAG; - - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; - - front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG); fan_tray_led_reg_value = dni_lock_swpld_read_attribute(FAN_TRAY_LED_REG); - fan_tray_led_reg_2_value = dni_lock_swpld_read_attribute(FAN_TRAY_LED_REG_2); - switch(local_id) - { - case LED_FRONT_FAN: + fan_tray_led_reg_2_value = dni_lock_swpld_read_attribute(FAN_TRAY_LED_REG_2); + switch(local_id) + { + case LED_FRONT_FAN: /* Clean the bit 1,0 */ + front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG); front_panel_led_value &= ~0x3; - /* Read fan eeprom to check present. Fan tray 1-5 */ - for(i = 0; i < 5; i++) + if(mode == ONLP_LED_MODE_GREEN) { - 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) - count++; + front_panel_led_value |= 0x01; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST && dni_fan_speed_good() == FAN_SPEED_NORMALLY) - { - front_panel_led_value |= 0x01; - dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); - } - else + else if(mode == ONLP_LED_MODE_ORANGE) { front_panel_led_value |= 0x02; dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); } - - break; - case LED_FRONT_PWR1: - /* Clean bit 7,6 */ - front_panel_led_value &= ~0xC0; - /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_4; - dev_info.addr = PSU_EEPROM; - mux_info.channel = 0x00; - state = dni_i2c_lock_read(&mux_info, &dev_info); - - /* Check the state of PSU 1, "state = 1, PSU exists' */ - if(state == 1) - { - power_state = dni_lock_swpld_read_attribute(CTL_REG); - /* Set the light of PSU */ - if((power_state&0x80) != 0x80) - { - /* Red */ - front_panel_led_value |= 0x80; - dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); - } - else if((power_state & 0x80) == 0x80) - { - /* Green */ - front_panel_led_value |= 0x40; - dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); - } - } else dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); break; + case LED_FRONT_PWR1: + /* Clean bit 7,6 */ + front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG); + front_panel_led_value &= ~0xC0; + if(mode == ONLP_LED_MODE_GREEN) + { + /* Green */ + front_panel_led_value |= 0x40; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); + } + 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); + } + else if(mode == ONLP_LED_MODE_OFF) + { + front_panel_led_value &= ~0xC0; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); + } + else + return ONLP_STATUS_E_UNSUPPORTED; + break; case LED_FRONT_PWR2: - /* Set front light of PSU 2 */ /* Clean bit 5,4 */ + front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG); front_panel_led_value &= ~0x30; - /* switch CPLD to PSU 2 */ - dev_info.bus = I2C_BUS_4; - dev_info.addr = PSU_EEPROM; - mux_info.channel = 0x20; - state = dni_i2c_lock_read(&mux_info, &dev_info); - - /* Check the state of PSU 2, "state = 1, PSU exists' */ - if(state == 1) + if(mode == ONLP_LED_MODE_GREEN) { - power_state = dni_lock_swpld_read_attribute(CTL_REG); - if((power_state & 0x40) != 0x40) - { - /* Red */ - front_panel_led_value |= 0x20; - dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); - } - else if((power_state & 0x40) == 0x40) - { - /* Green */ - front_panel_led_value |= 0x10; - dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); - } + /* Green */ + front_panel_led_value |= 0x10; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); + } + 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); + } + else if(mode == ONLP_LED_MODE_OFF) + { + front_panel_led_value &= ~0x30; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); + } + else + return ONLP_STATUS_E_UNSUPPORTED; + break; + + case LED_FRONT_SYS: + front_panel_led_value = dni_lock_swpld_read_attribute(LED_REG); + front_panel_led_value &= ~0x0C; + if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x08; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); + } + else if (mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x04; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); + } + else if (mode == ONLP_LED_MODE_RED) + { + front_panel_led_value |= 0x0c; + dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); } else dni_lock_swpld_write_attribute(LED_REG, front_panel_led_value); break; + case LED_REAR_FAN_TRAY_1: - /* Select fan tray 1 */ - mux_info.channel = 0x00; - dev_info.addr = FAN_TRAY_1; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - /* Clean bit 7,6 */ - fan_tray_led_reg_value &= ~0xC0; - 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 ) - {/* Green light */ - fan_tray_led_reg_value |= 0x40; - dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } - else - {/* Red light */ + fan_tray_led_reg_value &= ~0xC0; + 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); + } + else + {/* Red light */ fan_tray_led_reg_value |= 0x80; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } - break; + } + break; case LED_REAR_FAN_TRAY_2: - /* Select fan tray 2 */ - mux_info.channel = 0x01; - dev_info.addr = FAN_TRAY_2; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - /* Clean bit 5,4 */ fan_tray_led_reg_value &= ~0x30; - 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(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); } else - { - fan_tray_led_reg_value |= 0x20; - dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); + {/* Red light */ + fan_tray_led_reg_value |= 0x20; + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } break; case LED_REAR_FAN_TRAY_3: - /* Select 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_led_reg_value &= ~0x0c; - /* Clean bit 3,2 */ - 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(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); } else - { - fan_tray_led_reg_value |= 0x08; - dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); + {/* Red light */ + fan_tray_led_reg_value |= 0x08; + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } break; case LED_REAR_FAN_TRAY_4: - /* Select fan tray 4 */ - mux_info.channel = 0x03; - dev_info.addr = FAN_TRAY_4; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - /* Clean bit 1,0 */ fan_tray_led_reg_value &= ~0x03; - 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(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); } else - { + {/* Red light */ fan_tray_led_reg_value |= 0x02; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } break; - case LED_REAR_FAN_TRAY_5: - /* Select fan tray 5 */ - mux_info.channel = 0x04; - dev_info.addr = FAN_TRAY_5; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - /* Clean bit 7,6 */ - fan_tray_led_reg_2_value &= ~0xC0; - 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 ) - { + 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); - } - else - { + } + else + {/* 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); - } - break; + } + break; } return ONLP_STATUS_OK; } @@ -526,6 +459,3 @@ onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) { return ONLP_STATUS_E_UNSUPPORTED; } - - - diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.c index 27f9850c..743806ad 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.c @@ -36,6 +36,33 @@ #include #include +int dni_fan_speed_good() +{ + int rpm = 0, rpm1 = 0, speed_good = 0; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) + speed_good++; + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) + speed_good++; + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) + speed_good++; + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) + speed_good++; + rpm = dni_i2c_lock_read_attribute(NULL, FAN5_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN5_REAR); + if(rpm != 0 && rpm != 960 && rpm1 != 0 && rpm1 != 960) + speed_good++; + return speed_good; +} + int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, int data_len) { int fd; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.h index ea48e364..ff9f57a4 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/platform_lib.h @@ -168,6 +168,8 @@ 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_fan_speed_good(); + typedef enum { diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/sysi.c index 2588c1a3..9d5d2d7d 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/sysi.c @@ -210,66 +210,174 @@ onlp_sysi_platform_manage_leds(void) { /* Set front lights: fan, power supply 1, 2 */ - uint8_t addr, present_bit = 0x00, bit = 0x00; - - addr = dni_lock_swpld_read_attribute(LED_REG); - /* Turn the fan led on or off */ - if((addr & 0x3) == 0 || (addr & 0x3) == 0x3 ) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); - - /* Set front light of PSU 1 */ - addr = dni_lock_swpld_read_attribute(LED_REG); - - if((addr & 0xC0) == 0 || (addr & 0xC0) == 0xC0 ) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), TURN_ON); - - /* Set front light of PSU 2 */ - addr = dni_lock_swpld_read_attribute(LED_REG); - if((addr & 0x30) == 0 || (addr & 0x30) == 0x30 ) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), TURN_ON); - - /* Rear light fan tray 1-5 */ - 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; - + int fantray_present = -1, rpm, rpm1,i=0,count=0, state; + uint8_t power_state; mux_info_t mux_info; mux_info.offset = SWPLD_PSU_FAN_I2C_MUX_REG; mux_info.flags = DEFAULT_FLAG; - mux_info.channel = 0x07; - - /* Turn on or off the fan trays' leds */ - present_bit = dni_i2c_lock_read(&mux_info, &dev_info); - if((present_bit & ((bit+1)<<4)) == 0) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); - if((present_bit & ((bit+1)<<3)) == 0) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); - if((present_bit & ((bit+1)<<2)) == 0) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); - if((present_bit & ((bit+1)<<1)) == 0) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); - else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); - if((present_bit & ((bit+1)<<0)) == 0) - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5), TURN_OFF); + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + + /* 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 ) + {/* Green light */ + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); + } else - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5), TURN_ON); + {/* Red light */ + + 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); + + 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 ) + {/* Green light */ + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); + } + else + {/* Red light */ + + 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); + + 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 ) + {/* Green light */ + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); + } + else + {/* Red light */ + + 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); + + 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 ) + {/* Green light */ + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); + } + else + {/* Red light */ + + 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); + + 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 ) + {/* Green light */ + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5),ONLP_LED_MODE_GREEN); + } + else + {/* Red light */ + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5),ONLP_LED_MODE_RED); + } + + /* 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) + count++; + } + /* Set front light of FAN */ + if(count == ALL_FAN_TRAY_EXIST && dni_fan_speed_good() == FAN_SPEED_NORMALLY) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_GREEN); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), ONLP_LED_MODE_GREEN); + } + else + { + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_ORANGE); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), ONLP_LED_MODE_RED); + } + /* Set front light of PWR1 */ + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; + state = dni_i2c_lock_read(&mux_info, &dev_info); + + /* Check the state of PSU 1, "state = 1, PSU exists' */ + if(state == 1) + { + power_state = dni_lock_swpld_read_attribute(CTL_REG); + /* Set the light of PSU */ + if((power_state&0x80) != 0x80) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), ONLP_LED_MODE_ORANGE_BLINKING); + } + else if((power_state & 0x80) == 0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), ONLP_LED_MODE_GREEN); + } + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR1), ONLP_LED_MODE_OFF); + /* Set front light of PWR1 */ + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x20; + state = dni_i2c_lock_read(&mux_info, &dev_info); + + /* Check the state of PSU 2, "state = 1, PSU exists' */ + if(state == 1) + { + power_state = dni_lock_swpld_read_attribute(CTL_REG); + /* Set the light of PSU */ + if((power_state&0x40) != 0x40) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), ONLP_LED_MODE_ORANGE_BLINKING); + } + else if((power_state & 0x40) == 0x40) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), ONLP_LED_MODE_GREEN); + } + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR2), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } - diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/thermali.c index 1e013d6e..0e898e72 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/thermali.c @@ -38,6 +38,12 @@ } \ } while(0) +#define dni_onlp_thermal_threshold(WARNING_DEFAULT, ERROR_DEFAULT, SHUTDOWN_DEFAULT){ \ + WARNING_DEFAULT, \ + ERROR_DEFAULT, \ + SHUTDOWN_DEFAULT, \ +} + static char* last_path[] = /* must map with onlp_thermal_id */ { "reserved", @@ -69,23 +75,23 @@ static onlp_thermal_info_t linfo[] = { }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "CPU below side thermal sensor (U57, Below of CPU)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Wind thermal sensor (U334, Near FAN)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_SW_BOARD), "MAC up side thermal sersor (U38, up side of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_SW_BOARD), "MAC down side thermal sensor (U40, down side of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(60000,70000,75000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_SW_BOARD), "Surroundings thermal sensor (U240, Near front panel)", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, ONLP_THERMAL_STATUS_PRESENT, diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/platform-config/r0/src/python/x86_64_delta_ag9032v1_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/platform-config/r0/src/python/x86_64_delta_ag9032v1_r0/__init__.py index 84ef7d64..c05b40a8 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/platform-config/r0/src/python/x86_64_delta_ag9032v1_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/platform-config/r0/src/python/x86_64_delta_ag9032v1_r0/__init__.py @@ -41,8 +41,20 @@ class OnlPlatform_x86_64_delta_ag9032v1_r0(OnlPlatformDelta, self.new_i2c_device('tmp75', 0x4f, 3) #Insert sfp module - self.insmod('dni_ag9032v1_sfp') - self.new_i2c_device('dni_ag9032v1_sfp', 0x50, 5) + self.insmod('dni_ag9032v1_sfp') + self.new_i2c_device('dni_ag9032v1_sfp', 0x50, 5) + + #set thermal Thigh & Tlow + os.system("echo 60000 > /sys/class/hwmon/hwmon4/temp1_max") + os.system("echo 65000 > /sys/class/hwmon/hwmon8/temp1_max") + os.system("echo 80000 > /sys/class/hwmon/hwmon5/temp1_max") + os.system("echo 75000 > /sys/class/hwmon/hwmon6/temp1_max") + os.system("echo 65000 > /sys/class/hwmon/hwmon7/temp1_max") + os.system("echo 55000 > /sys/class/hwmon/hwmon4/temp1_max_hyst") + os.system("echo 60000 > /sys/class/hwmon/hwmon8/temp1_max_hyst") + os.system("echo 75000 > /sys/class/hwmon/hwmon5/temp1_max_hyst") + os.system("echo 70000 > /sys/class/hwmon/hwmon6/temp1_max_hyst") + os.system("echo 60000 > /sys/class/hwmon/hwmon7/temp1_max_hyst") #set front panel sys light "GREEN" os.system("echo 0x1C > /sys/bus/i2c/devices/6-0031/addr") From f877fd216fa2209eae5620833b3cefd2636dee89 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 25 Oct 2017 22:28:19 +0000 Subject: [PATCH 052/244] Add F4M-QSSFP-C-2-30. Conflicts: packages/base/any/onlp/src/sff/module/src/sff_db.c --- .../any/onlp/src/sff/module/src/nonstandard.c | 1 + .../base/any/onlp/src/sff/module/src/sff_db.c | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/packages/base/any/onlp/src/sff/module/src/nonstandard.c b/packages/base/any/onlp/src/sff/module/src/nonstandard.c index 4b1da720..b512ffe2 100644 --- a/packages/base/any/onlp/src/sff/module/src/nonstandard.c +++ b/packages/base/any/onlp/src/sff/module/src/nonstandard.c @@ -17,6 +17,7 @@ static sff_ns_entry_t nonstandard_modules__[] = { "CISCO-OEM ", "QSFP-4SFP+-CU3M ", SFF_MODULE_TYPE_40G_BASE_CR4, 3 }, { "CISCO-OEM ", "QSFP-4SFP+-CU5M ", SFF_MODULE_TYPE_40G_BASE_CR4, 5 }, { "Mellanox ", "MC2206130-001 ", SFF_MODULE_TYPE_40G_BASE_CR4, 1 }, + { "OEM ", "F4M-QSSFP-C-2-30", SFF_MODULE_TYPE_40G_BASE_CR4, 2 }, {}, }; diff --git a/packages/base/any/onlp/src/sff/module/src/sff_db.c b/packages/base/any/onlp/src/sff/module/src/sff_db.c index 6249867a..095aecdb 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_db.c +++ b/packages/base/any/onlp/src/sff/module/src/sff_db.c @@ -1626,6 +1626,64 @@ static sff_db_entry_t sff_database__[] = }, }, }, + { + { + .eeprom = { + 0x0d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x43, 0x4d, 0x50, 0x51, 0x41, 0x41, 0x31, 0x43, 0x41, 0x41, 0x33, 0x37, 0x2d, 0x31, + 0x33, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x56, 0x30, 0x32, 0x20, 0x51, 0x53, 0x46, 0x50, 0x2d, 0xe6, + 0x53, 0x46, 0x50, 0x31, 0x30, 0x47, 0x2d, 0x43, 0x55, 0x32, 0x4d, 0x20, 0x20, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0xa0, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x46, 0x34, 0x4d, 0x2d, 0x51, 0x53, 0x53, 0x46, + 0x50, 0x2d, 0x43, 0x2d, 0x32, 0x2d, 0x33, 0x30, 0x41, 0x20, 0x09, 0x0d, 0x00, 0x00, 0x46, 0x8f, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x45, 0x31, 0x36, 0x30, 0x34, 0x30, 0x39, 0x32, 0x33, 0x33, 0x33, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x30, 0x34, 0x30, 0x38, 0x20, 0x20, 0x00, 0x00, 0xe2, 0x60, + 0x00, 0x00, 0x11, 0x92, 0x93, 0x56, 0x08, 0x23, 0xce, 0x3b, 0x71, 0x35, 0xac, 0x37, 0xdc, 0x38, + 0x1d, 0x13, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x36, 0xa4, 0x00, + }, + .info = { + "OEM ", + "F4M-QSSFP-C-2-30", + "GE1604092333 ", + SFF_40G_BASE_CR4_PROPERTIES, + 2, + }, + }, + }, + { + { + .eeprom = { + 0x0d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x43, 0x4d, 0x50, 0x51, 0x41, 0x41, 0x31, 0x43, 0x41, 0x41, 0x33, 0x37, 0x2d, 0x31, + 0x33, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x56, 0x30, 0x32, 0x20, 0x51, 0x53, 0x46, 0x50, 0x2d, 0xe6, + 0x53, 0x46, 0x50, 0x31, 0x30, 0x47, 0x2d, 0x43, 0x55, 0x31, 0x4d, 0x20, 0x20, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0xa0, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x48, 0x34, 0x30, + 0x47, 0x2d, 0x43, 0x55, 0x31, 0x4d, 0x2d, 0x43, 0x41, 0x20, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7a, + 0x00, 0x00, 0x00, 0x00, 0x45, 0x31, 0x36, 0x31, 0x31, 0x31, 0x36, 0x30, 0x30, 0x36, 0x37, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x31, 0x32, 0x30, 0x32, 0x20, 0x20, 0x00, 0x00, 0xe2, 0x30, + 0x00, 0x00, 0x11, 0xbc, 0xb2, 0x5f, 0x4b, 0xf4, 0x39, 0x79, 0xf6, 0xca, 0xb9, 0x62, 0xf7, 0x4c, + 0x14, 0xd8, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0xc5, 0xef, 0x53, + }, + .info = { + "OEM ", + "QSFP-H40G-CU1M-C", + "E1611160067 ", + SFF_40G_BASE_CR4_PROPERTIES, + 1, + }, + }, + }, #endif /** SFF_CONFIG_INCLUDE_DATABASE */ }; From e74f5db634b553b83c62aa699697a6962f446d76 Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Tue, 24 Oct 2017 10:08:10 +0800 Subject: [PATCH 053/244] Add Support for QuantaMesh T3048-LY7: 1. Add class OnlPlatformPortConfig_48x10_4x100 at base.py 2. Port LY7 platform driver 3. Port LY7 ONLP: board info 4. Port LY7 ONLP: system led 5. Port LY7 ONLP: sfp 6. Set SYS_OBJECT_ID as ".3048.2700" --- .../src/python/onl/platform/base.py | 4 + .../x86-64-quanta-ly7-rglbmc/.gitignore | 2 + .../x86-64/x86-64-quanta-ly7-rglbmc/Makefile | 1 + .../x86-64-quanta-ly7-rglbmc/modules/Makefile | 1 + .../x86-64-quanta-ly7-rglbmc/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../modules/builds/quanta_platform_ly7.c | 403 +++++++++++++++++ .../x86-64-quanta-ly7-rglbmc/onlp/Makefile | 1 + .../x86-64-quanta-ly7-rglbmc/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++ .../onlp/builds/onlpdump/Makefile | 45 ++ .../src/x86_64_quanta_ly7_rglbmc/.module | 1 + .../src/x86_64_quanta_ly7_rglbmc/Makefile | 9 + .../module/auto/make.mk | 9 + .../module/auto/x86_64_quanta_ly7_rglbmc.yml | 134 ++++++ .../x86_64_quanta_ly7_rglbmc.x | 14 + .../x86_64_quanta_ly7_rglbmc_config.h | 167 +++++++ .../x86_64_quanta_ly7_rglbmc_dox.h | 26 ++ .../x86_64_quanta_ly7_rglbmc_gpio_table.h | 39 ++ .../x86_64_quanta_ly7_rglbmc_porting.h | 87 ++++ .../x86_64_quanta_ly7_rglbmc/module/make.mk | 10 + .../module/src/Makefile | 9 + .../module/src/fani.c | 31 ++ .../module/src/ledi.c | 78 ++++ .../module/src/make.mk | 9 + .../module/src/psui.c | 15 + .../module/src/sfpi.c | 409 ++++++++++++++++++ .../module/src/sysi.c | 66 +++ .../module/src/thermali.c | 31 ++ .../src/x86_64_quanta_ly7_rglbmc_config.c | 95 ++++ .../src/x86_64_quanta_ly7_rglbmc_enums.c | 10 + .../module/src/x86_64_quanta_ly7_rglbmc_int.h | 281 ++++++++++++ .../module/src/x86_64_quanta_ly7_rglbmc_log.c | 18 + .../module/src/x86_64_quanta_ly7_rglbmc_log.h | 12 + .../src/x86_64_quanta_ly7_rglbmc_module.c | 24 + .../src/x86_64_quanta_ly7_rglbmc_ucli.c | 50 +++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-quanta-ly7-rglbmc-r0.yml | 31 ++ .../x86_64_quanta_ly7_rglbmc_r0/__init__.py | 22 + 43 files changed, 2203 insertions(+) create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml create mode 100755 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index 026aed28..170f1eac 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -482,6 +482,10 @@ class OnlPlatformPortConfig_48x10_6x40(object): PORT_COUNT=54 PORT_CONFIG="48x10 + 6x40" +class OnlPlatformPortConfig_48x10_4x100(object): + PORT_COUNT=52 + PORT_CONFIG="48x10 + 4x100" + class OnlPlatformPortConfig_48x25_6x100(object): PORT_COUNT=54 PORT_CONFIG="48x25 + 6x100" diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore new file mode 100755 index 00000000..60f9dd9d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore @@ -0,0 +1,2 @@ +*x86*64*quanta*ly7*rglbmc.mk +onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml new file mode 100755 index 00000000..7f33b579 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly7-rglbmc KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore new file mode 100755 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile new file mode 100755 index 00000000..aec5bb59 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := quanta +BASENAME := x86-64-quanta-ly7-rglbmc +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c new file mode 100755 index 00000000..2efdfab3 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c @@ -0,0 +1,403 @@ +/* + * Quanta LY7 platform driver + * + * + * Copyright (C) 2017 Quanta Computer inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)) +#include +#else +#include +#endif + +#define MUX_INFO(bus, deselect) \ + {.adap_id = bus, .deselect_on_exit = deselect} + +static struct pca954x_platform_mode pca9548sfp1_modes[] = { + MUX_INFO(0x20, 1), + MUX_INFO(0x21, 1), + MUX_INFO(0x22, 1), + MUX_INFO(0x23, 1), + MUX_INFO(0x24, 1), + MUX_INFO(0x25, 1), + MUX_INFO(0x26, 1), + MUX_INFO(0x27, 1), +}; + +static struct pca954x_platform_data pca9548sfp1_data = { + .modes = pca9548sfp1_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp2_modes[] = { + MUX_INFO(0x28, 1), + MUX_INFO(0x29, 1), + MUX_INFO(0x2a, 1), + MUX_INFO(0x2b, 1), + MUX_INFO(0x2c, 1), + MUX_INFO(0x2d, 1), + MUX_INFO(0x2e, 1), + MUX_INFO(0x2f, 1), +}; + +static struct pca954x_platform_data pca9548sfp2_data = { + .modes = pca9548sfp2_modes, + .num_modes = 8, +}; +static struct pca954x_platform_mode pca9548sfp3_modes[] = { + MUX_INFO(0x30, 1), + MUX_INFO(0x31, 1), + MUX_INFO(0x32, 1), + MUX_INFO(0x33, 1), + MUX_INFO(0x34, 1), + MUX_INFO(0x35, 1), + MUX_INFO(0x36, 1), + MUX_INFO(0x37, 1), +}; + +static struct pca954x_platform_data pca9548sfp3_data = { + .modes = pca9548sfp3_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp4_modes[] = { + MUX_INFO(0x38, 1), + MUX_INFO(0x39, 1), + MUX_INFO(0x3a, 1), + MUX_INFO(0x3b, 1), + MUX_INFO(0x3c, 1), + MUX_INFO(0x3d, 1), + MUX_INFO(0x3e, 1), + MUX_INFO(0x3f, 1), +}; + +static struct pca954x_platform_data pca9548sfp4_data = { + .modes = pca9548sfp4_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp5_modes[] = { + MUX_INFO(0x40, 1), + MUX_INFO(0x41, 1), + MUX_INFO(0x42, 1), + MUX_INFO(0x43, 1), + MUX_INFO(0x44, 1), + MUX_INFO(0x45, 1), + MUX_INFO(0x46, 1), + MUX_INFO(0x47, 1), +}; + +static struct pca954x_platform_data pca9548sfp5_data = { + .modes = pca9548sfp5_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp6_modes[] = { + MUX_INFO(0x48, 1), + MUX_INFO(0x49, 1), + MUX_INFO(0x4a, 1), + MUX_INFO(0x4b, 1), + MUX_INFO(0x4c, 1), + MUX_INFO(0x4d, 1), + MUX_INFO(0x4e, 1), + MUX_INFO(0x4f, 1), +}; + +static struct pca954x_platform_data pca9548sfp6_data = { + .modes = pca9548sfp6_modes, + .num_modes = 8, +}; + +//ZQSFP +static struct pca954x_platform_mode pca9548sfp7_modes[] = { + MUX_INFO(0x50, 1), + MUX_INFO(0x51, 1), + MUX_INFO(0x52, 1), + MUX_INFO(0x53, 1), + MUX_INFO(0x54, 1), + MUX_INFO(0x55, 1), + MUX_INFO(0x56, 1), + MUX_INFO(0x57, 1), +}; + +static struct pca954x_platform_data pca9548sfp7_data = { + .modes = pca9548sfp7_modes, + .num_modes = 8, +}; + +// end port + +static struct pca954x_platform_mode pca9546_modes[] = { + MUX_INFO(0x10, 1), + MUX_INFO(0x11, 1), + MUX_INFO(0x12, 1), + MUX_INFO(0x13, 1), +}; + +static struct pca954x_platform_data pca9546_data = { + .modes = pca9546_modes, + .num_modes = 4, +}; + +static struct pca954x_platform_mode pca9548_modes[] = { + MUX_INFO(0x14, 1), + MUX_INFO(0x15, 1), + MUX_INFO(0x16, 1), + MUX_INFO(0x17, 1), + MUX_INFO(0x18, 1), + MUX_INFO(0x19, 1), + MUX_INFO(0x1a, 1), + MUX_INFO(0x1b, 1), +}; + +static struct pca954x_platform_data pca9548_data = { + .modes = pca9548_modes, + .num_modes = 8, +}; + +/* CPU Board i2c device */ +static struct pca954x_platform_mode pca9546_cpu_modes[] = { + MUX_INFO(0x02, 1), + MUX_INFO(0x03, 1), + MUX_INFO(0x04, 1), + MUX_INFO(0x05, 1), +}; + +static struct pca954x_platform_data pca9546_cpu_data = { + .modes = pca9546_cpu_modes, + .num_modes = 4, +}; +//MB Board Data +static struct pca953x_platform_data pca9555_1_data = { + .gpio_base = 0x10, +}; +//QSFP28 49-52 IO Expander +static struct pca953x_platform_data pca9698_2_data = { + .gpio_base = 0x20, +}; +//CPU Board pca9555 +static struct pca953x_platform_data pca9555_CPU_data = { + .gpio_base = 0x40, +}; +static struct i2c_board_info ly7_i2c_devices[] = { + { + I2C_BOARD_INFO("pca9546", 0x72), // 0 + .platform_data = &pca9546_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x77), // 1 + .platform_data = &pca9548_data, + }, + { + I2C_BOARD_INFO("24c02", 0x54), // 2 eeprom + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 3 0x77 ch0 + .platform_data = &pca9548sfp1_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 4 0x77 ch1 + .platform_data = &pca9548sfp2_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 5 0x77 ch2 + .platform_data = &pca9548sfp3_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 6 0x77 ch3 + .platform_data = &pca9548sfp4_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 7 0x77 ch4 + .platform_data = &pca9548sfp5_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 8 0x77 ch5 + .platform_data = &pca9548sfp6_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 9 0x77 ch6 + .platform_data = &pca9548sfp7_data, + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 10 0x72 ch0 CPLD1_:SFP28 1~16 + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 11 0x72 ch1 CPLD2_:SFP28 17~32 + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 12 0x72 ch2 CPLD_3:SFP28 33~48 + }, + { + I2C_BOARD_INFO("pca9555", 0x23), // 13 0x72 ch3 MB Board Data + .platform_data = &pca9555_1_data, + }, + { + I2C_BOARD_INFO("pca9698", 0x21), // 14 0x72 ch3 QSFP:49~52 + .platform_data = &pca9698_2_data, + }, + { + I2C_BOARD_INFO("24c02", 0x50), // 15 0x50 SFP28, QSFP EEPROM + }, + { + I2C_BOARD_INFO("pca9546", 0x71), // 16 + .platform_data = &pca9546_cpu_data, + }, + { + I2C_BOARD_INFO("pca9555", 0x20), // 17 0x71 ch0 CPU Board Data + .platform_data = &pca9555_CPU_data, + }, +}; + +static struct platform_driver ly7_platform_driver = { + .driver = { + .name = "qci-ly7", + .owner = THIS_MODULE, + }, +}; + +static struct platform_device *ly7_device; + +static int __init ly7_platform_init(void) +{ + struct i2c_client *client; + struct i2c_adapter *adapter; + int ret, i; + + ret = platform_driver_register(&ly7_platform_driver); + if (ret < 0) + return ret; + + /* Register platform stuff */ + ly7_device = platform_device_alloc("qci-ly7", -1); + if (!ly7_device) { + ret = -ENOMEM; + goto fail_platform_driver; + } + + ret = platform_device_add(ly7_device); + if (ret) + goto fail_platform_device; + + adapter = i2c_get_adapter(0); + client = i2c_new_device(adapter, &ly7_i2c_devices[0]); // pca9546 + client = i2c_new_device(adapter, &ly7_i2c_devices[1]); // pca9548 + client = i2c_new_device(adapter, &ly7_i2c_devices[16]); // pca9546cpu + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x02); + client = i2c_new_device(adapter, &ly7_i2c_devices[17]); // CPU Board Data + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x10); + client = i2c_new_device(adapter, &ly7_i2c_devices[10]); // CPLD_1 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x11); + client = i2c_new_device(adapter, &ly7_i2c_devices[11]); // CPLD_2 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x12); + client = i2c_new_device(adapter, &ly7_i2c_devices[12]); // CPLD_3 + client = i2c_new_device(adapter, &ly7_i2c_devices[2]); // MB_BOARDINFO_EEPROM + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x13); + client = i2c_new_device(adapter, &ly7_i2c_devices[13]); // MB Board Data + client = i2c_new_device(adapter, &ly7_i2c_devices[14]); // QSFP:49~52 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x14); + client = i2c_new_device(adapter, &ly7_i2c_devices[3]); // pca9548_1 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x15); + client = i2c_new_device(adapter, &ly7_i2c_devices[4]); // pca9548_2 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x16); + client = i2c_new_device(adapter, &ly7_i2c_devices[5]); // pca9548_3 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x17); + client = i2c_new_device(adapter, &ly7_i2c_devices[6]); // pca9548_4 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x18); + client = i2c_new_device(adapter, &ly7_i2c_devices[7]); // pca9548_5 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x19); + client = i2c_new_device(adapter, &ly7_i2c_devices[8]); // pca9548_6 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x1a); + client = i2c_new_device(adapter, &ly7_i2c_devices[9]); // pca9548_7 QSFP + i2c_put_adapter(adapter); + + for(i = 32; i < 84; i ++){ // SFP28 1~48 & QSFP 49~52 EEPROM + adapter = i2c_get_adapter(i); + client = i2c_new_device(adapter, &ly7_i2c_devices[15]); + i2c_put_adapter(adapter); + } + + return 0; + +fail_platform_device: + platform_device_put(ly7_device); + +fail_platform_driver: + platform_driver_unregister(&ly7_platform_driver); + return ret; +} + +static void __exit ly7_platform_exit(void) +{ + platform_device_unregister(ly7_device); + platform_driver_unregister(&ly7_platform_driver); +} + +module_init(ly7_platform_init); +module_exit(ly7_platform_exit); + + +MODULE_AUTHOR("Jonathan Tsai "); +MODULE_VERSION("1.0"); +MODULE_DESCRIPTION("Quanta LY7 Platform Driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml new file mode 100755 index 00000000..76467669 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-quanta-ly7-rglbmc ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile new file mode 100755 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile new file mode 100755 index 00000000..3cd4efa5 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-quanta-ly7-rglbmc +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_quanta_ly7_rglbmc quanta_sys_eeprom onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-quanta-ly7-rglbmc.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..f50697a1 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_quanta_ly7_rglbmc quanta_sys_eeprom onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module new file mode 100755 index 00000000..f225e551 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module @@ -0,0 +1 @@ +name: x86_64_quanta_ly7_rglbmc diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile new file mode 100755 index 00000000..d36660de --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_quanta_ly7_rglbmc +AUTOMODULE := x86_64_quanta_ly7_rglbmc +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk new file mode 100755 index 00000000..3c19c01d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_quanta_ly7_rglbmc Autogeneration +# +############################################################################### +x86_64_quanta_ly7_rglbmc_AUTO_DEFS := module/auto/x86_64_quanta_ly7_rglbmc.yml +x86_64_quanta_ly7_rglbmc_AUTO_DIRS := module/inc/x86_64_quanta_ly7_rglbmc module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml new file mode 100755 index 00000000..5d056542 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml @@ -0,0 +1,134 @@ +############################################################################### +# +# x86_64_quanta_ly7_rglbmc Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: + doc: "RPM Threshold at which the fan is considered to have failed." + default: 3000 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX: + doc: "Maximum system front-to-back fan speed." + default: 18000 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX: + doc: "Maximum system back-to-front fan speed." + default: 18000 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS: + doc: "Time to hold Phy GPIO in reset, in ms" + default: 100 + +definitions: + cdefs: + X86_64_QUANTA_LY7_RGLBMC_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_quanta_ly7_rglbmc_config + + enum: &enums + + fan_id: + members: + - FAN1 : 1 + - FAN2 : 2 + - FAN3 : 3 + - FAN4 : 4 + - FAN5 : 5 + - FAN6 : 6 + - FAN7 : 7 + - FAN8 : 8 + - FAN9 : 9 + - FAN10 : 10 + + fan_oid: + members: + - FAN1 : ONLP_FAN_ID_CREATE(1) + - FAN2 : ONLP_FAN_ID_CREATE(2) + - FAN3 : ONLP_FAN_ID_CREATE(3) + - FAN4 : ONLP_FAN_ID_CREATE(4) + - FAN5 : ONLP_FAN_ID_CREATE(5) + - FAN6 : ONLP_FAN_ID_CREATE(6) + - FAN7 : ONLP_FAN_ID_CREATE(7) + - FAN8 : ONLP_FAN_ID_CREATE(8) + - FAN9 : ONLP_FAN_ID_CREATE(9) + - FAN10 : ONLP_FAN_ID_CREATE(10) + + psu_id: + members: + - PSU1 : 1 + - PSU2 : 2 + + psu_oid: + members: + - PSU1 : ONLP_PSU_ID_CREATE(1) + - PSU2 : ONLP_PSU_ID_CREATE(2) + + thermal_id: + members: + - THERMAL1 : 1 + - THERMAL2 : 2 + - THERMAL3 : 3 + - THERMAL4 : 4 + - THERMAL5 : 5 + - THERMAL6 : 6 + - THERMAL7 : 7 + - THERMAL8 : 8 + - THERMAL9 : 9 + - THERMAL10 : 10 + - THERMAL11 : 11 + - THERMAL12 : 12 + - THERMAL13 : 13 + - THERMAL14 : 14 + - THERMAL15 : 15 + - THERMAL16 : 16 + + + thermal_oid: + members: + - THERMAL1 : ONLP_THERMAL_ID_CREATE(1) + - THERMAL2 : ONLP_THERMAL_ID_CREATE(2) + - THERMAL3 : ONLP_THERMAL_ID_CREATE(3) + - THERMAL4 : ONLP_THERMAL_ID_CREATE(4) + - THERMAL5 : ONLP_THERMAL_ID_CREATE(5) + - THERMAL6 : ONLP_THERMAL_ID_CREATE(6) + - THERMAL7 : ONLP_THERMAL_ID_CREATE(7) + - THERMAL8 : ONLP_THERMAL_ID_CREATE(8) + - THERMAL9 : ONLP_THERMAL_ID_CREATE(9) + - THERMAL10 : ONLP_THERMAL_ID_CREATE(10) + - THERMAL11 : ONLP_THERMAL_ID_CREATE(11) + - THERMAL12 : ONLP_THERMAL_ID_CREATE(12) + - THERMAL13 : ONLP_THERMAL_ID_CREATE(13) + - THERMAL14 : ONLP_THERMAL_ID_CREATE(14) + - THERMAL15 : ONLP_THERMAL_ID_CREATE(15) + - THERMAL16 : ONLP_THERMAL_ID_CREATE(16) + + + portingmacro: + X86_64_QUANTA_LY7_RGLBMC: + macros: + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x new file mode 100755 index 00000000..fb92a8c9 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h new file mode 100755 index 00000000..77fc4eed --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h @@ -0,0 +1,167 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ly7_rglbmc Configuration Header + * + * @addtogroup x86_64_quanta_ly7_rglbmc-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_CONFIG_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + * + * RPM Threshold at which the fan is considered to have failed. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + * + * Maximum system front-to-back fan speed. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + * + * Maximum system back-to-front fan speed. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + * + * Time to hold Phy GPIO in reset, in ms */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS 100 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_quanta_ly7_rglbmc_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_quanta_ly7_rglbmc_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_quanta_ly7_rglbmc_config_settings table. */ +extern x86_64_quanta_ly7_rglbmc_config_settings_t x86_64_quanta_ly7_rglbmc_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_quanta_ly7_rglbmc_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_quanta_ly7_rglbmc_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_quanta_ly7_rglbmc_porting.h" + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h new file mode 100755 index 00000000..95cb5d2d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_quanta_ly7_rglbmc Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_DOX_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_DOX_H__ + +/** + * @defgroup x86_64_quanta_ly7_rglbmc x86_64_quanta_ly7_rglbmc - x86_64_quanta_ly7_rglbmc Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_quanta_ly7_rglbmc-x86_64_quanta_ly7_rglbmc Public Interface + * @defgroup x86_64_quanta_ly7_rglbmc-config Compile Time Configuration + * @defgroup x86_64_quanta_ly7_rglbmc-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h new file mode 100755 index 00000000..8317d978 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h @@ -0,0 +1,39 @@ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_GPIO_TABLE_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_GPIO_TABLE_H__ + +/* + * defined within platform/quanta_switch.c + * Quanta Switch Platform driver + */ +#define QUANTA_LY7_PCA953x_GPIO(P1, P2) (P1*8+P2) + +#define QUANTA_LY7_PCA9555_GPIO_SIZE 0x10 + +#define QUANTA_LY7_I2C_GPIO_BASE 0x10 + +#define QUANTA_LY7_I2C_GPIO_CPU_BASE 0x40 + +#define QUANTA_LY7_CPU_BOARD_GPIO_BASE (QUANTA_LY7_I2C_GPIO_CPU_BASE) +#define QUANTA_LY7_CPU_BOARD_SYS_P1 (QUANTA_LY7_CPU_BOARD_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,2)) +#define QUANTA_LY7_CPU_BOARD_SYS_P2 (QUANTA_LY7_CPU_BOARD_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,3)) + +#define QUANTA_LY7_ZQSFP_EN_GPIO_BASE QUANTA_LY7_I2C_GPIO_BASE +#define QUANTA_LY7_ZQSFP_EN_GPIO_SIZE QUANTA_LY7_PCA9555_GPIO_SIZE +#define QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_LY7_ZQSFP_EN_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,4)) +#define QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_LY7_ZQSFP_EN_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,5)) + +#define QUANTA_LY7_PCA9698_2_GPIO_BASE (QUANTA_LY7_I2C_GPIO_BASE + QUANTA_LY7_PCA9555_GPIO_SIZE) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,0)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,2)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,3)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,4)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,6)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,7)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,0)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,2)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,3)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,4)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,6)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,7)) + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h new file mode 100755 index 00000000..32b963fa --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ly7_rglbmc Porting Macros. + * + * @addtogroup x86_64_quanta_ly7_rglbmc-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_PORTING_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_PORTING_H__ + + +/* */ +#if X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_QUANTA_LY7_RGLBMC_MEMSET GLOBAL_MEMSET + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_MEMSET memset + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_QUANTA_LY7_RGLBMC_MEMCPY GLOBAL_MEMCPY + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_MEMCPY memcpy + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_QUANTA_LY7_RGLBMC_STRNCPY GLOBAL_STRNCPY + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_STRNCPY strncpy + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF vsnprintf + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_QUANTA_LY7_RGLBMC_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_SNPRINTF snprintf + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_QUANTA_LY7_RGLBMC_STRLEN GLOBAL_STRLEN + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_STRLEN strlen + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk new file mode 100755 index 00000000..9976c552 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_quanta_ly7_rglbmc_INCLUDES := -I $(THIS_DIR)inc +x86_64_quanta_ly7_rglbmc_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_quanta_ly7_rglbmc_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ly7_rglbmc ucli:x86_64_quanta_ly7_rglbmc + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile new file mode 100755 index 00000000..0aa71303 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_quanta_ly7_rglbmc_ucli.c + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c new file mode 100755 index 00000000..7594b0ca --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c @@ -0,0 +1,31 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_fani_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c new file mode 100755 index 00000000..74928269 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include + +#include "x86_64_quanta_ly7_rglbmc_int.h" +#include +#include + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t led_info[] = +{ + { }, /* Not used */ + { + { LED_OID_SYSTEM, "System LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + } +}; + +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + + int led_id; + + led_id = ONLP_OID_ID_GET(id); + + *info = led_info[led_id]; + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_ON; + + return ONLP_STATUS_OK; +} + +void +Sysfs_Set_System_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P1, 0); + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P2, 1); + } + else if(mode == ONLP_LED_MODE_ORANGE){ + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P2, 0); + } + else{ + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P2, 1); + } +} + +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int led_id; + + led_id = ONLP_OID_ID_GET(id); + switch (led_id) { + case LED_ID_SYSTEM: + Sysfs_Set_System_LED(mode); + break; + default: + return ONLP_STATUS_E_INTERNAL; + break; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk new file mode 100755 index 00000000..f48c4f6e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_quanta_ly7_rglbmc +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c new file mode 100755 index 00000000..b5cedce1 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c @@ -0,0 +1,15 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c new file mode 100755 index 00000000..5bb1079f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c @@ -0,0 +1,409 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * SFPI Interface for the Quanta LY7 + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "x86_64_quanta_ly7_rglbmc_log.h" +#include +#include +#include + +/** + * This table maps the presence gpio, reset gpio, and eeprom file + * for each SFP port. + */ +typedef struct sfpmap_s { + int port; + const char* present_cpld; + const char* reset_gpio; + const char* eeprom; + const char* dom; +} sfpmap_t; + +static sfpmap_t sfpmap__[] = + { + { 1, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-1/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-32/32-0050/eeprom", NULL }, + { 2, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-2/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-33/33-0050/eeprom", NULL }, + { 3, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-3/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-34/34-0050/eeprom", NULL }, + { 4, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-4/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-35/35-0050/eeprom", NULL }, + { 5, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-5/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-36/36-0050/eeprom", NULL }, + { 6, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-6/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-37/37-0050/eeprom", NULL }, + { 7, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-7/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-38/38-0050/eeprom", NULL }, + { 8, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-8/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-39/39-0050/eeprom", NULL }, + { 9, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-9/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-40/40-0050/eeprom", NULL }, + { 10, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-10/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-41/41-0050/eeprom", NULL }, + { 11, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-11/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-42/42-0050/eeprom", NULL }, + { 12, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-12/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-43/43-0050/eeprom", NULL }, + { 13, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-13/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-44/44-0050/eeprom", NULL }, + { 14, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-14/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-45/45-0050/eeprom", NULL }, + { 15, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-15/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-46/46-0050/eeprom", NULL }, + { 16, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-16/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-47/47-0050/eeprom", NULL }, + { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-17/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-48/48-0050/eeprom", NULL }, + { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-18/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-49/49-0050/eeprom", NULL }, + { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-19/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-50/50-0050/eeprom", NULL }, + { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-20/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-51/51-0050/eeprom", NULL }, + { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-21/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-52/52-0050/eeprom", NULL }, + { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-22/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-53/53-0050/eeprom", NULL }, + { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-23/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-54/54-0050/eeprom", NULL }, + { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-24/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-55/55-0050/eeprom", NULL }, + { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-25/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-56/56-0050/eeprom", NULL }, + { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-26/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-57/57-0050/eeprom", NULL }, + { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-27/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-58/58-0050/eeprom", NULL }, + { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-28/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-59/59-0050/eeprom", NULL }, + { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-29/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-60/60-0050/eeprom", NULL }, + { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-30/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-61/61-0050/eeprom", NULL }, + { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-31/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-62/62-0050/eeprom", NULL }, + { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-63/63-0050/eeprom", NULL }, + { 33, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-33/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-64/64-0050/eeprom", NULL }, + { 34, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-34/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-65/65-0050/eeprom", NULL }, + { 35, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-35/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-66/66-0050/eeprom", NULL }, + { 36, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-36/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-67/67-0050/eeprom", NULL }, + { 37, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-37/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-68/68-0050/eeprom", NULL }, + { 38, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-38/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-69/69-0050/eeprom", NULL }, + { 39, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-39/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-70/70-0050/eeprom", NULL }, + { 40, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-40/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-71/71-0050/eeprom", NULL }, + { 41, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-41/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-72/72-0050/eeprom", NULL }, + { 42, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-42/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-73/73-0050/eeprom", NULL }, + { 43, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-43/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-74/74-0050/eeprom", NULL }, + { 44, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-44/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-75/75-0050/eeprom", NULL }, + { 45, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-45/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-76/76-0050/eeprom", NULL }, + { 46, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-46/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-77/77-0050/eeprom", NULL }, + { 47, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-47/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-78/78-0050/eeprom", NULL }, + { 48, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-48/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-79/79-0050/eeprom", NULL }, + }; + +typedef struct qsfpmap_s { + int port; + int present_gpio; + int reset_gpio; + int lplmod_gpio; + const char* eeprom; + const char* dom; +} qsfpmap_t; + +static qsfpmap_t qsfpmap__[] = + { + { 49, QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-80/80-0050/eeprom", NULL }, + { 50, QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-81/81-0050/eeprom", NULL }, + { 51, QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-82/82-0050/eeprom", NULL }, + { 52, QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-83/83-0050/eeprom", NULL }, + }; + +#define SFP_GET(_port) (sfpmap__ + _port - 1) +#define QSFP_GET(_port) (qsfpmap__ + _port - 49) +#define MAX_SFP_PATH 128 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sfpmap_t* sfp = SFP_GET(port); + + sprintf(sfp_node_path, sfp->present_cpld, + node_name); + return sfp_node_path; +} + +int +onlp_sfpi_init(void) +{ + int ret, i; + qsfpmap_t* qsfp; + + onlp_gpio_export(QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); + ret = onlp_gpio_set(QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_EN, 1); + sleep(1); + + for(i = 49; i < 53 ; i ++) { + qsfp = QSFP_GET(i); + onlp_gpio_export(qsfp->present_gpio, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(qsfp->reset_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(qsfp->reset_gpio, 1); + onlp_gpio_export(qsfp->lplmod_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(qsfp->lplmod_gpio, 0); + } + + return ret; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + + for(p = 1; p < 53; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + if(port > 48){ + int value = 0; + qsfpmap_t* qsfp = QSFP_GET(port); + + if(qsfp->present_gpio > 0) { + if(onlp_gpio_get(qsfp->present_gpio, &value) == ONLP_STATUS_OK) + return (value == 0); + else + return ONLP_STATUS_E_MISSING; + } + else { + /** + * If we can open and read a byte from the EEPROM file + * then we consider it present. + */ + int fd = open(qsfp->eeprom, O_RDONLY); + if (fd < 0) { + /* Not Present */ + return 0; + } + int rv; + uint8_t byte; + + if(read(fd, &byte, 1) == 1) { + /* Present */ + rv = 1; + } + else { + /* No Present */ + rv = 0; + } + close(fd); + return rv; + } + } + else{ + return onlplib_sfp_is_present_file(sfp_get_port_path(port, "pre_n"), /* Present */ "1\n", /* Absent */ "0\n"); + } +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + return onlplib_sfp_eeprom_read_file(qsfp->eeprom, data); + } + else{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->eeprom, data); + } +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + return onlplib_sfp_eeprom_read_file(qsfp->dom, data); + } + else{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->dom, data); + } +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + if(onlp_gpio_set(qsfp->reset_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set reset status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + if(onlp_gpio_set(qsfp->lplmod_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + else{ + switch(control){ + case ONLP_SFP_CONTROL_TX_DISABLE: + { + char* path = sfp_get_port_path(port, "tx_dis"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + char* path = NULL; + + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + if(onlp_gpio_get(qsfp->reset_gpio, value) == ONLP_STATUS_OK){ + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + if(onlp_gpio_get(qsfp->lplmod_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read lp_mode status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_RX_LOS: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + else{ + switch(control){ + case ONLP_SFP_CONTROL_RX_LOS: + { + path = sfp_get_port_path(port, "rx_los"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + path = sfp_get_port_path(port, "tx_fault"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + path = sfp_get_port_path(port, "tx_dis"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read tx_disable status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + + return rv; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c new file mode 100755 index 00000000..2be2773f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c @@ -0,0 +1,66 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_quanta_ly7_rglbmc_int.h" +#include "x86_64_quanta_ly7_rglbmc_log.h" +#include +#include +#include +#include +#include + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-quanta-ly7-rglbmc-r0"; +} + +int +onlp_sysi_init(void) +{ + /* Config GPIO */ + /* LED Output */ + onlp_gpio_export(QUANTA_LY7_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_LY7_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); + + /* Set LED to green */ + onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); + + return ONLP_STATUS_OK; +} + +#define QUANTA_SYS_EEPROM_PATH \ +"/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0054/eeprom" + +int +onlp_sysi_onie_info_get(onlp_onie_info_t* onie) +{ + int rv; + + rv = onlp_onie_decode_file(onie, QUANTA_SYS_EEPROM_PATH); + if(rv >= 0) { + onie->platform_name = aim_strdup("x86-64-quanta-ly7-rglbmc-r0"); + rv = quanta_onie_sys_eeprom_custom_format(onie); + } + return rv; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* + * 1 LEDs + */ + *e++ = LED_OID_SYSTEM; + + return 0; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c new file mode 100755 index 00000000..2a84c017 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c @@ -0,0 +1,31 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c new file mode 100755 index 00000000..0a811a3b --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c @@ -0,0 +1,95 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(_x) +x86_64_quanta_ly7_rglbmc_config_settings_t x86_64_quanta_ly7_rglbmc_config_settings[] = +{ +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE +#undef __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME + +const char* +x86_64_quanta_ly7_rglbmc_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_quanta_ly7_rglbmc_config_settings[i].name; i++) { + if(strcmp(x86_64_quanta_ly7_rglbmc_config_settings[i].name, setting)) { + return x86_64_quanta_ly7_rglbmc_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_quanta_ly7_rglbmc_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_quanta_ly7_rglbmc_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_quanta_ly7_rglbmc_config_settings[i].name, x86_64_quanta_ly7_rglbmc_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c new file mode 100755 index 00000000..1d1f3f93 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h new file mode 100755 index 00000000..c0d51dca --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h @@ -0,0 +1,281 @@ +/**************************************************************************//** + * + * x86_64_quanta_ly7_rglbmc Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_INT_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_INT_H__ + +#include +#include + +/* */ +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; + +/** Enum names. */ +const char* thermal_oid_name(thermal_oid_t e); + +/** Enum values. */ +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_oid_desc(thermal_oid_t e); + +/** Enum validator. */ +int thermal_oid_valid(thermal_oid_t e); + +/** validator */ +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) + +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; + +/** psu_oid */ +typedef enum psu_oid_e { + PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), + PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), +} psu_oid_t; + +/** Enum names. */ +const char* psu_oid_name(psu_oid_t e); + +/** Enum values. */ +int psu_oid_value(const char* str, psu_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_oid_desc(psu_oid_t e); + +/** Enum validator. */ +int psu_oid_valid(psu_oid_t e); + +/** validator */ +#define PSU_OID_VALID(_e) \ + (psu_oid_valid((_e))) + +/** psu_oid_map table. */ +extern aim_map_si_t psu_oid_map[]; +/** psu_oid_desc_map table. */ +extern aim_map_si_t psu_oid_desc_map[]; + +/** thermal_id */ +typedef enum thermal_id_e { + THERMAL_ID_THERMAL1 = 1, + THERMAL_ID_THERMAL2 = 2, + THERMAL_ID_THERMAL3 = 3, + THERMAL_ID_THERMAL4 = 4, + THERMAL_ID_THERMAL5 = 5, + THERMAL_ID_THERMAL6 = 6, + THERMAL_ID_THERMAL7 = 7, + THERMAL_ID_THERMAL8 = 8, + THERMAL_ID_THERMAL9 = 9, + THERMAL_ID_THERMAL10 = 10, + THERMAL_ID_THERMAL11 = 11, + THERMAL_ID_THERMAL12 = 12, + THERMAL_ID_THERMAL13 = 13, + THERMAL_ID_THERMAL14 = 14, + THERMAL_ID_THERMAL15 = 15, + THERMAL_ID_THERMAL16 = 16, +} thermal_id_t; + +/** Enum names. */ +const char* thermal_id_name(thermal_id_t e); + +/** Enum values. */ +int thermal_id_value(const char* str, thermal_id_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_id_desc(thermal_id_t e); + +/** Enum validator. */ +int thermal_id_valid(thermal_id_t e); + +/** validator */ +#define THERMAL_ID_VALID(_e) \ + (thermal_id_valid((_e))) + +/** thermal_id_map table. */ +extern aim_map_si_t thermal_id_map[]; +/** thermal_id_desc_map table. */ +extern aim_map_si_t thermal_id_desc_map[]; + +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; + +/** Enum names. */ +const char* fan_id_name(fan_id_t e); + +/** Enum values. */ +int fan_id_value(const char* str, fan_id_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_id_desc(fan_id_t e); + +/** Enum validator. */ +int fan_id_valid(fan_id_t e); + +/** validator */ +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) + +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; +/* */ + +/* psu info table */ +struct psu_info_s { + char path[PATH_MAX]; + int present; + int busno; + int addr; +}; + +/** led_id */ +typedef enum led_id_e { + LED_ID_SYSTEM = 1, +} led_id_t; + +/** Enum names. */ +const char* led_id_name(led_id_t e); + +/** Enum values. */ +int led_id_value(const char* str, led_id_t* e, int substr); + +/** Enum descriptions. */ +const char* led_id_desc(led_id_t e); + +/** Enum validator. */ +int led_id_valid(led_id_t e); + +/** validator */ +#define LED_ID_VALID(_e) \ + (led_id_valid((_e))) + +/** led_id_map table. */ +extern aim_map_si_t led_id_map[]; +/** led_id_desc_map table. */ +extern aim_map_si_t led_id_desc_map[]; + +/** led_oid */ +typedef enum led_oid_e { + LED_OID_SYSTEM = ONLP_LED_ID_CREATE(LED_ID_SYSTEM), +} led_oid_t; + +/** Enum names. */ +const char* led_oid_name(led_oid_t e); + +/** Enum values. */ +int led_oid_value(const char* str, led_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* led_oid_desc(led_oid_t e); + +/** Enum validator. */ +int led_oid_valid(led_oid_t e); + +/** validator */ +#define LED_OID_VALID(_e) \ + (led_oid_valid((_e))) + +/** led_oid_map table. */ +extern aim_map_si_t led_oid_map[]; +/** led_oid_desc_map table. */ +extern aim_map_si_t led_oid_desc_map[]; +/* */ + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c new file mode 100755 index 00000000..f1e92e8c --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ly7_rglbmc_log.h" +/* + * x86_64_quanta_ly7_rglbmc log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h new file mode 100755 index 00000000..6a5dc0ce --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_LOG_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_quanta_ly7_rglbmc +#include + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c new file mode 100755 index 00000000..7fbcc78e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ly7_rglbmc_log.h" + +static int +datatypes_init__(void) +{ +#define X86_64_QUANTA_LY7_RGLBMC_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_quanta_ly7_rglbmc_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c new file mode 100755 index 00000000..cf50c8f5 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_quanta_ly7_rglbmc_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ly7_rglbmc) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_quanta_ly7_rglbmc_ucli_module__ = + { + "x86_64_quanta_ly7_rglbmc_ucli", + NULL, + x86_64_quanta_ly7_rglbmc_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_quanta_ly7_rglbmc_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_quanta_ly7_rglbmc_ucli_module__); + n = ucli_node_create("x86_64_quanta_ly7_rglbmc", NULL, &x86_64_quanta_ly7_rglbmc_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ly7_rglbmc")); + return n; +} + +#else +void* +x86_64_quanta_ly7_rglbmc_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml new file mode 100755 index 00000000..25082e7d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly7-rglbmc REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml new file mode 100755 index 00000000..8cf8da1f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for LY7 +# +###################################################################### + +x86-64-quanta-ly7-rglbmc-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + console=ttyS1,115200n8 + reboot=c,p + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py new file mode 100755 index 00000000..1cd8c645 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py @@ -0,0 +1,22 @@ +from onl.platform.base import * +from onl.platform.quanta import * + +class OnlPlatform_x86_64_quanta_ly7_rglbmc_r0(OnlPlatformQuanta, + OnlPlatformPortConfig_48x10_4x100): + PLATFORM='x86-64-quanta-ly7-rglbmc-r0' + MODEL="LY7" + """ Define Quanta SYS_OBJECT_ID rule. + + SYS_OBJECT_ID = .xxxx.ABCC + "xxxx" define QCT device mark. For example, LB9->1048, LY2->3048 + "A" define QCT switch series name: LB define 1, LY define 2, IX define 3 + "B" define QCT switch series number 1: For example, LB9->9, LY2->2 + "CC" define QCT switch series number 2: For example, LY2->00, LY4R->18(R is 18th english letter) + """ + SYS_OBJECT_ID=".3048.2700" + + def baseconfig(self): + self.insmod("qci_cpld_sfp28") + self.insmod("quanta_platform_ly7") + + return True From 874273c43454c571ec50c45a41d800ec3624aff0 Mon Sep 17 00:00:00 2001 From: Joe Chan Date: Tue, 3 Oct 2017 01:51:18 -0700 Subject: [PATCH 054/244] Add support for Inventec d7032q28b. --- packages/platforms/inventec/Makefile | 1 + .../platforms/inventec/vendor-config/Makefile | 1 + .../platforms/inventec/vendor-config/PKG.yml | 1 + .../src/python/inventec/__init__.py | 7 + packages/platforms/inventec/x86-64/Makefile | 1 + .../inventec/x86-64/modules/Makefile | 1 + .../platforms/inventec/x86-64/modules/PKG.yml | 1 + .../x86-64/x86-64-inventec-d7032q28b/Makefile | 1 + .../modules/Makefile | 1 + .../x86-64-inventec-d7032q28b/modules/PKG.yml | 1 + .../modules/builds/Makefile | 6 + .../modules/builds/gpio-ich.c | 548 +++++++++ .../modules/builds/inv_cpld.c | 456 ++++++++ .../modules/builds/inv_platform.c | 197 ++++ .../modules/builds/inv_psoc.c | 1024 +++++++++++++++++ .../x86-64-inventec-d7032q28b/onlp/Makefile | 1 + .../x86-64-inventec-d7032q28b/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/module/auto/make.mk | 9 + .../module/auto/x86_64_inventec_d7032q28b.yml | 50 + .../x86_64_inventec_d7032q28b.x | 14 + .../x86_64_inventec_d7032q28b_config.h | 137 +++ .../x86_64_inventec_d7032q28b_dox.h | 26 + .../x86_64_inventec_d7032q28b_porting.h | 107 ++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/debug.c | 45 + .../onlp/builds/src/module/src/fani.c | 402 +++++++ .../onlp/builds/src/module/src/ledi.c | 263 +++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 200 ++++ .../onlp/builds/src/module/src/platform_lib.h | 77 ++ .../onlp/builds/src/module/src/psui.c | 271 +++++ .../onlp/builds/src/module/src/sfpi.c | 221 ++++ .../onlp/builds/src/module/src/sysi.c | 295 +++++ .../onlp/builds/src/module/src/thermali.c | 141 +++ .../src/x86_64_inventec_d7032q28b_config.c | 81 ++ .../src/x86_64_inventec_d7032q28b_enums.c | 10 + .../src/x86_64_inventec_d7032q28b_int.h | 12 + .../src/x86_64_inventec_d7032q28b_log.c | 18 + .../src/x86_64_inventec_d7032q28b_log.h | 12 + .../src/x86_64_inventec_d7032q28b_module.c | 24 + .../src/x86_64_inventec_d7032q28b_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-inventec-d7032q28b-r0.yml | 31 + .../x86_64_inventec_d7032q28b_r0/__init__.py | 15 + 52 files changed, 4894 insertions(+) create mode 100644 packages/platforms/inventec/Makefile create mode 100644 packages/platforms/inventec/vendor-config/Makefile create mode 100644 packages/platforms/inventec/vendor-config/PKG.yml create mode 100644 packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py create mode 100644 packages/platforms/inventec/x86-64/Makefile create mode 100644 packages/platforms/inventec/x86-64/modules/Makefile create mode 100644 packages/platforms/inventec/x86-64/modules/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_psoc.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py diff --git a/packages/platforms/inventec/Makefile b/packages/platforms/inventec/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/vendor-config/Makefile b/packages/platforms/inventec/vendor-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/vendor-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/vendor-config/PKG.yml b/packages/platforms/inventec/vendor-config/PKG.yml new file mode 100644 index 00000000..4afa2f7c --- /dev/null +++ b/packages/platforms/inventec/vendor-config/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=inventec Vendor=Inventec diff --git a/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py b/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py new file mode 100644 index 00000000..41f7a3e6 --- /dev/null +++ b/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +from onl.platform.base import * + +class OnlPlatformInventec(OnlPlatformBase): + MANUFACTURER='Inventec' + PRIVATE_ENTERPRISE_NUMBER=6569 diff --git a/packages/platforms/inventec/x86-64/Makefile b/packages/platforms/inventec/x86-64/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/modules/Makefile b/packages/platforms/inventec/x86-64/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/modules/PKG.yml b/packages/platforms/inventec/x86-64/modules/PKG.yml new file mode 100644 index 00000000..3690f5a9 --- /dev/null +++ b/packages/platforms/inventec/x86-64/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=amd64 VENDOR=inventec diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml new file mode 100644 index 00000000..cad0df03 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d7032q28b ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile new file mode 100644 index 00000000..1fe88c1d --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := inventec +BASENAME := x86-64-inventec-d7032q28b +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c new file mode 100644 index 00000000..70304220 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c @@ -0,0 +1,548 @@ +/* + * Intel ICH6-10, Series 5 and 6, Atom C2000 (Avoton/Rangeley) GPIO driver + * + * Copyright (C) 2010 Extreme Engineering Solutions. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include + +#define DRV_NAME "gpio_ich" + +/* + * GPIO register offsets in GPIO I/O space. + * Each chunk of 32 GPIOs is manipulated via its own USE_SELx, IO_SELx, and + * LVLx registers. Logic in the read/write functions takes a register and + * an absolute bit number and determines the proper register offset and bit + * number in that register. For example, to read the value of GPIO bit 50 + * the code would access offset ichx_regs[2(=GPIO_LVL)][1(=50/32)], + * bit 18 (50%32). + */ +enum GPIO_REG { + GPIO_USE_SEL = 0, + GPIO_IO_SEL, + GPIO_LVL, + GPO_BLINK +}; + +static const u8 ichx_regs[4][3] = { + {0x00, 0x30, 0x40}, /* USE_SEL[1-3] offsets */ + {0x04, 0x34, 0x44}, /* IO_SEL[1-3] offsets */ + {0x0c, 0x38, 0x48}, /* LVL[1-3] offsets */ + {0x18, 0x18, 0x18}, /* BLINK offset */ +}; + +static const u8 ichx_reglen[3] = { + 0x30, 0x10, 0x10, +}; + +static const u8 avoton_regs[4][3] = { + {0x00, 0x80, 0x00}, + {0x04, 0x84, 0x00}, + {0x08, 0x88, 0x00}, +}; + +static const u8 avoton_reglen[3] = { + 0x10, 0x10, 0x00, +}; + +#define ICHX_WRITE(val, reg, base_res) outl(val, (reg) + (base_res)->start) +#define ICHX_READ(reg, base_res) inl((reg) + (base_res)->start) + +struct ichx_desc { + /* Max GPIO pins the chipset can have */ + uint ngpio; + + /* chipset registers */ + const u8 (*regs)[3]; + const u8 *reglen; + + /* GPO_BLINK is available on this chipset */ + bool have_blink; + + /* Whether the chipset has GPIO in GPE0_STS in the PM IO region */ + bool uses_gpe0; + + /* USE_SEL is bogus on some chipsets, eg 3100 */ + u32 use_sel_ignore[3]; + + /* Some chipsets have quirks, let these use their own request/get */ + int (*request)(struct gpio_chip *chip, unsigned offset); + int (*get)(struct gpio_chip *chip, unsigned offset); + + /* + * Some chipsets don't let reading output values on GPIO_LVL register + * this option allows driver caching written output values + */ + bool use_outlvl_cache; +}; + +static struct { + spinlock_t lock; + struct platform_device *dev; + struct gpio_chip chip; + struct resource *gpio_base; /* GPIO IO base */ + struct resource *pm_base; /* Power Mangagment IO base */ + struct ichx_desc *desc; /* Pointer to chipset-specific description */ + u32 orig_gpio_ctrl; /* Orig CTRL value, used to restore on exit */ + u8 use_gpio; /* Which GPIO groups are usable */ + int outlvl_cache[3]; /* cached output values */ +} ichx_priv; + +static int modparam_gpiobase = -1; /* dynamic */ +module_param_named(gpiobase, modparam_gpiobase, int, 0444); +MODULE_PARM_DESC(gpiobase, "The GPIO number base. -1 means dynamic, " + "which is the default."); + +static int ichx_write_bit(int reg, unsigned nr, int val, int verify) +{ + unsigned long flags; + u32 data, tmp; + int reg_nr = nr / 32; + int bit = nr & 0x1f; + int ret = 0; + + spin_lock_irqsave(&ichx_priv.lock, flags); + + if (reg == GPIO_LVL && ichx_priv.desc->use_outlvl_cache) + data = ichx_priv.outlvl_cache[reg_nr]; + else + data = ICHX_READ(ichx_priv.desc->regs[reg][reg_nr], + ichx_priv.gpio_base); + + if (val) + data |= 1 << bit; + else + data &= ~(1 << bit); + ICHX_WRITE(data, ichx_priv.desc->regs[reg][reg_nr], + ichx_priv.gpio_base); + if (reg == GPIO_LVL && ichx_priv.desc->use_outlvl_cache) + ichx_priv.outlvl_cache[reg_nr] = data; + + tmp = ICHX_READ(ichx_priv.desc->regs[reg][reg_nr], + ichx_priv.gpio_base); + if (verify && data != tmp) + ret = -EPERM; + + spin_unlock_irqrestore(&ichx_priv.lock, flags); + + return ret; +} + +static int ichx_read_bit(int reg, unsigned nr) +{ + unsigned long flags; + u32 data; + int reg_nr = nr / 32; + int bit = nr & 0x1f; + + spin_lock_irqsave(&ichx_priv.lock, flags); + + data = ICHX_READ(ichx_priv.desc->regs[reg][reg_nr], + ichx_priv.gpio_base); + + if (reg == GPIO_LVL && ichx_priv.desc->use_outlvl_cache) + data = ichx_priv.outlvl_cache[reg_nr] | data; + + spin_unlock_irqrestore(&ichx_priv.lock, flags); + + return data & (1 << bit) ? 1 : 0; +} + +static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr) +{ + return !!(ichx_priv.use_gpio & (1 << (nr / 32))); +} + +static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) +{ + /* + * Try setting pin as an input and verify it worked since many pins + * are output-only. + */ + if (ichx_write_bit(GPIO_IO_SEL, nr, 1, 1)) + return -EINVAL; + + return 0; +} + +static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, + int val) +{ + /* Disable blink hardware which is available for GPIOs from 0 to 31. */ + if (nr < 32 && ichx_priv.desc->have_blink) + ichx_write_bit(GPO_BLINK, nr, 0, 0); + + /* Set GPIO output value. */ + ichx_write_bit(GPIO_LVL, nr, val, 0); + + /* + * Try setting pin as an output and verify it worked since many pins + * are input-only. + */ + if (ichx_write_bit(GPIO_IO_SEL, nr, 0, 1)) + return -EINVAL; + + return 0; +} + +static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr) +{ + return ichx_read_bit(GPIO_LVL, nr); +} + +static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr) +{ + unsigned long flags; + u32 data; + + /* + * GPI 0 - 15 need to be read from the power management registers on + * a ICH6/3100 bridge. + */ + if (nr < 16) { + if (!ichx_priv.pm_base) + return -ENXIO; + + spin_lock_irqsave(&ichx_priv.lock, flags); + + /* GPI 0 - 15 are latched, write 1 to clear*/ + ICHX_WRITE(1 << (16 + nr), 0, ichx_priv.pm_base); + data = ICHX_READ(0, ichx_priv.pm_base); + + spin_unlock_irqrestore(&ichx_priv.lock, flags); + + return (data >> 16) & (1 << nr) ? 1 : 0; + } else { + return ichx_gpio_get(chip, nr); + } +} + +static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr) +{ + if (!ichx_gpio_check_available(chip, nr)) + return -ENXIO; + + /* + * Note we assume the BIOS properly set a bridge's USE value. Some + * chips (eg Intel 3100) have bogus USE values though, so first see if + * the chipset's USE value can be trusted for this specific bit. + * If it can't be trusted, assume that the pin can be used as a GPIO. + */ + if (ichx_priv.desc->use_sel_ignore[nr / 32] & (1 << (nr & 0x1f))) + return 0; + + return ichx_read_bit(GPIO_USE_SEL, nr) ? 0 : -ENODEV; +} + +static int ich6_gpio_request(struct gpio_chip *chip, unsigned nr) +{ + /* + * Fixups for bits 16 and 17 are necessary on the Intel ICH6/3100 + * bridge as they are controlled by USE register bits 0 and 1. See + * "Table 704 GPIO_USE_SEL1 register" in the i3100 datasheet for + * additional info. + */ + if (nr == 16 || nr == 17) + nr -= 16; + + return ichx_gpio_request(chip, nr); +} + +static void ichx_gpio_set(struct gpio_chip *chip, unsigned nr, int val) +{ + ichx_write_bit(GPIO_LVL, nr, val, 0); +} + +static void ichx_gpiolib_setup(struct gpio_chip *chip) +{ + chip->owner = THIS_MODULE; + chip->label = DRV_NAME; + chip->dev = &ichx_priv.dev->dev; + + /* Allow chip-specific overrides of request()/get() */ + chip->request = ichx_priv.desc->request ? + ichx_priv.desc->request : ichx_gpio_request; + chip->get = ichx_priv.desc->get ? + ichx_priv.desc->get : ichx_gpio_get; + + chip->set = ichx_gpio_set; + chip->direction_input = ichx_gpio_direction_input; + chip->direction_output = ichx_gpio_direction_output; + chip->base = modparam_gpiobase; + chip->ngpio = ichx_priv.desc->ngpio; + chip->can_sleep = false; + chip->dbg_show = NULL; +} + +/* ICH6-based, 631xesb-based */ +static struct ichx_desc ich6_desc = { + /* Bridges using the ICH6 controller need fixups for GPIO 0 - 17 */ + .request = ich6_gpio_request, + .get = ich6_gpio_get, + + /* GPIO 0-15 are read in the GPE0_STS PM register */ + .uses_gpe0 = true, + + .ngpio = 50, + .have_blink = true, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; + +/* Intel 3100 */ +static struct ichx_desc i3100_desc = { + /* + * Bits 16,17, 20 of USE_SEL and bit 16 of USE_SEL2 always read 0 on + * the Intel 3100. See "Table 712. GPIO Summary Table" of 3100 + * Datasheet for more info. + */ + .use_sel_ignore = {0x00130000, 0x00010000, 0x0}, + + /* The 3100 needs fixups for GPIO 0 - 17 */ + .request = ich6_gpio_request, + .get = ich6_gpio_get, + + /* GPIO 0-15 are read in the GPE0_STS PM register */ + .uses_gpe0 = true, + + .ngpio = 50, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; + +/* ICH7 and ICH8-based */ +static struct ichx_desc ich7_desc = { + .ngpio = 50, + .have_blink = true, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; + +/* ICH9-based */ +static struct ichx_desc ich9_desc = { + .ngpio = 61, + .have_blink = true, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; + +/* ICH10-based - Consumer/corporate versions have different amount of GPIO */ +static struct ichx_desc ich10_cons_desc = { + .ngpio = 61, + .have_blink = true, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; +static struct ichx_desc ich10_corp_desc = { + .ngpio = 72, + .have_blink = true, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; + +/* Intel 5 series, 6 series, 3400 series, and C200 series */ +static struct ichx_desc intel5_desc = { + .ngpio = 76, + .regs = ichx_regs, + .reglen = ichx_reglen, +}; + +/* Avoton */ +static struct ichx_desc avoton_desc = { + /* Avoton has only 59 GPIOs, but we assume the first set of register + * (Core) has 32 instead of 31 to keep gpio-ich compliance + */ + .ngpio = 60, + .regs = avoton_regs, + .reglen = avoton_reglen, + .use_outlvl_cache = true, +}; + +static int ichx_gpio_request_regions(struct resource *res_base, + const char *name, u8 use_gpio) +{ + int i; + + if (!res_base || !res_base->start || !res_base->end) + return -ENODEV; + + for (i = 0; i < ARRAY_SIZE(ichx_priv.desc->regs[0]); i++) { + if (!(use_gpio & (1 << i))) + continue; + if (!request_region( + res_base->start + ichx_priv.desc->regs[0][i], + ichx_priv.desc->reglen[i], name)) + goto request_err; + } + return 0; + +request_err: + /* Clean up: release already requested regions, if any */ + for (i--; i >= 0; i--) { + if (!(use_gpio & (1 << i))) + continue; + release_region(res_base->start + ichx_priv.desc->regs[0][i], + ichx_priv.desc->reglen[i]); + } + return -EBUSY; +} + +static void ichx_gpio_release_regions(struct resource *res_base, u8 use_gpio) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ichx_priv.desc->regs[0]); i++) { + if (!(use_gpio & (1 << i))) + continue; + release_region(res_base->start + ichx_priv.desc->regs[0][i], + ichx_priv.desc->reglen[i]); + } +} + +static int ichx_gpio_probe(struct platform_device *pdev) +{ + struct resource *res_base, *res_pm; + int err; + struct lpc_ich_info *ich_info = dev_get_platdata(&pdev->dev); + + if (!ich_info) + return -ENODEV; + + ichx_priv.dev = pdev; + + switch (ich_info->gpio_version) { + case ICH_I3100_GPIO: + ichx_priv.desc = &i3100_desc; + break; + case ICH_V5_GPIO: + ichx_priv.desc = &intel5_desc; + break; + case ICH_V6_GPIO: + ichx_priv.desc = &ich6_desc; + break; + case ICH_V7_GPIO: + ichx_priv.desc = &ich7_desc; + break; + case ICH_V9_GPIO: + ichx_priv.desc = &ich9_desc; + break; + case ICH_V10CORP_GPIO: + ichx_priv.desc = &ich10_corp_desc; + break; + case ICH_V10CONS_GPIO: + ichx_priv.desc = &ich10_cons_desc; + break; + case AVOTON_GPIO: + ichx_priv.desc = &avoton_desc; + break; + default: + return -ENODEV; + } + + spin_lock_init(&ichx_priv.lock); + res_base = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPIO); + ichx_priv.use_gpio = ich_info->use_gpio; + err = ichx_gpio_request_regions(res_base, pdev->name, + ichx_priv.use_gpio); + if (err) + return err; + + ichx_priv.gpio_base = res_base; + + /* + * If necessary, determine the I/O address of ACPI/power management + * registers which are needed to read the the GPE0 register for GPI pins + * 0 - 15 on some chipsets. + */ + if (!ichx_priv.desc->uses_gpe0) + goto init; + + res_pm = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPE0); + if (!res_pm) { + pr_warn("ACPI BAR is unavailable, GPI 0 - 15 unavailable\n"); + goto init; + } + + if (!request_region(res_pm->start, resource_size(res_pm), + pdev->name)) { + pr_warn("ACPI BAR is busy, GPI 0 - 15 unavailable\n"); + goto init; + } + + ichx_priv.pm_base = res_pm; + +init: + ichx_gpiolib_setup(&ichx_priv.chip); + err = gpiochip_add(&ichx_priv.chip); + if (err) { + pr_err("Failed to register GPIOs\n"); + goto add_err; + } + + pr_info("GPIO from %d to %d on %s\n", ichx_priv.chip.base, + ichx_priv.chip.base + ichx_priv.chip.ngpio - 1, DRV_NAME); + + return 0; + +add_err: + ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio); + if (ichx_priv.pm_base) + release_region(ichx_priv.pm_base->start, + resource_size(ichx_priv.pm_base)); + return err; +} + +static int ichx_gpio_remove(struct platform_device *pdev) +{ + int err; + + err = gpiochip_remove(&ichx_priv.chip); + if (err) { + dev_err(&pdev->dev, "%s failed, %d\n", + "gpiochip_remove()", err); + return err; + } + + ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio); + if (ichx_priv.pm_base) + release_region(ichx_priv.pm_base->start, + resource_size(ichx_priv.pm_base)); + + return 0; +} + +static struct platform_driver ichx_gpio_driver = { + .driver = { + .owner = THIS_MODULE, + .name = DRV_NAME, + }, + .probe = ichx_gpio_probe, + .remove = ichx_gpio_remove, +}; + +module_platform_driver(ichx_gpio_driver); + +MODULE_AUTHOR("Peter Tyser "); +MODULE_DESCRIPTION("GPIO interface for Intel ICH series"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:"DRV_NAME); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c new file mode 100644 index 00000000..a5e38353 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c @@ -0,0 +1,456 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "I2CHostCommunication.h" + +#define USE_SMBUS 1 + +/* definition */ +#define CPLD_INFO_OFFSET 0x00 +#define CPLD_RESET_OFFSET 0x08 +#define CPLD_PSU_OFFSET 0x09 +#define CPLD_LED_OFFSET 0x0E +#define CPLD_LED_STATU_OFFSET 0x0D +#define CPLD_CTL_OFFSET 0x0C + + + +/* Each client has this additional data */ +struct cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/*-----------------------------------------------------------------------*/ + +static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg[0].buf = msgbuf; + msg[0].len = 1; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + + status = i2c_transfer(client->adapter, msg, 2); + + if(status == 2) + status = count; + + return status; +#endif +} + +static ssize_t cpld_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + + return status; +#endif +} + +/*-----------------------------------------------------------------------*/ + +/* sysfs attributes for hwmon */ + +static ssize_t show_info(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //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 b[4]; + + memset(b, 0, 4); + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, b, CPLD_INFO_OFFSET, 4); + mutex_unlock(&data->update_lock); + + if(status != 4) return sprintf(buf, "read cpld info fail\n"); + + status = sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", b[2] & 0xf, (b[3] & 0x1f), 2014+(b[2] >> 4)); /* mm/dd/yyyy*/ + status = sprintf (buf, "%sThe PCB version is %X%X\n", buf, b[0]>>4, b[0]&0xf); + status = sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, b[1]>>4, b[1]&0xf); + + return strlen(buf); +} + +static ssize_t show_reset(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //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 b[1]; + + mutex_lock(&data->update_lock); + + status = cpld_i2c_read(client, b, CPLD_RESET_OFFSET, 1); + + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld reset fail\n"); + + + status = sprintf (buf, "The CPLD 1 cpld_reset = %d\n", b[0]); + + return strlen(buf); +} + +static ssize_t set_reset(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + + u8 temp = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + cpld_i2c_write(client, &temp, CPLD_RESET_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_ctl(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //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 b[1]; + + mutex_lock(&data->update_lock); + + status = cpld_i2c_read(client, b, CPLD_CTL_OFFSET, 1); + + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld ctl fail\n"); + + + status = sprintf (buf, "0x%X\n", b[0]); + + return strlen(buf); +} + +static ssize_t set_ctl(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 byte; + + u8 temp = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + cpld_i2c_read(client, &byte, CPLD_CTL_OFFSET, 1); + if(temp) byte |= (1<<0); + else byte &= ~(1<<0); + cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static char* led_str[] = { + "OFF", //000 + "0.5 Hz", //001 + "1 Hz", //010 + "2 Hz", //011 + "NA", //100 + "NA", //101 + "NA", //110 + "ON", //111 +}; + +static ssize_t show_led(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + 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 byte; + int shift = (attr->index == 0)?3:0; + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld offset 0x%x\n", CPLD_LED_OFFSET); + + byte = (byte >> shift) & 0x7; + + /* + 0: off + 1: 0.5hz + 2: 1 hz + 3: 2 hz + 4~6: not define + 7: on + */ + + status = sprintf (buf, "%d: %s\n", byte, led_str[byte]); + + return strlen(buf); +} + +static ssize_t set_led(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + + u8 temp = simple_strtol(buf, NULL, 16); + u8 byte; + int shift = (attr->index == 0)?3:0; + + temp &= 0x7; + //validate temp value: 0,1,2,3,7, TBD + + mutex_lock(&data->update_lock); + cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); + byte &= ~(0x7<update_lock); + + return count; +} + +/* +CPLD report the PSU0 status +000 = PSU normal operation +100 = PSU fault +010 = PSU unpowered +111 = PSU not installed + +7 6 | 5 4 3 | 2 1 0 +---------------------- + | psu0 | psu1 +*/ +static char* psu_str[] = { + "normal", //000 + "NA", //001 + "unpowered", //010 + "NA", //011 + "fault", //100 + "NA", //101 + "NA", //110 + "not installed", //111 +}; + +static ssize_t show_psu(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + 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 byte; + int shift = (attr->index == 1)?0:3; + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1); + mutex_unlock(&data->update_lock); + + byte = (byte >> shift) & 0x7; + + status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); + + return strlen(buf); +} + + +static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0); +static SENSOR_DEVICE_ATTR(reset, S_IWUSR|S_IRUGO, show_reset, set_reset, 0); +static SENSOR_DEVICE_ATTR(ctl, S_IWUSR|S_IRUGO, show_ctl, set_ctl, 0); + +static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_led, set_led, 0); +static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, 1); + +static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0); +static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1); + +static struct attribute *cpld_attributes[] = { + //info + &sensor_dev_attr_info.dev_attr.attr, + &sensor_dev_attr_reset.dev_attr.attr, + &sensor_dev_attr_ctl.dev_attr.attr, + + &sensor_dev_attr_grn_led.dev_attr.attr, + &sensor_dev_attr_red_led.dev_attr.attr, + + &sensor_dev_attr_psu0.dev_attr.attr, + &sensor_dev_attr_psu1.dev_attr.attr, + + NULL +}; + +static const struct attribute_group cpld_group = { + .attrs = cpld_attributes, +}; + +/*-----------------------------------------------------------------------*/ + +/* device probe and removal */ + +static int +cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct cpld_data *data; + int status; + + printk("+%s\n", __func__); + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + return -EIO; + + data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &cpld_group); + if (status) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sensor '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &cpld_group); +exit_free: + i2c_set_clientdata(client, NULL); + kfree(data); + return status; +} + +static int cpld_remove(struct i2c_client *client) +{ + struct cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &cpld_group); + i2c_set_clientdata(client, NULL); + kfree(data); + return 0; +} + +static const struct i2c_device_id cpld_ids[] = { + { "inv_cpld", 0, }, + { /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, cpld_ids); + +static struct i2c_driver cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "inv_cpld", + }, + .probe = cpld_probe, + .remove = cpld_remove, + .id_table = cpld_ids, +}; + +/*-----------------------------------------------------------------------*/ + +/* module glue */ + +static int __init inv_cpld_init(void) +{ + return i2c_add_driver(&cpld_driver); +} + +static void __exit inv_cpld_exit(void) +{ + i2c_del_driver(&cpld_driver); +} + +MODULE_AUTHOR("eddie.lan "); +MODULE_DESCRIPTION("inv cpld driver"); +MODULE_LICENSE("GPL"); + +module_init(inv_cpld_init); +module_exit(inv_cpld_exit); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c new file mode 100644 index 00000000..f046ba8c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c @@ -0,0 +1,197 @@ +#include +//#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//#include +#define IO_EXPAND_BASE 64 +#define IO_EXPAND_NGPIO 16 + +struct inv_i2c_board_info { + int ch; + int size; + struct i2c_board_info *board_info; +}; + +#define bus_id(id) (id) +static struct pca954x_platform_mode mux_modes_0[] = { + {.adap_id = bus_id(2),}, {.adap_id = bus_id(3),}, + {.adap_id = bus_id(4),}, {.adap_id = bus_id(5),}, +}; +static struct pca954x_platform_mode mux_modes_0_0[] = { + {.adap_id = bus_id(6),}, {.adap_id = bus_id(7),}, + {.adap_id = bus_id(8),}, {.adap_id = bus_id(9),}, + {.adap_id = bus_id(10),}, {.adap_id = bus_id(11),}, + {.adap_id = bus_id(12),}, {.adap_id = bus_id(13),}, +}; + +static struct pca954x_platform_mode mux_modes_0_1[] = { + {.adap_id = bus_id(14),}, {.adap_id = bus_id(15),}, + {.adap_id = bus_id(16),}, {.adap_id = bus_id(17),}, + {.adap_id = bus_id(18),}, {.adap_id = bus_id(19),}, + {.adap_id = bus_id(20),}, {.adap_id = bus_id(21),}, +}; + +static struct pca954x_platform_mode mux_modes_0_2[] = { + {.adap_id = bus_id(22),}, {.adap_id = bus_id(23),}, + {.adap_id = bus_id(24),}, {.adap_id = bus_id(25),}, + {.adap_id = bus_id(26),}, {.adap_id = bus_id(27),}, + {.adap_id = bus_id(28),}, {.adap_id = bus_id(29),}, +}; + +static struct pca954x_platform_mode mux_modes_0_3[] = { + {.adap_id = bus_id(30),}, {.adap_id = bus_id(31),}, + {.adap_id = bus_id(32),}, {.adap_id = bus_id(33),}, + {.adap_id = bus_id(34),}, {.adap_id = bus_id(35),}, + {.adap_id = bus_id(36),}, {.adap_id = bus_id(37),}, +}; + +static struct pca954x_platform_data mux_data_0 = { + .modes = mux_modes_0, + .num_modes = 4, +}; +static struct pca954x_platform_data mux_data_0_0 = { + .modes = mux_modes_0_0, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_1 = { + .modes = mux_modes_0_1, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_2 = { + .modes = mux_modes_0_2, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_3 = { + .modes = mux_modes_0_3, + .num_modes = 8, +}; + +static struct i2c_board_info i2c_device_info0[] __initdata = { + {"inv_psoc", 0, 0x66, 0, 0, 0},//psoc + {"inv_cpld", 0, 0x55, 0, 0, 0},//cpld + {"pca9545", 0, 0x70, &mux_data_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info1[] __initdata = { + {"pca9545", 0, 0x70, &mux_data_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info2[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info3[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info4[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info5[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_3, 0, 0}, +}; + + +static struct inv_i2c_board_info i2cdev_list[] = { + {0, ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //smbus 0 + {1, ARRAY_SIZE(i2c_device_info1), i2c_device_info1 }, //smbus 1 or gpio11+12 + + {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //mux 0 + {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //mux 1 + {bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //mux 2 + {bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, //mux 3 +}; + +///////////////////////////////////////////////////////////////////////////////////////// +static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { + .scl_pin = 8, + .sda_pin = 9, + + .udelay = 5, //5:100kHz + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, + .scl_is_output_only = 0 +}; + +static struct i2c_gpio_platform_data i2c_gpio_platdata1 = { + .scl_pin = 12, + .sda_pin = 11, + + .udelay = 5, //5:100kHz + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, + .scl_is_output_only = 0 +}; + +static struct platform_device device_i2c_gpio0 = { + .name = "i2c-gpio", + .id = 0, // adapter number + .dev.platform_data = &i2c_gpio_platdata0, +}; + +static struct platform_device device_i2c_gpio1 = { + .name = "i2c-gpio", + .id = 1, // adapter number + .dev.platform_data = &i2c_gpio_platdata1, +}; + +static int __init plat_redwood_x86_init(void) +{ + struct i2c_adapter *adap = NULL; + struct i2c_client *e = NULL; + int ret = 0; + int i,j; + + printk("el6661 plat_redwood_x86_init \n"); + +#if 0 //disable for ICOS + //use i2c-gpio + //register i2c gpio + //config gpio8,9 to gpio function + outl( inl(0x500) | (1<<8 | 1<<9), 0x500); + + ret = platform_device_register(&device_i2c_gpio0); + if (ret) { + printk(KERN_ERR "i2c-gpio: device_i2c_gpio0 register fail %d\n", ret); + } + + outl( inl(0x500) | (1<<11 | 1<<12), 0x500); + ret = platform_device_register(&device_i2c_gpio1); + if (ret) { + printk(KERN_ERR "i2c-gpio: device_i2c_gpio1 register fail %d\n", ret); + } +#endif + + for(i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "I2CHostCommunication.h" + +#define USE_SMBUS 1 + +//#define offsetof(st, m) ((size_t)(&((st *)0)->m)) +#define FAN_NUM 5 +#define PSU_NUM 2 + +struct __attribute__ ((__packed__)) psoc_psu_layout { + u16 psu1_iin; + u16 psu2_iin; + u16 psu1_iout; + u16 psu2_iout; + + u16 psu1_pin; + u16 psu2_pin; + u16 psu1_pout; + u16 psu2_pout; + + u16 psu1_vin; + u16 psu2_vin; + u16 psu1_vout; + u16 psu2_vout; +}; + +struct __attribute__ ((__packed__)) psoc_layout { + u8 ctl; //offset: 0 + u16 switch_temp; //offset: 1 + u8 reserve1; //offset: 3 + + u8 fw_upgrade; //offset: 4 + + //i2c bridge + u8 i2c_st; //offset: 5 + u8 i2c_ctl; //offset: 6 + u8 i2c_addr; //offset: 7 + u8 i2c_data[0x20]; //offset: 8 + + //gpo + u8 led_grn; //offset: 28 + u8 led_red; //offset: 29 + + //pwm duty + u8 pwm[FAN_NUM]; //offset: 2a + u8 pwm_psu[PSU_NUM]; //offset: 2f + + //fan rpm + u16 fan[FAN_NUM*2]; //offset: 31 + //u16 fan_psu[PSU_NUM]; + + //gpi + u8 gpi_fan; //offset: 45 + + //psu state + u8 psu_state; //offset: 46 + + //temperature + u16 temp[5]; //offset: 47 + u16 temp_psu[PSU_NUM]; //offset: 51 + + //version + u8 version[2]; //offset: 55 + + u8 reserve2[3]; //offset: 57 + struct psoc_psu_layout psu_info; //offset: 5a +}; + + +/* definition */ +#define PSOC_OFF(m) offsetof(struct psoc_layout, m) +#define PSOC_PSU_OFF(m) offsetof(struct psoc_psu_layout, m) + +#define SWITCH_TMP_OFFSET PSOC_OFF(switch_temp) //0x01 +#define PWM_OFFSET PSOC_OFF(pwm) +#define PWM_PSU_OFFSET PSOC_OFF(pwm_psu) +#define THERMAL_OFFSET PSOC_OFF(temp) +#define RPM_OFFSET PSOC_OFF(fan) +//#define RPM_PSU_OFFSET PSOC_OFF(fan_psu) +#define DIAG_FLAG_OFFSET PSOC_OFF(ctl) +#define FAN_LED_OFFSET PSOC_OFF(led_grn) +#define FAN_GPI_OFFSET PSOC_OFF(gpi_fan) +#define PSOC_PSU_OFFSET PSOC_OFF(psu_state) +#define VERSION_OFFSET PSOC_OFF(version) +#define PSU_INFO_OFFSET PSOC_OFF(psu_info) + + +/* Each client has this additional data */ +struct psoc_data { + struct device *hwmon_dev; + struct mutex update_lock; + u32 diag; +}; + +/*-----------------------------------------------------------------------*/ + +static ssize_t psoc_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg[0].buf = msgbuf; + msg[0].len = 1; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + + status = i2c_transfer(client->adapter, msg, 2); + + if(status == 2) + status = count; + + return status; +#endif +} + +static ssize_t psoc_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + + return status; +#endif +} + +static u32 psoc_read32(struct i2c_client *client, u8 offset) +{ + u32 value = 0; + u8 buf[4]; + + if( psoc_i2c_read(client, buf, offset, 4) == 4) + value = (buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3]); + + return value; +} + +static u16 psoc_read16(struct i2c_client *client, u8 offset) +{ + u16 value = 0; + u8 buf[2]; + + if(psoc_i2c_read(client, buf, offset, 2) == 2) + value = (buf[0]<<8 | buf[1]<<0); + + return value; +} + +static u8 psoc_read8(struct i2c_client *client, u8 offset) +{ + u8 value = 0; + u8 buf = 0; + + if(psoc_i2c_read(client, &buf, offset, 1) == 1) + value = buf; + + return value; +} + +static int psoc_write_value(struct i2c_client *client, unsigned offset, u16 value) +{ + //TBD + return 0; +} + + +//PSOC i2c bridge regsters +#define PSOC_I2C_STATUS PSOC_OFF(i2c_st) +#define PSOC_I2C_CNTRL PSOC_OFF(i2c_ctl) +#define PSOC_I2C_ADDR PSOC_OFF(i2c_addr) +#define PSOC_I2C_DATA PSOC_OFF(i2c_data) + +//status bit definition +#define PSOC_I2C_START (1 << 0) +#define PSOC_PMB_SEL (1 << 7) + +//addr bits definition +#define PSOC_I2C_READ (1 << 0) + +//PMBUS registers definition +#define PMBUS_READ_VIN (0x88) +#define PMBUS_READ_IIN (0x89) +#define PMBUS_READ_VOUT (0x8B) +#define PMBUS_READ_IOUT (0x8C) +#define PMBUS_READ_POUT (0x96) +#define PMBUS_READ_PIN (0x97) + +#define PMBUS_MFR_ID (0x99) +#define PMBUS_MFR_MODEL (0x9A) +#define PMBUS_MFR_REVISION (0x9B) +#define PMBUS_MFR_DATE (0x9D) +#define PMBUS_MFR_SERIAL (0x9E) + +static int psoc_i2c_bridge_read(struct i2c_client *client, + unsigned char bus, + unsigned char chip, + char *addr, int alen, + unsigned char *data, int len ) +{ + unsigned char txdata[28], rxdata[28]; + int index, timeout; + + txdata[PSOC_I2C_STATUS] = 0; /* the status */ + txdata[PSOC_I2C_CNTRL] = ((alen & 3) << 5) | (len & 0x1f); /* the sizes */ + txdata[PSOC_I2C_ADDR] = (chip << 1) | PSOC_I2C_READ; /* read address */ + for(index = 0; index < alen; index++) + txdata[PSOC_I2C_DATA + index] = addr[index]; /* the chip address */ + for(; index < alen+len; index++) + txdata[PSOC_I2C_DATA + index] = 0; /* clear the chip data */ + + psoc_i2c_write(client, &txdata[PSOC_I2C_CNTRL], PSOC_I2C_CNTRL, 2 + alen + len); + + //delay a while ??? + //--------------------------------------------------------------------- + //start write + txdata[PSOC_I2C_STATUS] = PSOC_I2C_START; /* the start bit*/ + if(bus) + txdata[PSOC_I2C_STATUS] |= PSOC_PMB_SEL;/* bus id */ + psoc_i2c_write(client, &txdata[PSOC_I2C_STATUS], PSOC_I2C_STATUS, 1); + + //delay a while + timeout = 40; //40*20==>800 ms + do { + psoc_i2c_read(client, &rxdata[PSOC_I2C_STATUS], PSOC_I2C_STATUS, 1); + + //check rxdata[5] error bit(1) and complete bit(0) ,TBD + if((rxdata[PSOC_I2C_STATUS] & 0x2) == 0x2) { + //printk("i2c bridge fail!!!\n"); + timeout = 0; + break; + } + if((rxdata[PSOC_I2C_STATUS] & PSOC_I2C_START) == 0) { + /* comand complete */ + psoc_i2c_read(client, &rxdata[PSOC_I2C_DATA+alen], PSOC_I2C_DATA+alen, len); + break; + } + + //delay + msleep(20); + } while(timeout--); + + if(timeout <= 0) { + return -1; + } + + //--------------------------------------------------------------------- + + for(index=0; index < len; index++) { + data[index] = rxdata[PSOC_I2C_DATA + alen + index]; + } + + return 0; +} + + +/* +CPLD report the PSU0 status +000 = PSU normal operation +100 = PSU fault +010 = PSU unpowered +111 = PSU not installed + +7 6 | 5 4 3 | 2 1 0 +---------------------- + | psu1 | psu0 +*/ +static char* psu_str[] = { + "normal", //000 + "NA", //001 + "unpowered", //010 + "NA", //011 + "fault", //100 + "NA", //101 + "NA", //110 + "not installed", //111 +}; + +static ssize_t show_psu_st(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 byte; + int shift = (attr->index == 0)?3:0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET, 1); + mutex_unlock(&data->update_lock); + + byte = (byte >> shift) & 0x7; + + status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); + + return strlen(buf); +} + +/*-----------------------------------------------------------------------*/ + +/* sysfs attributes for hwmon */ + +static ssize_t show_thermal(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index * 2 + THERMAL_OFFSET; + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, offset); + status = __swab16(status); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + (s8)(status>>8) * 1000 ); +} + + +static ssize_t show_pwm(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + status); +} + +static ssize_t set_pwm(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + u8 pwm = simple_strtol(buf, NULL, 10); + if(pwm > 255) pwm = 255; + + if(data->diag) { + mutex_lock(&data->update_lock); + psoc_i2c_write(client, &pwm, offset, 1); + mutex_unlock(&data->update_lock); + } + + return count; +} + + +static ssize_t show_rpm(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, offset); + status = __swab16(status); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + status); +} +static ssize_t show_fan_type(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 index = attr->index; + int type = -1; + + mutex_lock(&data->update_lock); + status = psoc_read8(client, FAN_GPI_OFFSET); + mutex_unlock(&data->update_lock); + + if( (status & 1<update_lock); + status = psoc_i2c_read(client, (u8*)&temp, SWITCH_TMP_OFFSET, 2); + status = __swab16(status); + mutex_unlock(&data->update_lock); + + status = sprintf (buf, "%d\n", (s8)(temp>>8) * 1000 ); + + return strlen(buf); +} + +static ssize_t set_switch_tmp(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + + long temp = simple_strtol(buf, NULL, 10); + u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; + + //printk("set_switch_tmp temp=%d, temp2=0x%x (%x,%x)\n", temp, temp2, ( ( (temp/1000) <<8 ) & 0xFF00 ), (( (temp%1000) / 10 ) & 0xFF)); + + mutex_lock(&data->update_lock); + psoc_i2c_write(client, (u8*)&temp2, SWITCH_TMP_OFFSET, 2); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_diag(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 diag_flag = 0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, (u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); + mutex_unlock(&data->update_lock); + + data->diag = (diag_flag & 0x80)?1:0; + status = sprintf (buf, "%d\n", data->diag); + + return strlen(buf); +} + +static ssize_t set_diag(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 value = 0; + u8 diag = simple_strtol(buf, NULL, 10); + + diag = diag?1:0; + data->diag = diag; + + mutex_lock(&data->update_lock); + psoc_i2c_read(client, (u8*)&value, DIAG_FLAG_OFFSET, 1); + if(diag) value |= (1<<7); + else value &= ~(1<<7); + psoc_i2c_write(client, (u8*)&value, DIAG_FLAG_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, VERSION_OFFSET); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "ver: %x.%x\n", (status & 0xFF00)>>8, (status & 0xFF) ); +} + + +static ssize_t show_fan_led(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 bit = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, FAN_LED_OFFSET); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + (status & (1<index; + u8 led_state = 0; + + u8 v = simple_strtol(buf, NULL, 10); + + if(data->diag) { + mutex_lock(&data->update_lock); + led_state = psoc_read8(client, FAN_LED_OFFSET); + if(v) led_state |= (1<update_lock); + } + + return count; +} + +static ssize_t show_value8(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "0x%02X\n", status ); +} + +static long pmbus_reg2data_linear(int data, int linear16) +{ + s16 exponent; + s32 mantissa; + long val; + + if (linear16) { /* LINEAR16 */ + exponent = -9; + mantissa = (u16) data; + } else { /* LINEAR11 */ + exponent = ((s16)data) >> 11; + exponent = ((s16)( data & 0xF800) ) >> 11; + mantissa = ((s32)((data & 0x7ff) << 5)) >> 5; + } + + //printk("data=%d, m=%d, e=%d\n", data, exponent, mantissa); + val = mantissa; + + /* scale result to micro-units for power sensors */ + val = val * 1000L; + + if (exponent >= 0) + val <<= exponent; + else + val >>= -exponent; + + return val; +} + +static ssize_t show_psu(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 reg = attr->index & 0xFF; + u8 len = ((attr->index & 0xFF00) >> 8); + u8 chip = (attr->index >> 16)? 0x59:0x58; + u8 bus = 1; + unsigned char value[2] = {0,0};; + + if (len == 2) + { + mutex_lock(&data->update_lock); + psoc_i2c_bridge_read(client, bus, chip, ®, 1, value, 2); + mutex_unlock(&data->update_lock); + + status = value[1]<<8 | value[0]; + //status1 = value[1]<<8 | value[0]; + + return sprintf(buf, "%ld\n", pmbus_reg2data_linear(status, (reg==PMBUS_READ_VOUT)?1:0) ); + } + else + { //len is not defined. + u8 tmpbuf[32]; + mutex_lock(&data->update_lock); + //length of block read + psoc_i2c_bridge_read(client, bus, chip, ®, 1, &len, 1); + //data included length + psoc_i2c_bridge_read(client, bus, chip, ®, 1, tmpbuf, len+1); + mutex_unlock(&data->update_lock); + + memcpy(buf, tmpbuf+1, len); + buf[len]='\n'; + + return len+1; + } +} + +static ssize_t show_psu_psoc(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index + PSU_INFO_OFFSET; + + mutex_lock(&data->update_lock); + status = psoc_read16(client, offset); + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, strstr(attr->dev_attr.attr.name, "vout")? 1:0 )); +} + + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_thermal, 0, 0); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_thermal, 0, 1); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_thermal, 0, 2); +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_thermal, 0, 3); +static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_thermal, 0, 4); +static SENSOR_DEVICE_ATTR(thermal_psu1, S_IRUGO, show_thermal, 0, 5); +static SENSOR_DEVICE_ATTR(thermal_psu2, S_IRUGO, show_thermal, 0, 6); + +static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+0); +static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+1); +static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+2); +static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+3); +#if (FAN_NUM >= 5) +static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+4); +#endif +static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_PSU_OFFSET+0); +static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_PSU_OFFSET+1); + +static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu_st, 0, 0); +static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 1); + +static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_rpm, 0, 0*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_rpm, 0, 1*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_rpm, 0, 2*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_rpm, 0, 3*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_rpm, 0, 4*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_rpm, 0, 5*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_rpm, 0, 6*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_rpm, 0, 7*2 + RPM_OFFSET); +#if (FAN_NUM >= 5) +static SENSOR_DEVICE_ATTR(fan9_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); +#endif +static SENSOR_DEVICE_ATTR(rpm_psu1, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(rpm_psu2, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); + +static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); + +static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0); +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, 0, 0); + +static SENSOR_DEVICE_ATTR(fan_led_grn1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); +static SENSOR_DEVICE_ATTR(fan_led_grn2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1); +static SENSOR_DEVICE_ATTR(fan_led_grn3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2); +static SENSOR_DEVICE_ATTR(fan_led_grn4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3); +static SENSOR_DEVICE_ATTR(fan_led_red1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4); +static SENSOR_DEVICE_ATTR(fan_led_red2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5); +static SENSOR_DEVICE_ATTR(fan_led_red3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6); +static SENSOR_DEVICE_ATTR(fan_led_red4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 7); + +static SENSOR_DEVICE_ATTR(fan_gpi, S_IRUGO, show_value8, 0, FAN_GPI_OFFSET); +static SENSOR_DEVICE_ATTR(fan1_type, S_IRUGO, show_fan_type, 0, 0); +static SENSOR_DEVICE_ATTR(fan2_type, S_IRUGO, show_fan_type, 0, 1); +static SENSOR_DEVICE_ATTR(fan3_type, S_IRUGO, show_fan_type, 0, 2); +static SENSOR_DEVICE_ATTR(fan4_type, S_IRUGO, show_fan_type, 0, 3); + +static SENSOR_DEVICE_ATTR(psu1_vin, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_VIN); +static SENSOR_DEVICE_ATTR(psu1_vout, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_VOUT); +static SENSOR_DEVICE_ATTR(psu1_iin, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_IIN); +static SENSOR_DEVICE_ATTR(psu1_iout, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_IOUT); +static SENSOR_DEVICE_ATTR(psu1_pin, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_PIN); +static SENSOR_DEVICE_ATTR(psu1_pout, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_POUT); + +static SENSOR_DEVICE_ATTR(psu1_vendor, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_ID); +static SENSOR_DEVICE_ATTR(psu1_model, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu1_version, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_REVISION); +static SENSOR_DEVICE_ATTR(psu1_date, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_DATE); +static SENSOR_DEVICE_ATTR(psu1_sn, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_SERIAL); + +static SENSOR_DEVICE_ATTR(psu2_vin, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_VIN); +static SENSOR_DEVICE_ATTR(psu2_vout, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_VOUT); +static SENSOR_DEVICE_ATTR(psu2_iin, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_IIN); +static SENSOR_DEVICE_ATTR(psu2_iout, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_IOUT); +static SENSOR_DEVICE_ATTR(psu2_pin, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_PIN); +static SENSOR_DEVICE_ATTR(psu2_pout, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_POUT); + +static SENSOR_DEVICE_ATTR(psu2_vendor, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_ID); +static SENSOR_DEVICE_ATTR(psu2_model, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu2_version, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_REVISION); +static SENSOR_DEVICE_ATTR(psu2_date, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_DATE); +static SENSOR_DEVICE_ATTR(psu2_sn, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_SERIAL); + +static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); +static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); +static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pout)); + + +static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); +static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); +static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); + +static struct attribute *psoc_attributes[] = { + //thermal + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp4_input.dev_attr.attr, + &sensor_dev_attr_temp5_input.dev_attr.attr, + + &sensor_dev_attr_thermal_psu1.dev_attr.attr, + &sensor_dev_attr_thermal_psu2.dev_attr.attr, + + + //pwm + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm2.dev_attr.attr, + &sensor_dev_attr_pwm3.dev_attr.attr, + &sensor_dev_attr_pwm4.dev_attr.attr, +#if (FAN_NUM >= 5) + //&sensor_dev_attr_pwm5.dev_attr.attr, +#endif + &sensor_dev_attr_pwm_psu1.dev_attr.attr, + &sensor_dev_attr_pwm_psu2.dev_attr.attr, + + //rpm + &sensor_dev_attr_fan1_input.dev_attr.attr, + &sensor_dev_attr_fan2_input.dev_attr.attr, + &sensor_dev_attr_fan3_input.dev_attr.attr, + &sensor_dev_attr_fan4_input.dev_attr.attr, + &sensor_dev_attr_fan5_input.dev_attr.attr, + &sensor_dev_attr_fan6_input.dev_attr.attr, + &sensor_dev_attr_fan7_input.dev_attr.attr, + &sensor_dev_attr_fan8_input.dev_attr.attr, +#if (FAN_NUM >= 5) + //&sensor_dev_attr_fan9_input.dev_attr.attr, + //&sensor_dev_attr_fan10_input.dev_attr.attr, +#endif + + &sensor_dev_attr_rpm_psu1.dev_attr.attr, + &sensor_dev_attr_rpm_psu2.dev_attr.attr, + + //switch temperature + &sensor_dev_attr_switch_tmp.dev_attr.attr, + + //diag flag + &sensor_dev_attr_diag.dev_attr.attr, + + //version + &sensor_dev_attr_version.dev_attr.attr, + + //fan led + &sensor_dev_attr_fan_led_grn1.dev_attr.attr, + &sensor_dev_attr_fan_led_grn2.dev_attr.attr, + &sensor_dev_attr_fan_led_grn3.dev_attr.attr, + &sensor_dev_attr_fan_led_grn4.dev_attr.attr, + &sensor_dev_attr_fan_led_red1.dev_attr.attr, + &sensor_dev_attr_fan_led_red2.dev_attr.attr, + &sensor_dev_attr_fan_led_red3.dev_attr.attr, + &sensor_dev_attr_fan_led_red4.dev_attr.attr, + + //fan GPI + &sensor_dev_attr_fan_gpi.dev_attr.attr, + + //fan type + &sensor_dev_attr_fan1_type.dev_attr.attr, + &sensor_dev_attr_fan2_type.dev_attr.attr, + &sensor_dev_attr_fan3_type.dev_attr.attr, + &sensor_dev_attr_fan4_type.dev_attr.attr, + + //psu + &sensor_dev_attr_psu1_vin.dev_attr.attr, + &sensor_dev_attr_psu1_vout.dev_attr.attr, + &sensor_dev_attr_psu1_iin.dev_attr.attr, + &sensor_dev_attr_psu1_iout.dev_attr.attr, + &sensor_dev_attr_psu1_pin.dev_attr.attr, + &sensor_dev_attr_psu1_pout.dev_attr.attr, + &sensor_dev_attr_psu2_vin.dev_attr.attr, + &sensor_dev_attr_psu2_vout.dev_attr.attr, + &sensor_dev_attr_psu2_iin.dev_attr.attr, + &sensor_dev_attr_psu2_iout.dev_attr.attr, + &sensor_dev_attr_psu2_pin.dev_attr.attr, + &sensor_dev_attr_psu2_pout.dev_attr.attr, + + &sensor_dev_attr_psu1_vendor.dev_attr.attr, + &sensor_dev_attr_psu1_model.dev_attr.attr, + &sensor_dev_attr_psu1_version.dev_attr.attr, + &sensor_dev_attr_psu1_date.dev_attr.attr, + &sensor_dev_attr_psu1_sn.dev_attr.attr, + &sensor_dev_attr_psu2_vendor.dev_attr.attr, + &sensor_dev_attr_psu2_model.dev_attr.attr, + &sensor_dev_attr_psu2_version.dev_attr.attr, + &sensor_dev_attr_psu2_date.dev_attr.attr, + &sensor_dev_attr_psu2_sn.dev_attr.attr, + + &sensor_dev_attr_psu0.dev_attr.attr, + &sensor_dev_attr_psu1.dev_attr.attr, + + //psu_psoc, new added on psoc 1.9 + &sensor_dev_attr_psoc_psu1_vin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_vout.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_iin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_iout.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_pin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_pout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_iin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_iout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_pin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_pout.dev_attr.attr, + + NULL +}; + +static const struct attribute_group psoc_group = { + .attrs = psoc_attributes, +}; + +/*-----------------------------------------------------------------------*/ + +/* device probe and removal */ + +static int +psoc_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct psoc_data *data; + int status; + + printk("+%s\n", __func__); + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + return -EIO; + + data = kzalloc(sizeof(struct psoc_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->diag = 0; + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &psoc_group); + if (status) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sensor '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &psoc_group); +exit_free: + i2c_set_clientdata(client, NULL); + kfree(data); + return status; +} + +static int psoc_remove(struct i2c_client *client) +{ + struct psoc_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &psoc_group); + i2c_set_clientdata(client, NULL); + kfree(data); + return 0; +} + +static const struct i2c_device_id psoc_ids[] = { + { "inv_psoc", 0, }, + { /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, psoc_ids); + +static struct i2c_driver psoc_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "inv_psoc", + }, + .probe = psoc_probe, + .remove = psoc_remove, + .id_table = psoc_ids, +}; + +/*-----------------------------------------------------------------------*/ + +/* module glue */ + +static int __init inv_psoc_init(void) +{ + return i2c_add_driver(&psoc_driver); +} + +static void __exit inv_psoc_exit(void) +{ + i2c_del_driver(&psoc_driver); +} + +MODULE_AUTHOR("eddie.lan "); +MODULE_DESCRIPTION("inv psoc driver"); +MODULE_LICENSE("GPL"); + +module_init(inv_psoc_init); +module_exit(inv_psoc_exit); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml new file mode 100644 index 00000000..ea6da9a1 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d7032q28b ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile new file mode 100644 index 00000000..e8a03987 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-inventec-d7032q28b +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_inventec_d7032q28b onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-inventec-d7032q28b.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..c5c87ab8 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_inventec_d7032q28b onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module new file mode 100644 index 00000000..a41675eb --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_inventec_d7032q28b diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile new file mode 100644 index 00000000..f3ba68e3 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_inventec_d7032q28b +AUTOMODULE := x86_64_inventec_d7032q28b +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..30860504 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_inventec_d7032q28b Autogeneration +# +############################################################################### +x86_64_inventec_d7032q28b_AUTO_DEFS := module/auto/x86_64_inventec_d7032q28b.yml +x86_64_inventec_d7032q28b_AUTO_DIRS := module/inc/x86_64_inventec_d7032q28b module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml new file mode 100644 index 00000000..cd4ae278 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_inventec_d7032q28b Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB +- x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + x86_64_inventec_d7032q28b_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_inventec_d7032q28b_config + + portingmacro: + x86_64_inventec_d7032q28b: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x new file mode 100644 index 00000000..47142477 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h new file mode 100644 index 00000000..232518dc --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_inventec_d7032q28b Configuration Header + * + * @addtogroup x86_64_inventec_d7032q28b-config + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_CONFIG_H__ +#define __x86_64_inventec_d7032q28b_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef x86_64_inventec_d7032q28b_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING +#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT +#define x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT +#define x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB +#define x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI +#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_inventec_d7032q28b_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_inventec_d7032q28b_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_inventec_d7032q28b_config_settings table. */ +extern x86_64_inventec_d7032q28b_config_settings_t x86_64_inventec_d7032q28b_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_inventec_d7032q28b_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_inventec_d7032q28b_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_inventec_d7032q28b_porting.h" + +#endif /* __x86_64_inventec_d7032q28b_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h new file mode 100644 index 00000000..727ff26a --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_inventec_d7032q28b Doxygen Header + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_DOX_H__ +#define __x86_64_inventec_d7032q28b_DOX_H__ + +/** + * @defgroup x86_64_inventec_d7032q28b x86_64_inventec_d7032q28b - x86_64_inventec_d7032q28b Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_inventec_d7032q28b-x86_64_inventec_d7032q28b Public Interface + * @defgroup x86_64_inventec_d7032q28b-config Compile Time Configuration + * @defgroup x86_64_inventec_d7032q28b-porting Porting Macros + * + * @} + * + */ + +#endif /* __x86_64_inventec_d7032q28b_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h new file mode 100644 index 00000000..55950ecd --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_inventec_d7032q28b Porting Macros. + * + * @addtogroup x86_64_inventec_d7032q28b-porting + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_PORTING_H__ +#define __x86_64_inventec_d7032q28b_PORTING_H__ + + +/* */ +#if x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_inventec_d7032q28b_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_inventec_d7032q28b_MALLOC GLOBAL_MALLOC + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_MALLOC malloc + #else + #error The macro x86_64_inventec_d7032q28b_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_FREE + #if defined(GLOBAL_FREE) + #define x86_64_inventec_d7032q28b_FREE GLOBAL_FREE + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_FREE free + #else + #error The macro x86_64_inventec_d7032q28b_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_inventec_d7032q28b_MEMSET GLOBAL_MEMSET + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_MEMSET memset + #else + #error The macro x86_64_inventec_d7032q28b_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_inventec_d7032q28b_MEMCPY GLOBAL_MEMCPY + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_MEMCPY memcpy + #else + #error The macro x86_64_inventec_d7032q28b_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_inventec_d7032q28b_STRNCPY GLOBAL_STRNCPY + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_STRNCPY strncpy + #else + #error The macro x86_64_inventec_d7032q28b_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_inventec_d7032q28b_VSNPRINTF GLOBAL_VSNPRINTF + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_VSNPRINTF vsnprintf + #else + #error The macro x86_64_inventec_d7032q28b_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_inventec_d7032q28b_SNPRINTF GLOBAL_SNPRINTF + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_SNPRINTF snprintf + #else + #error The macro x86_64_inventec_d7032q28b_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_inventec_d7032q28b_STRLEN GLOBAL_STRLEN + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_STRLEN strlen + #else + #error The macro x86_64_inventec_d7032q28b_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __x86_64_inventec_d7032q28b_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..cec02d5e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_inventec_d7032q28b_INCLUDES := -I $(THIS_DIR)inc +x86_64_inventec_d7032q28b_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_inventec_d7032q28b_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d7032q28b ucli:x86_64_inventec_d7032q28b + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..f82e1a89 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_inventec_d7032q28b_ucli.c + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c new file mode 100644 index 00000000..7831ccc8 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c @@ -0,0 +1,45 @@ +#include "x86_64_inventec_d7032q28b_int.h" + +#if x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEBUG == 1 + +#include + +static char help__[] = + "Usage: debug [options]\n" + " -c CPLD Versions\n" + " -h Help\n" + ; + +int +x86_64_inventec_d7032q28b_debug_main(int argc, char* argv[]) +{ + int c = 0; + int help = 0; + int rv = 0; + + while( (c = getopt(argc, argv, "ch")) != -1) { + switch(c) + { + case 'c': c = 1; break; + case 'h': help = 1; rv = 0; break; + default: help = 1; rv = 1; break; + } + + } + + if(help || argc == 1) { + printf("%s", help__); + return rv; + } + + if(c) { + printf("Not implemented.\n"); + } + + + return 0; +} + +#endif + + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..5fd76b00 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c @@ -0,0 +1,402 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define PREFIX_PATH_ON_MAIN_BOARD "/sys/bus/i2c/devices/2-0066/" +#define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 18000 +#define MAX_PSU_FAN_SPEED 25500 + +#define PROJECT_NAME +#define LEN_FILE_NAME 80 + +#define FAN_RESERVED 0 +#define FAN_1_ON_MAIN_BOARD 1 +#define FAN_2_ON_MAIN_BOARD 2 +#define FAN_3_ON_MAIN_BOARD 3 +#define FAN_4_ON_MAIN_BOARD 4 +#define FAN_5_ON_MAIN_BOARD 5 +#define FAN_6_ON_MAIN_BOARD 6 +#define FAN_1_ON_PSU1 7 +#define FAN_1_ON_PSU2 8 + +typedef struct fan_path_S +{ + char present[LEN_FILE_NAME]; + char status[LEN_FILE_NAME]; + char speed[LEN_FILE_NAME]; + char direction[LEN_FILE_NAME]; + char ctrl_speed[LEN_FILE_NAME]; + char r_speed[LEN_FILE_NAME]; +}fan_path_T; + +#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ + { #prj"fan"#id"_present", #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \ + #prj"fan"#id"_direction", #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) + +#define MAKE_FAN_PATH_ON_PSU(folder) \ + {"", #folder"/psu_fan1_fault", #folder"/psu_fan1_speed_rpm", \ + "", #folder"/psu_fan1_duty_cycle_percentage", "" } + +static fan_path_T fan_path[] = /* must map with onlp_fan_id */ +{ + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_5_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_6_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_PSU(11-005b), + MAKE_FAN_PATH_ON_PSU(10-0058) +}; + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } 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 + +static uint32_t +_onlp_fani_info_get_psu_fan_direction(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_DC_48V_F2B: + case PSU_TYPE_DC_12V_F2B: + return ONLP_FAN_STATUS_F2B; + case PSU_TYPE_AC_B2F: + case PSU_TYPE_DC_48V_B2F: + case PSU_TYPE_DC_12V_B2F: + return ONLP_FAN_STATUS_B2F; + default: + return 0; + }; + } + + return 0; +} + +static int +_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) +{ + int fd, len, nbytes = 10; + char r_data[10] = {0}; + char fullpath[65] = {0}; + + /* check if fan is present + */ + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].present); + OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); + if (atoi(r_data) == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan fault status (turn on when any one fails) + */ + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status); + 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/fanr direction (both : the same) + */ + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].direction); + OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); + + if (atoi(r_data) == 0) /*B2F*/ + info->status |= ONLP_FAN_STATUS_B2F; + else + info->status |= ONLP_FAN_STATUS_F2B; + + /* get fan speed (take the min from two speeds) + */ + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed); + OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); + info->rpm = atoi(r_data); + + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed); + OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); + if (info->rpm > atoi(r_data)) { + info->rpm = atoi(r_data); + } + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) +{ + int fd, len, nbytes = 10; + char r_data[10] = {0}; + char fullpath[80] = {0}; + + /* get fan direction + */ + info->status |= _onlp_fani_info_get_psu_fan_direction(); + + /* get fan fault status + */ + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status); + OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); + info->status |= (atoi(r_data) > 0) ? ONLP_FAN_STATUS_FAILED : 0; + + /* get fan speed + */ + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed); + OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); + info->rpm = atoi(r_data); + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + info->status |= ONLP_FAN_STATUS_PRESENT; + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = linfo[local_id]; + + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + rc = _onlp_fani_info_get_fan_on_psu(local_id, info); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + case FAN_3_ON_MAIN_BOARD: + case FAN_4_ON_MAIN_BOARD: + case FAN_5_ON_MAIN_BOARD: + case FAN_6_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fd, len, nbytes=10, local_id; + char data[10] = {0}; + char fullpath[70] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + /* get fullpath */ + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + case FAN_3_ON_MAIN_BOARD: + case FAN_4_ON_MAIN_BOARD: + case FAN_5_ON_MAIN_BOARD: + case FAN_6_ON_MAIN_BOARD: + sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].ctrl_speed); + break; + default: + return ONLP_STATUS_E_INVALID; + } + sprintf(data, "%d", p); + DEBUG_PRINT("[Debug][%s][%d][openfile: %s][data=%s]\n", __FUNCTION__, __LINE__, fullpath, data); + + /* Create output file descriptor */ + fd = open(fullpath, O_WRONLY, 0644); + if (fd == -1){ + return ONLP_STATUS_E_INTERNAL; + } + + len = write (fd, data, (ssize_t) nbytes); + if (len != nbytes) { + close(fd); + return ONLP_STATUS_E_INTERNAL; + } + + close(fd); + return ONLP_STATUS_OK; +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..3c86a173 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,263 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/inventec_d7032q28b_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * Diag LED Off + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (deviceNodeReadString(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (deviceNodeWriteInt(fullpath, onlp_to_driver_led_mode(local_id, mode), 0) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..6176a32e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_inventec_d7032q28b +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..b4ef2d04 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,200 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +int deviceNodeWrite(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { + return -1; + } + + if ((len = write(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int deviceNodeWriteInt(char *filename, int value, int data_len) +{ + char buf[8] = {0}; + sprintf(buf, "%d", value); + + return deviceNodeWrite(filename, buf, (int)strlen(buf), data_len); +} + +int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_RDONLY)) == -1) { + return -1; + } + + if ((len = read(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = deviceNodeReadBinary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 11 +#define I2C_PSU_FAN_DIR_LEN 3 +#include +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name); + + if (deviceNodeReadString(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if(isspace(model_name[strlen(model_name)-1])) { + model_name[strlen(model_name)-1] = 0; + } + + if (strncmp(model_name, "YM-2651Y", 8) == 0) { + if (modelname) { + strncpy(modelname, model_name, 8); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + } + + if (strncmp(model_name, "YM-2651V", 8) == 0) { + if (modelname) { + strncpy(modelname, model_name, 8); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_DC_48V_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_DC_48V_B2F; + } + } + + if (strncmp(model_name, "PSU-12V-750", 11) == 0) { + if (modelname) { + strncpy(modelname, model_name, 11); + } + + node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_fan_dir) : PSU2_AC_HWMON_NODE(psu_fan_dir); + if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", 3) == 0) { + return PSU_TYPE_DC_12V_F2B; + } + + if (strncmp(fan_dir, "B2F", 3) == 0) { + return PSU_TYPE_DC_12V_B2F; + } + + if (strncmp(fan_dir, "NON", 3) == 0) { + return PSU_TYPE_DC_12V_FANLESS; + } + } + + return PSU_TYPE_UNKNOWN; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..0ae3c77f --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,77 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_inventec_d7032q28b_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/11-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/10-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/11-0053/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/10-0050/" + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom" + +int deviceNodeWriteInt(char *filename, int value, int data_len); +int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len); +int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_len); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F, + PSU_TYPE_DC_48V_F2B, + PSU_TYPE_DC_48V_B2F, + PSU_TYPE_DC_12V_FANLESS, + PSU_TYPE_DC_12V_F2B, + PSU_TYPE_DC_12V_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..88c02f03 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c @@ -0,0 +1,271 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; + char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(node_path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(node_path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + + ret = deviceNodeReadString(node_path, buf, sizeof(buf), 0); + + if (ret == 0) { + *value = atoi(buf); + } + + return ret; +} + +static int +psu_ym2651_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; + char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(node_path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + ret = deviceNodeReadString(node_path, buf, sizeof(buf), 0); + + if (ret == 0) { + *value = atoi(buf); + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +#include +#define DC12V_750_REG_TO_CURRENT(low, high) (((low << 4 | high >> 4) * 20 * 1000) / 754) +#define DC12V_750_REG_TO_VOLTAGE(low, high) ((low << 4 | high >> 4) * 25) + +static int +psu_dc12v_750_info_get(onlp_psu_info_t* info) +{ + int pid = ONLP_OID_ID_GET(info->hdr.id); + int bus = (PSU1_ID == pid) ? 11 : 10; + int iout_low, iout_high; + int vout_low, vout_high; + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_DC12; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Get current + */ + iout_low = onlp_i2c_readb(bus, 0x6f, 0x0, ONLP_I2C_F_FORCE); + iout_high = onlp_i2c_readb(bus, 0x6f, 0x1, ONLP_I2C_F_FORCE); + + if ((iout_low >= 0) && (iout_high >= 0)) { + info->miout = DC12V_750_REG_TO_CURRENT(iout_low, iout_high); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Get voltage + */ + vout_low = onlp_i2c_readb(bus, 0x6f, 0x2, ONLP_I2C_F_FORCE); + vout_high = onlp_i2c_readb(bus, 0x6f, 0x3, ONLP_I2C_F_FORCE); + + if ((vout_low >= 0) && (vout_high >= 0)) { + info->mvout = DC12V_750_REG_TO_VOLTAGE(vout_low, vout_high); + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get power based on current and voltage + */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_VOUT)) { + info->mpout = (info->miout * info->mvout) / 1000; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + info->caps = ONLP_PSU_CAPS_AC; + ret = psu_ym2651_info_get(info); + break; + case PSU_TYPE_DC_48V_F2B: + case PSU_TYPE_DC_48V_B2F: + info->caps = ONLP_PSU_CAPS_DC48; + ret = psu_ym2651_info_get(info); + break; + case PSU_TYPE_DC_12V_F2B: + case PSU_TYPE_DC_12V_B2F: + case PSU_TYPE_DC_12V_FANLESS: + ret = psu_dc12v_750_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..6c7f381b --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,221 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +#include /* For O_RDWR && open */ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +#define MUX_START_INDEX 18 +#define NUM_OF_SFP_PORT 32 +static const int sfp_mux_index[NUM_OF_SFP_PORT] = { + 4, 5, 6, 7, 9, 8, 11, 10, + 0, 1, 2, 3, 12, 13, 14, 15, +16, 17, 18, 19, 28, 29, 30, 31, +20, 21, 22, 23, 24, 25, 26, 27 +}; + +#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]+MUX_START_INDEX) + +static int +as7512_32x_sfp_node_read_int(char *node_path, int *value, int data_len) +{ + int ret = 0; + char buf[8]; + *value = 0; + + ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); + + if (ret == 0) { + *value = atoi(buf); + } + + return ret; +} + +static char* +as7512_32x_sfp_get_port_path(int port, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", + FRONT_PORT_TO_MUX_INDEX(port), + node_name); + + return sfp_node_path; +} + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + char* path = as7512_32x_sfp_get_port_path(port, "sfp_is_present"); + + if (as7512_32x_sfp_node_read_int(path, &present, 0) != 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[4]; + char* path; + FILE* fp; + + path = as7512_32x_sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3 + ); + fclose(fp); + if(count != AIM_ARRAYSIZE(bytes)) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom"); + + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + memset(data, 0, 256); + + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..d3a4b629 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,295 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "x86_64_inventec_d7032q28b_int.h" +#include "x86_64_inventec_d7032q28b_log.h" + +#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) +{ + return "x86-64-inventec-d7032q28b-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + 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) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 4 Thermal sensors on the chassis */ + for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 4 Fans on the chassis */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +typedef struct fan_ctrl_policy { + int duty_cycle; + int temp_down_adjust; /* The boundary temperature to down adjust fan speed */ + int temp_up_adjust; /* The boundary temperature to up adjust fan speed */ +} fan_ctrl_policy_t; + +fan_ctrl_policy_t fan_ctrl_policy_f2b[] = { +{32, 0, 174000}, +{38, 170000, 182000}, +{50, 178000, 190000}, +{63, 186000, 0} +}; + +fan_ctrl_policy_t fan_ctrl_policy_b2f[] = { +{32, 0, 140000}, +{38, 135000, 150000}, +{50, 145000, 160000}, +{69, 155000, 0} +}; + +#define FAN_DUTY_CYCLE_MAX 100 +#define FAN_SPEED_CTRL_PATH "/sys/bus/i2c/devices/2-0066/fan_duty_cycle_percentage" + +/* + * For AC power Front to Back : + * * If any fan fail, please fan speed register to 15 + * * The max value of Fan speed register is 9 + * [LM75(48) + LM75(49) + LM75(4A)] > 174 => set Fan speed value from 4 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] > 182 => set Fan speed value from 5 to 7 + * [LM75(48) + LM75(49) + LM75(4A)] > 190 => set Fan speed value from 7 to 9 + * + * [LM75(48) + LM75(49) + LM75(4A)] < 170 => set Fan speed value from 5 to 4 + * [LM75(48) + LM75(49) + LM75(4A)] < 178 => set Fan speed value from 7 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] < 186 => set Fan speed value from 9 to 7 + * + * + * For AC power Back to Front : + * * If any fan fail, please fan speed register to 15 + * * The max value of Fan speed register is 10 + * [LM75(48) + LM75(49) + LM75(4A)] > 140 => set Fan speed value from 4 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] > 150 => set Fan speed value from 5 to 7 + * [LM75(48) + LM75(49) + LM75(4A)] > 160 => set Fan speed value from 7 to 10 + * + * [LM75(48) + LM75(49) + LM75(4A)] < 135 => set Fan speed value from 5 to 4 + * [LM75(48) + LM75(49) + LM75(4A)] < 145 => set Fan speed value from 7 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] < 155 => set Fan speed value from 10 to 7 + */ +int +onlp_sysi_platform_manage_fans(void) +{ + int i = 0, arr_size, temp; + fan_ctrl_policy_t *policy; + int cur_duty_cycle, new_duty_cycle; + onlp_thermal_info_t thermal_1, thermal_2, thermal_3; + + int fd, len; + char buf[10] = {0}; + + /* Get each fan status + */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + /* Decision 1: Set fan as full speed if any fan is failed. + */ + if (fan_info.status & ONLP_FAN_STATUS_FAILED) { + AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i); + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + } + + /* Decision 1.1: Set fan as full speed if any fan is not present. + */ + if (!(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { + AIM_LOG_ERROR("Fan(%d) is not present, set the other fans as full speed\r\n", i); + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + if (fan_info.status & ONLP_FAN_STATUS_F2B) { + policy = fan_ctrl_policy_f2b; + arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_f2b); + } + else { + policy = fan_ctrl_policy_b2f; + arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_b2f); + } + } + } + + /* Get current fan speed + */ + fd = open(FAN_SPEED_CTRL_PATH, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + cur_duty_cycle = atoi(buf); + + + /* Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + */ + for (i = 0; i < arr_size; i++) { + if (policy[i].duty_cycle != cur_duty_cycle) + continue; + + break; + } + + if (i == arr_size) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), policy[0].duty_cycle); + } + + /* Get current temperature + */ + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_1) != ONLP_STATUS_OK || + onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_2) != ONLP_STATUS_OK || + onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(4), &thermal_3) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + temp = thermal_1.mcelsius + thermal_2.mcelsius + thermal_3.mcelsius; + + + /* Decision 3: Decide new fan speed depend on fan direction/current fan speed/temperature + */ + new_duty_cycle = cur_duty_cycle; + + if ((temp >= policy[i].temp_up_adjust) && (i != (arr_size-1))) { + new_duty_cycle = policy[i+1].duty_cycle; + } + else if ((temp <= policy[i].temp_down_adjust) && (i != 0)) { + new_duty_cycle = policy[i-1].duty_cycle; + } + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..94f5353c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + "reserved", + NULL, /* CPU_CORE files */ + "/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/3-004b*temp1_input", + "/sys/bus/i2c/devices/11-005b*psu_temp1_input", + "/sys/bus/i2c/devices/10-0058*psu_temp1_input", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int local_id; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if(local_id == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c new file mode 100644 index 00000000..d75ca1b8 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(_x) +x86_64_inventec_d7032q28b_config_settings_t x86_64_inventec_d7032q28b_config_settings[] = +{ +#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE +#undef __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME + +const char* +x86_64_inventec_d7032q28b_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_inventec_d7032q28b_config_settings[i].name; i++) { + if(strcmp(x86_64_inventec_d7032q28b_config_settings[i].name, setting)) { + return x86_64_inventec_d7032q28b_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_inventec_d7032q28b_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_inventec_d7032q28b_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_inventec_d7032q28b_config_settings[i].name, x86_64_inventec_d7032q28b_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c new file mode 100644 index 00000000..28b49fa2 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h new file mode 100644 index 00000000..f112cb20 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_inventec_d7032q28b Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_INT_H__ +#define __x86_64_inventec_d7032q28b_INT_H__ + +#include + + +#endif /* __x86_64_inventec_d7032q28b_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c new file mode 100644 index 00000000..6ab416f3 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_inventec_d7032q28b_log.h" +/* + * x86_64_inventec_d7032q28b log struct. + */ +AIM_LOG_STRUCT_DEFINE( + x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT, + x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h new file mode 100644 index 00000000..8b66dc39 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_LOG_H__ +#define __x86_64_inventec_d7032q28b_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_inventec_d7032q28b +#include + +#endif /* __x86_64_inventec_d7032q28b_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c new file mode 100644 index 00000000..fe89a47a --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_inventec_d7032q28b_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_inventec_d7032q28b_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_inventec_d7032q28b_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c new file mode 100644 index 00000000..4d15b02c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_inventec_d7032q28b_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d7032q28b) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_inventec_d7032q28b_ucli_module__ = + { + "x86_64_inventec_d7032q28b_ucli", + NULL, + x86_64_inventec_d7032q28b_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_inventec_d7032q28b_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_inventec_d7032q28b_ucli_module__); + n = ucli_node_create("x86_64_inventec_d7032q28b", NULL, &x86_64_inventec_d7032q28b_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d7032q28b")); + return n; +} + +#else +void* +x86_64_inventec_d7032q28b_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml new file mode 100644 index 00000000..ac682e0b --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d7032q28b REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml new file mode 100644 index 00000000..19bcea27 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for d7032q28b +# +###################################################################### + +x86-64-inventec-d7032q28b-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS1,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py new file mode 100644 index 00000000..10c81ea9 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py @@ -0,0 +1,15 @@ +from onl.platform.base import * +from onl.platform.inventec import * + +class OnlPlatform_x86_64_inventec_d7032q28b_r0(OnlPlatformInventec, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-inventec-d7032q28b-r0' + MODEL="X86-D7032Q28B" + SYS_OBJECT_ID=".1.32" + + def baseconfig(self): + os.system("insmod /lib/modules/`uname -r`/onl/inventec/x86-64-inventec-d7032q28b/gpio-ich.ko gpiobase=0") + self.insmod('inv_platform') + self.insmod('inv_psoc') + self.insmod('inv_cpld') + return True From 54197c317c085eb94a3d65e0664263e3b8c94b0f Mon Sep 17 00:00:00 2001 From: Joe Chan Date: Tue, 10 Oct 2017 15:21:47 -0700 Subject: [PATCH 055/244] Update Inventec d7032q28b. --- .../configs/x86_64-all/x86_64-all.config | 2 +- .../modules/builds/gpio-ich.c | 548 ------------------ .../module/auto/x86_64_inventec_d7032q28b.yml | 22 +- .../onlp/builds/src/module/src/debug.c | 45 -- .../onlp/builds/src/module/src/fani.c | 319 ++++------ .../onlp/builds/src/module/src/ledi.c | 14 +- .../onlp/builds/src/module/src/platform_lib.c | 66 ++- .../onlp/builds/src/module/src/platform_lib.h | 12 +- .../onlp/builds/src/module/src/psui.c | 4 +- .../onlp/builds/src/module/src/sfpi.c | 16 +- .../x86_64_inventec_d7032q28b_r0/__init__.py | 2 +- 11 files changed, 213 insertions(+), 837 deletions(-) delete mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c delete mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c diff --git a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config index a7f0259f..109a7ccd 100644 --- a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config @@ -2004,7 +2004,7 @@ CONFIG_GPIO_GENERIC_PLATFORM=y # CONFIG_GPIO_F7188X is not set # CONFIG_GPIO_SCH311X is not set CONFIG_GPIO_SCH=y -# CONFIG_GPIO_ICH is not set +CONFIG_GPIO_ICH=m # CONFIG_GPIO_VX855 is not set # CONFIG_GPIO_LYNXPOINT is not set diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c deleted file mode 100644 index 70304220..00000000 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/gpio-ich.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Intel ICH6-10, Series 5 and 6, Atom C2000 (Avoton/Rangeley) GPIO driver - * - * Copyright (C) 2010 Extreme Engineering Solutions. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include - -#define DRV_NAME "gpio_ich" - -/* - * GPIO register offsets in GPIO I/O space. - * Each chunk of 32 GPIOs is manipulated via its own USE_SELx, IO_SELx, and - * LVLx registers. Logic in the read/write functions takes a register and - * an absolute bit number and determines the proper register offset and bit - * number in that register. For example, to read the value of GPIO bit 50 - * the code would access offset ichx_regs[2(=GPIO_LVL)][1(=50/32)], - * bit 18 (50%32). - */ -enum GPIO_REG { - GPIO_USE_SEL = 0, - GPIO_IO_SEL, - GPIO_LVL, - GPO_BLINK -}; - -static const u8 ichx_regs[4][3] = { - {0x00, 0x30, 0x40}, /* USE_SEL[1-3] offsets */ - {0x04, 0x34, 0x44}, /* IO_SEL[1-3] offsets */ - {0x0c, 0x38, 0x48}, /* LVL[1-3] offsets */ - {0x18, 0x18, 0x18}, /* BLINK offset */ -}; - -static const u8 ichx_reglen[3] = { - 0x30, 0x10, 0x10, -}; - -static const u8 avoton_regs[4][3] = { - {0x00, 0x80, 0x00}, - {0x04, 0x84, 0x00}, - {0x08, 0x88, 0x00}, -}; - -static const u8 avoton_reglen[3] = { - 0x10, 0x10, 0x00, -}; - -#define ICHX_WRITE(val, reg, base_res) outl(val, (reg) + (base_res)->start) -#define ICHX_READ(reg, base_res) inl((reg) + (base_res)->start) - -struct ichx_desc { - /* Max GPIO pins the chipset can have */ - uint ngpio; - - /* chipset registers */ - const u8 (*regs)[3]; - const u8 *reglen; - - /* GPO_BLINK is available on this chipset */ - bool have_blink; - - /* Whether the chipset has GPIO in GPE0_STS in the PM IO region */ - bool uses_gpe0; - - /* USE_SEL is bogus on some chipsets, eg 3100 */ - u32 use_sel_ignore[3]; - - /* Some chipsets have quirks, let these use their own request/get */ - int (*request)(struct gpio_chip *chip, unsigned offset); - int (*get)(struct gpio_chip *chip, unsigned offset); - - /* - * Some chipsets don't let reading output values on GPIO_LVL register - * this option allows driver caching written output values - */ - bool use_outlvl_cache; -}; - -static struct { - spinlock_t lock; - struct platform_device *dev; - struct gpio_chip chip; - struct resource *gpio_base; /* GPIO IO base */ - struct resource *pm_base; /* Power Mangagment IO base */ - struct ichx_desc *desc; /* Pointer to chipset-specific description */ - u32 orig_gpio_ctrl; /* Orig CTRL value, used to restore on exit */ - u8 use_gpio; /* Which GPIO groups are usable */ - int outlvl_cache[3]; /* cached output values */ -} ichx_priv; - -static int modparam_gpiobase = -1; /* dynamic */ -module_param_named(gpiobase, modparam_gpiobase, int, 0444); -MODULE_PARM_DESC(gpiobase, "The GPIO number base. -1 means dynamic, " - "which is the default."); - -static int ichx_write_bit(int reg, unsigned nr, int val, int verify) -{ - unsigned long flags; - u32 data, tmp; - int reg_nr = nr / 32; - int bit = nr & 0x1f; - int ret = 0; - - spin_lock_irqsave(&ichx_priv.lock, flags); - - if (reg == GPIO_LVL && ichx_priv.desc->use_outlvl_cache) - data = ichx_priv.outlvl_cache[reg_nr]; - else - data = ICHX_READ(ichx_priv.desc->regs[reg][reg_nr], - ichx_priv.gpio_base); - - if (val) - data |= 1 << bit; - else - data &= ~(1 << bit); - ICHX_WRITE(data, ichx_priv.desc->regs[reg][reg_nr], - ichx_priv.gpio_base); - if (reg == GPIO_LVL && ichx_priv.desc->use_outlvl_cache) - ichx_priv.outlvl_cache[reg_nr] = data; - - tmp = ICHX_READ(ichx_priv.desc->regs[reg][reg_nr], - ichx_priv.gpio_base); - if (verify && data != tmp) - ret = -EPERM; - - spin_unlock_irqrestore(&ichx_priv.lock, flags); - - return ret; -} - -static int ichx_read_bit(int reg, unsigned nr) -{ - unsigned long flags; - u32 data; - int reg_nr = nr / 32; - int bit = nr & 0x1f; - - spin_lock_irqsave(&ichx_priv.lock, flags); - - data = ICHX_READ(ichx_priv.desc->regs[reg][reg_nr], - ichx_priv.gpio_base); - - if (reg == GPIO_LVL && ichx_priv.desc->use_outlvl_cache) - data = ichx_priv.outlvl_cache[reg_nr] | data; - - spin_unlock_irqrestore(&ichx_priv.lock, flags); - - return data & (1 << bit) ? 1 : 0; -} - -static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr) -{ - return !!(ichx_priv.use_gpio & (1 << (nr / 32))); -} - -static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) -{ - /* - * Try setting pin as an input and verify it worked since many pins - * are output-only. - */ - if (ichx_write_bit(GPIO_IO_SEL, nr, 1, 1)) - return -EINVAL; - - return 0; -} - -static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, - int val) -{ - /* Disable blink hardware which is available for GPIOs from 0 to 31. */ - if (nr < 32 && ichx_priv.desc->have_blink) - ichx_write_bit(GPO_BLINK, nr, 0, 0); - - /* Set GPIO output value. */ - ichx_write_bit(GPIO_LVL, nr, val, 0); - - /* - * Try setting pin as an output and verify it worked since many pins - * are input-only. - */ - if (ichx_write_bit(GPIO_IO_SEL, nr, 0, 1)) - return -EINVAL; - - return 0; -} - -static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr) -{ - return ichx_read_bit(GPIO_LVL, nr); -} - -static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr) -{ - unsigned long flags; - u32 data; - - /* - * GPI 0 - 15 need to be read from the power management registers on - * a ICH6/3100 bridge. - */ - if (nr < 16) { - if (!ichx_priv.pm_base) - return -ENXIO; - - spin_lock_irqsave(&ichx_priv.lock, flags); - - /* GPI 0 - 15 are latched, write 1 to clear*/ - ICHX_WRITE(1 << (16 + nr), 0, ichx_priv.pm_base); - data = ICHX_READ(0, ichx_priv.pm_base); - - spin_unlock_irqrestore(&ichx_priv.lock, flags); - - return (data >> 16) & (1 << nr) ? 1 : 0; - } else { - return ichx_gpio_get(chip, nr); - } -} - -static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr) -{ - if (!ichx_gpio_check_available(chip, nr)) - return -ENXIO; - - /* - * Note we assume the BIOS properly set a bridge's USE value. Some - * chips (eg Intel 3100) have bogus USE values though, so first see if - * the chipset's USE value can be trusted for this specific bit. - * If it can't be trusted, assume that the pin can be used as a GPIO. - */ - if (ichx_priv.desc->use_sel_ignore[nr / 32] & (1 << (nr & 0x1f))) - return 0; - - return ichx_read_bit(GPIO_USE_SEL, nr) ? 0 : -ENODEV; -} - -static int ich6_gpio_request(struct gpio_chip *chip, unsigned nr) -{ - /* - * Fixups for bits 16 and 17 are necessary on the Intel ICH6/3100 - * bridge as they are controlled by USE register bits 0 and 1. See - * "Table 704 GPIO_USE_SEL1 register" in the i3100 datasheet for - * additional info. - */ - if (nr == 16 || nr == 17) - nr -= 16; - - return ichx_gpio_request(chip, nr); -} - -static void ichx_gpio_set(struct gpio_chip *chip, unsigned nr, int val) -{ - ichx_write_bit(GPIO_LVL, nr, val, 0); -} - -static void ichx_gpiolib_setup(struct gpio_chip *chip) -{ - chip->owner = THIS_MODULE; - chip->label = DRV_NAME; - chip->dev = &ichx_priv.dev->dev; - - /* Allow chip-specific overrides of request()/get() */ - chip->request = ichx_priv.desc->request ? - ichx_priv.desc->request : ichx_gpio_request; - chip->get = ichx_priv.desc->get ? - ichx_priv.desc->get : ichx_gpio_get; - - chip->set = ichx_gpio_set; - chip->direction_input = ichx_gpio_direction_input; - chip->direction_output = ichx_gpio_direction_output; - chip->base = modparam_gpiobase; - chip->ngpio = ichx_priv.desc->ngpio; - chip->can_sleep = false; - chip->dbg_show = NULL; -} - -/* ICH6-based, 631xesb-based */ -static struct ichx_desc ich6_desc = { - /* Bridges using the ICH6 controller need fixups for GPIO 0 - 17 */ - .request = ich6_gpio_request, - .get = ich6_gpio_get, - - /* GPIO 0-15 are read in the GPE0_STS PM register */ - .uses_gpe0 = true, - - .ngpio = 50, - .have_blink = true, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; - -/* Intel 3100 */ -static struct ichx_desc i3100_desc = { - /* - * Bits 16,17, 20 of USE_SEL and bit 16 of USE_SEL2 always read 0 on - * the Intel 3100. See "Table 712. GPIO Summary Table" of 3100 - * Datasheet for more info. - */ - .use_sel_ignore = {0x00130000, 0x00010000, 0x0}, - - /* The 3100 needs fixups for GPIO 0 - 17 */ - .request = ich6_gpio_request, - .get = ich6_gpio_get, - - /* GPIO 0-15 are read in the GPE0_STS PM register */ - .uses_gpe0 = true, - - .ngpio = 50, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; - -/* ICH7 and ICH8-based */ -static struct ichx_desc ich7_desc = { - .ngpio = 50, - .have_blink = true, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; - -/* ICH9-based */ -static struct ichx_desc ich9_desc = { - .ngpio = 61, - .have_blink = true, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; - -/* ICH10-based - Consumer/corporate versions have different amount of GPIO */ -static struct ichx_desc ich10_cons_desc = { - .ngpio = 61, - .have_blink = true, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; -static struct ichx_desc ich10_corp_desc = { - .ngpio = 72, - .have_blink = true, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; - -/* Intel 5 series, 6 series, 3400 series, and C200 series */ -static struct ichx_desc intel5_desc = { - .ngpio = 76, - .regs = ichx_regs, - .reglen = ichx_reglen, -}; - -/* Avoton */ -static struct ichx_desc avoton_desc = { - /* Avoton has only 59 GPIOs, but we assume the first set of register - * (Core) has 32 instead of 31 to keep gpio-ich compliance - */ - .ngpio = 60, - .regs = avoton_regs, - .reglen = avoton_reglen, - .use_outlvl_cache = true, -}; - -static int ichx_gpio_request_regions(struct resource *res_base, - const char *name, u8 use_gpio) -{ - int i; - - if (!res_base || !res_base->start || !res_base->end) - return -ENODEV; - - for (i = 0; i < ARRAY_SIZE(ichx_priv.desc->regs[0]); i++) { - if (!(use_gpio & (1 << i))) - continue; - if (!request_region( - res_base->start + ichx_priv.desc->regs[0][i], - ichx_priv.desc->reglen[i], name)) - goto request_err; - } - return 0; - -request_err: - /* Clean up: release already requested regions, if any */ - for (i--; i >= 0; i--) { - if (!(use_gpio & (1 << i))) - continue; - release_region(res_base->start + ichx_priv.desc->regs[0][i], - ichx_priv.desc->reglen[i]); - } - return -EBUSY; -} - -static void ichx_gpio_release_regions(struct resource *res_base, u8 use_gpio) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ichx_priv.desc->regs[0]); i++) { - if (!(use_gpio & (1 << i))) - continue; - release_region(res_base->start + ichx_priv.desc->regs[0][i], - ichx_priv.desc->reglen[i]); - } -} - -static int ichx_gpio_probe(struct platform_device *pdev) -{ - struct resource *res_base, *res_pm; - int err; - struct lpc_ich_info *ich_info = dev_get_platdata(&pdev->dev); - - if (!ich_info) - return -ENODEV; - - ichx_priv.dev = pdev; - - switch (ich_info->gpio_version) { - case ICH_I3100_GPIO: - ichx_priv.desc = &i3100_desc; - break; - case ICH_V5_GPIO: - ichx_priv.desc = &intel5_desc; - break; - case ICH_V6_GPIO: - ichx_priv.desc = &ich6_desc; - break; - case ICH_V7_GPIO: - ichx_priv.desc = &ich7_desc; - break; - case ICH_V9_GPIO: - ichx_priv.desc = &ich9_desc; - break; - case ICH_V10CORP_GPIO: - ichx_priv.desc = &ich10_corp_desc; - break; - case ICH_V10CONS_GPIO: - ichx_priv.desc = &ich10_cons_desc; - break; - case AVOTON_GPIO: - ichx_priv.desc = &avoton_desc; - break; - default: - return -ENODEV; - } - - spin_lock_init(&ichx_priv.lock); - res_base = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPIO); - ichx_priv.use_gpio = ich_info->use_gpio; - err = ichx_gpio_request_regions(res_base, pdev->name, - ichx_priv.use_gpio); - if (err) - return err; - - ichx_priv.gpio_base = res_base; - - /* - * If necessary, determine the I/O address of ACPI/power management - * registers which are needed to read the the GPE0 register for GPI pins - * 0 - 15 on some chipsets. - */ - if (!ichx_priv.desc->uses_gpe0) - goto init; - - res_pm = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPE0); - if (!res_pm) { - pr_warn("ACPI BAR is unavailable, GPI 0 - 15 unavailable\n"); - goto init; - } - - if (!request_region(res_pm->start, resource_size(res_pm), - pdev->name)) { - pr_warn("ACPI BAR is busy, GPI 0 - 15 unavailable\n"); - goto init; - } - - ichx_priv.pm_base = res_pm; - -init: - ichx_gpiolib_setup(&ichx_priv.chip); - err = gpiochip_add(&ichx_priv.chip); - if (err) { - pr_err("Failed to register GPIOs\n"); - goto add_err; - } - - pr_info("GPIO from %d to %d on %s\n", ichx_priv.chip.base, - ichx_priv.chip.base + ichx_priv.chip.ngpio - 1, DRV_NAME); - - return 0; - -add_err: - ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio); - if (ichx_priv.pm_base) - release_region(ichx_priv.pm_base->start, - resource_size(ichx_priv.pm_base)); - return err; -} - -static int ichx_gpio_remove(struct platform_device *pdev) -{ - int err; - - err = gpiochip_remove(&ichx_priv.chip); - if (err) { - dev_err(&pdev->dev, "%s failed, %d\n", - "gpiochip_remove()", err); - return err; - } - - ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio); - if (ichx_priv.pm_base) - release_region(ichx_priv.pm_base->start, - resource_size(ichx_priv.pm_base)); - - return 0; -} - -static struct platform_driver ichx_gpio_driver = { - .driver = { - .owner = THIS_MODULE, - .name = DRV_NAME, - }, - .probe = ichx_gpio_probe, - .remove = ichx_gpio_remove, -}; - -module_platform_driver(ichx_gpio_driver); - -MODULE_AUTHOR("Peter Tyser "); -MODULE_DESCRIPTION("GPIO interface for Intel ICH series"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:"DRV_NAME); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml index cd4ae278..b624ecde 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml @@ -5,40 +5,40 @@ ############################################################################### cdefs: &cdefs -- x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING: +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT: +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB: +- X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." - default: x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB -- x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI: + default: X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 definitions: cdefs: - x86_64_inventec_d7032q28b_CONFIG_HEADER: + X86_64_INVENTEC_D7032Q28B_CONFIG_HEADER: defs: *cdefs basename: x86_64_inventec_d7032q28b_config portingmacro: - x86_64_inventec_d7032q28b: + X86_64_INVENTEC_D7032Q28B: macros: - malloc - free diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c deleted file mode 100644 index 7831ccc8..00000000 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d7032q28b_int.h" - -#if x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d7032q28b_debug_main(int argc, char* argv[]) -{ - int c = 0; - int help = 0; - int rv = 0; - - while( (c = getopt(argc, argv, "ch")) != -1) { - switch(c) - { - case 'c': c = 1; break; - case 'h': help = 1; rv = 0; break; - default: help = 1; rv = 1; break; - } - - } - - if(help || argc == 1) { - printf("%s", help__); - return rv; - } - - if(c) { - printf("Not implemented.\n"); - } - - - return 0; -} - -#endif - - diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c index 5fd76b00..e81967d3 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c @@ -23,6 +23,7 @@ * Fan Platform Implementation Defaults. * ***********************************************************/ +#include #include #include #include @@ -47,15 +48,15 @@ #define FAN_1_ON_PSU1 7 #define FAN_1_ON_PSU2 8 -typedef struct fan_path_S -{ - char present[LEN_FILE_NAME]; - char status[LEN_FILE_NAME]; - char speed[LEN_FILE_NAME]; - char direction[LEN_FILE_NAME]; - char ctrl_speed[LEN_FILE_NAME]; - char r_speed[LEN_FILE_NAME]; -}fan_path_T; +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; #define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ { #prj"fan"#id"_present", #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \ @@ -67,19 +68,6 @@ typedef struct fan_path_S {"", #folder"/psu_fan1_fault", #folder"/psu_fan1_speed_rpm", \ "", #folder"/psu_fan1_duty_cycle_percentage", "" } -static fan_path_T fan_path[] = /* must map with onlp_fan_id */ -{ - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_5_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_6_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_PSU(11-005b), - MAKE_FAN_PATH_ON_PSU(10-0058) -}; - #define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ { \ { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ @@ -120,19 +108,83 @@ onlp_fan_info_t linfo[] = { } \ } 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 + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value, ret; + + /* get fan present status + */ + ret = onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_B2F : ONLP_FAN_STATUS_F2B; + + + /* get front fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + ret = onlp_file_read_int(&value, "%s""fan_max_speed_rpm", FAN_BOARD_PATH); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->percentage = (info->rpm * 100)/value; + + return ONLP_STATUS_OK; +} + static uint32_t -_onlp_fani_info_get_psu_fan_direction(void) +_onlp_get_fan_direction_on_psu(void) { /* Try to read direction from PSU1. * If PSU1 is not valid, read from PSU2 @@ -147,106 +199,46 @@ _onlp_fani_info_get_psu_fan_direction(void) continue; } - switch (psu_type) { - case PSU_TYPE_AC_F2B: - case PSU_TYPE_DC_48V_F2B: - case PSU_TYPE_DC_12V_F2B: - return ONLP_FAN_STATUS_F2B; - case PSU_TYPE_AC_B2F: - case PSU_TYPE_DC_48V_B2F: - case PSU_TYPE_DC_12V_B2F: - return ONLP_FAN_STATUS_B2F; - default: - return 0; - }; + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } } return 0; } -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) -{ - int fd, len, nbytes = 10; - char r_data[10] = {0}; - char fullpath[65] = {0}; - - /* check if fan is present - */ - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].present); - OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); - if (atoi(r_data) == 0) { - return ONLP_STATUS_OK; - } - info->status |= ONLP_FAN_STATUS_PRESENT; - - /* get fan fault status (turn on when any one fails) - */ - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status); - 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/fanr direction (both : the same) - */ - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].direction); - OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); - - if (atoi(r_data) == 0) /*B2F*/ - info->status |= ONLP_FAN_STATUS_B2F; - else - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan speed (take the min from two speeds) - */ - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed); - OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); - info->rpm = atoi(r_data); - - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed); - OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); - if (info->rpm > atoi(r_data)) { - info->rpm = atoi(r_data); - } - - /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; - - return ONLP_STATUS_OK; -} static int -_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) { - int fd, len, nbytes = 10; - char r_data[10] = {0}; - char fullpath[80] = {0}; + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; /* get fan direction */ - info->status |= _onlp_fani_info_get_psu_fan_direction(); + info->status |= _onlp_get_fan_direction_on_psu(); /* get fan fault status */ - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status); - OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); - info->status |= (atoi(r_data) > 0) ? ONLP_FAN_STATUS_FAILED : 0; + if (psu_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } /* get fan speed */ - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed); - OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len); - info->rpm = atoi(r_data); - - /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= ONLP_FAN_STATUS_PRESENT; + if (psu_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } return ONLP_STATUS_OK; } + /* * This function will be called prior to all of onlp_fani_* functions. */ @@ -288,20 +280,6 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) return rc; } -/* - * This function sets the speed of the given fan in RPM. - * - * This function will only be called if the fan supprots the RPM_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - /* * This function sets the fan speed of the given OID as a percentage. * @@ -313,90 +291,39 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) int onlp_fani_percentage_set(onlp_oid_t id, int p) { - int fd, len, nbytes=10, local_id; - char data[10] = {0}; - char fullpath[70] = {0}; + int fid; + char *path = NULL; VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); + fid = ONLP_OID_ID_GET(id); /* reject p=0 (p=0, stop fan) */ if (p == 0){ return ONLP_STATUS_E_INVALID; } - /* get fullpath */ - switch (local_id) - { - case FAN_1_ON_PSU1: - case FAN_1_ON_PSU2: - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed); - break; - case FAN_1_ON_MAIN_BOARD: - case FAN_2_ON_MAIN_BOARD: - case FAN_3_ON_MAIN_BOARD: - case FAN_4_ON_MAIN_BOARD: - case FAN_5_ON_MAIN_BOARD: - case FAN_6_ON_MAIN_BOARD: - sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].ctrl_speed); - break; + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_pmbus_info_set(PSU1_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_pmbus_info_set(PSU2_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; default: return ONLP_STATUS_E_INVALID; } - sprintf(data, "%d", p); - DEBUG_PRINT("[Debug][%s][%d][openfile: %s][data=%s]\n", __FUNCTION__, __LINE__, fullpath, data); - /* Create output file descriptor */ - fd = open(fullpath, O_WRONLY, 0644); - if (fd == -1){ + if (onlp_file_write_integer(path, p) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); return ONLP_STATUS_E_INTERNAL; } - len = write (fd, data, (ssize_t) nbytes); - if (len != nbytes) { - close(fd); - return ONLP_STATUS_E_INTERNAL; - } - - close(fd); - return ONLP_STATUS_OK; + return ONLP_STATUS_OK; } - - -/* - * This function sets the fan speed of the given OID as per - * the predefined ONLP fan speed modes: off, slow, normal, fast, max. - * - * Interpretation of these modes is up to the platform. - * - */ -int -onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan direction of the given OID. - * - * This function is only relevant if the fan OID supports both direction - * capabilities. - * - * This function is optional unless the functionality is available. - */ -int -onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c index 3c86a173..72a0a5b7 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c @@ -191,7 +191,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) *info = linfo[ONLP_OID_ID_GET(id)]; /* Set LED mode */ - if (deviceNodeReadString(fullpath, data, sizeof(data), 0) != 0) { + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); return ONLP_STATUS_E_INTERNAL; } @@ -244,20 +244,10 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) local_id = ONLP_OID_ID_GET(id); sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); - if (deviceNodeWriteInt(fullpath, onlp_to_driver_led_mode(local_id, mode), 0) != 0) + if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) { return ONLP_STATUS_E_INTERNAL; } return ONLP_STATUS_OK; } - -/* - * Generic LED ioctl interface. - */ -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c index b4ef2d04..1f3e791b 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c @@ -30,9 +30,13 @@ #include #include #include +#include +#include #include "platform_lib.h" -int deviceNodeWrite(char *filename, char *buffer, int buf_size, int data_len) +#define PSU_NODE_MAX_PATH_LEN 64 + +int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) { int fd; int len; @@ -61,15 +65,15 @@ int deviceNodeWrite(char *filename, char *buffer, int buf_size, int data_len) return 0; } -int deviceNodeWriteInt(char *filename, int value, int data_len) +int onlp_file_write_integer(char *filename, int value) { char buf[8] = {0}; sprintf(buf, "%d", value); - return deviceNodeWrite(filename, buf, (int)strlen(buf), data_len); + return _onlp_file_write(filename, buf, (int)strlen(buf), 0); } -int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len) +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) { int fd; int len; @@ -98,7 +102,7 @@ int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_le return 0; } -int deviceNodeReadString(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) { int ret; @@ -106,7 +110,7 @@ int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_le return -1; } - ret = deviceNodeReadBinary(filename, buffer, buf_size-1, data_len); + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); if (ret == 0) { buffer[buf_size-1] = '\0'; @@ -127,7 +131,7 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) /* Check AC model name */ node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name); - if (deviceNodeReadString(node, model_name, sizeof(model_name), 0) != 0) { + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { return PSU_TYPE_UNKNOWN; } @@ -141,7 +145,7 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) } node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); - if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) { + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { return PSU_TYPE_UNKNOWN; } @@ -160,7 +164,7 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) } node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); - if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) { + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { return PSU_TYPE_UNKNOWN; } @@ -179,7 +183,7 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) } node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_fan_dir) : PSU2_AC_HWMON_NODE(psu_fan_dir); - if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) { + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { return PSU_TYPE_UNKNOWN; } @@ -198,3 +202,45 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) return PSU_TYPE_UNKNOWN; } + +int psu_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + *value = 0; + + if (PSU1_ID == id) { + ret = onlp_file_read_int(value, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + ret = onlp_file_read_int(value, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_integer(path, value) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h index 0ae3c77f..a63aecd4 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h @@ -46,11 +46,17 @@ #define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node #define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node +#define FAN_BOARD_PATH "/sys/devices/platform/fan/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + #define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom" -int deviceNodeWriteInt(char *filename, int value, int data_len); -int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len); -int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_len); +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); + +int psu_pmbus_info_get(int id, char *node, int *value); +int psu_pmbus_info_set(int id, char *node, int value); typedef enum psu_type { PSU_TYPE_UNKNOWN, diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c index 88c02f03..97cf78ef 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c @@ -58,7 +58,7 @@ psu_status_info_get(int id, char *node, int *value) sprintf(node_path, "%s%s", PSU2_AC_HWMON_PREFIX, node); } - ret = deviceNodeReadString(node_path, buf, sizeof(buf), 0); + ret = onlp_file_read_string(node_path, buf, sizeof(buf), 0); if (ret == 0) { *value = atoi(buf); @@ -83,7 +83,7 @@ psu_ym2651_pmbus_info_get(int id, char *node, int *value) sprintf(node_path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); } - ret = deviceNodeReadString(node_path, buf, sizeof(buf), 0); + ret = onlp_file_read_string(node_path, buf, sizeof(buf), 0); if (ret == 0) { *value = atoi(buf); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c index 6c7f381b..e211d417 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c @@ -48,13 +48,13 @@ static const int sfp_mux_index[NUM_OF_SFP_PORT] = { #define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]+MUX_START_INDEX) static int -as7512_32x_sfp_node_read_int(char *node_path, int *value, int data_len) +sfp_node_read_int(char *node_path, int *value, int data_len) { int ret = 0; char buf[8]; *value = 0; - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); + ret = onlp_file_read_string(node_path, buf, sizeof(buf), data_len); if (ret == 0) { *value = atoi(buf); @@ -64,7 +64,7 @@ as7512_32x_sfp_node_read_int(char *node_path, int *value, int data_len) } static char* -as7512_32x_sfp_get_port_path(int port, char *node_name) +sfp_get_port_path(int port, char *node_name) { sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", FRONT_PORT_TO_MUX_INDEX(port), @@ -110,9 +110,9 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as7512_32x_sfp_get_port_path(port, "sfp_is_present"); + char* path = sfp_get_port_path(port, "sfp_is_present"); - if (as7512_32x_sfp_node_read_int(path, &present, 0) != 0) { + if (sfp_node_read_int(path, &present, 0) != 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -127,7 +127,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) char* path; FILE* fp; - path = as7512_32x_sfp_get_port_path(0, "sfp_is_present_all"); + path = sfp_get_port_path(0, "sfp_is_present_all"); fp = fopen(path, "r"); if(fp == NULL) { @@ -167,7 +167,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom"); + char* path = sfp_get_port_path(port, "sfp_eeprom"); /* * Read the SFP eeprom into data[] @@ -177,7 +177,7 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) */ memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py index 10c81ea9..181b07cc 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py @@ -8,7 +8,7 @@ class OnlPlatform_x86_64_inventec_d7032q28b_r0(OnlPlatformInventec, SYS_OBJECT_ID=".1.32" def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/onl/inventec/x86-64-inventec-d7032q28b/gpio-ich.ko gpiobase=0") + os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") self.insmod('inv_platform') self.insmod('inv_psoc') self.insmod('inv_cpld') From acae0738913e7f2ba5db78e0515e2689c3837457 Mon Sep 17 00:00:00 2001 From: Joe Chan Date: Thu, 26 Oct 2017 02:55:10 -0700 Subject: [PATCH 056/244] Inventec d7032q28b onlp update. --- .../onlp/builds/src/module/src/fani.c | 2 +- .../onlp/builds/src/module/src/ledi.c | 4 +- .../onlp/builds/src/module/src/platform_lib.c | 61 +------------------ .../onlp/builds/src/module/src/platform_lib.h | 1 - .../onlp/builds/src/module/src/psui.c | 17 +++--- .../onlp/builds/src/module/src/sfpi.c | 12 ++-- 6 files changed, 21 insertions(+), 76 deletions(-) diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c index e81967d3..25addc7f 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c @@ -320,7 +320,7 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) return ONLP_STATUS_E_INVALID; } - if (onlp_file_write_integer(path, p) < 0) { + if (onlp_file_write_int(p, path, NULL) != 0) { AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c index 72a0a5b7..9cfd216b 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c @@ -29,7 +29,7 @@ #include #include #include - +#include #include "platform_lib.h" #define prefix_path "/sys/class/leds/inventec_d7032q28b_led::" @@ -244,7 +244,7 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) local_id = ONLP_OID_ID_GET(id); sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); - if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) + if (onlp_file_write_int(onlp_to_driver_led_mode(local_id, mode), fullpath, NULL) != 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c index 1f3e791b..9e4c5e06 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c @@ -36,70 +36,13 @@ #define PSU_NODE_MAX_PATH_LEN 64 -int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) -{ - int fd; - int len; - - if ((buffer == NULL) || (buf_size < 0)) { - return -1; - } - - if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { - return -1; - } - - if ((len = write(fd, buffer, buf_size)) < 0) { - close(fd); - return -1; - } - - if ((close(fd) == -1)) { - return -1; - } - - if ((len > buf_size) || (data_len != 0 && len != data_len)) { - return -1; - } - - return 0; -} - -int onlp_file_write_integer(char *filename, int value) -{ - char buf[8] = {0}; - sprintf(buf, "%d", value); - - return _onlp_file_write(filename, buf, (int)strlen(buf), 0); -} - int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) { - int fd; - int len; - if ((buffer == NULL) || (buf_size < 0)) { return -1; } - if ((fd = open(filename, O_RDONLY)) == -1) { - return -1; - } - - if ((len = read(fd, buffer, buf_size)) < 0) { - close(fd); - return -1; - } - - if ((close(fd) == -1)) { - return -1; - } - - if ((len > buf_size) || (data_len != 0 && len != data_len)) { - return -1; - } - - return 0; + return onlp_file_read((uint8_t*)buffer, buf_size, &data_len, "%s", filename); } int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) @@ -237,7 +180,7 @@ int psu_pmbus_info_set(int id, char *node, int value) return ONLP_STATUS_E_UNSUPPORTED; }; - if (onlp_file_write_integer(path, value) < 0) { + if (onlp_file_write_int(value, path, NULL) != 0) { AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h index a63aecd4..2a50bf9e 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h @@ -51,7 +51,6 @@ #define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom" -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); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c index 97cf78ef..8d12741e 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c @@ -25,6 +25,7 @@ ***********************************************************/ #include #include +#include #include #include #include "platform_lib.h" @@ -46,7 +47,6 @@ static int psu_status_info_get(int id, char *node, int *value) { int ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; @@ -58,10 +58,11 @@ psu_status_info_get(int id, char *node, int *value) sprintf(node_path, "%s%s", PSU2_AC_HWMON_PREFIX, node); } - ret = onlp_file_read_string(node_path, buf, sizeof(buf), 0); + ret = onlp_file_read_int(value, node_path); - if (ret == 0) { - *value = atoi(buf); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; } return ret; @@ -71,7 +72,6 @@ static int psu_ym2651_pmbus_info_get(int id, char *node, int *value) { int ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; @@ -83,10 +83,11 @@ psu_ym2651_pmbus_info_get(int id, char *node, int *value) sprintf(node_path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); } - ret = onlp_file_read_string(node_path, buf, sizeof(buf), 0); + ret = onlp_file_read_int(value, node_path); - if (ret == 0) { - *value = atoi(buf); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; } return ret; diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c index e211d417..0b568114 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "platform_lib.h" #define MAX_SFP_PATH 64 @@ -51,13 +52,13 @@ static int sfp_node_read_int(char *node_path, int *value, int data_len) { int ret = 0; - char buf[8]; *value = 0; - ret = onlp_file_read_string(node_path, buf, sizeof(buf), data_len); + ret = onlp_file_read_int(value, node_path); - if (ret == 0) { - *value = atoi(buf); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; } return ret; @@ -168,6 +169,7 @@ int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { char* path = sfp_get_port_path(port, "sfp_eeprom"); + int len = 0; /* * Read the SFP eeprom into data[] @@ -177,7 +179,7 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) */ memset(data, 0, 256); - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { + if (onlp_file_read((uint8_t*)data, 256, &len, path) < 0) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } From 6db19bd5a55fb347e51b50061560307b967c68d8 Mon Sep 17 00:00:00 2001 From: hans Date: Wed, 1 Nov 2017 17:14:55 +0800 Subject: [PATCH 057/244] fix bug: 1. Fixed bug: 1.1 shows the correct percentage speed display on fan 2. modify the corresponding LED capability Signed-off-by: hans --- .../x86-64/x86-64-delta-ag5648/.gitignore | 3 +- .../delta/x86-64/x86-64-delta-ag5648/Makefile | 3 +- .../modules/builds/dni_ag5648_psu.c | 10 +- .../modules/builds/dni_ag5648_sfp.c | 2 +- .../modules/builds/dni_emc2305.c | 44 +- .../onlp/builds/src/module/src/fani.c | 36 +- .../onlp/builds/src/module/src/ledi.c | 414 +++++++++--------- .../onlp/builds/src/module/src/platform_lib.c | 43 +- .../onlp/builds/src/module/src/platform_lib.h | 5 +- .../onlp/builds/src/module/src/sysi.c | 165 ++++--- .../onlp/builds/src/module/src/thermali.c | 27 +- .../python/x86_64_delta_ag5648_r0/__init__.py | 1 - 12 files changed, 426 insertions(+), 327 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore index 269535f7..76483140 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore @@ -1,2 +1,3 @@ -*x86*64*delta*ag5648*.mk +*x86*64*delta_agc7648a*.mk onlpdump.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile index 003238cf..26aa37e6 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile @@ -1 +1,2 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file +include $(ONL)/make/pkg.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c index eae7970e..a6bc521e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c @@ -176,8 +176,8 @@ static ssize_t for_linear_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(value >> 11, 5, 0x1f); mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - return (exponent >= 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ + return (exponent >= 0) ? \ + sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) : \ sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); } @@ -201,9 +201,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - return (exponent > 0) ? sprintf(buf, "%d\n", \ - mantissa * (1 << exponent)) : \ - sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier); + return (exponent > 0) ? \ + sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent)); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c index a0459f37..198084f1 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c @@ -199,7 +199,7 @@ static ssize_t for_r_port_data(struct device *dev, struct device_attribute *dev_ } } - return sprintf(buf, "%d\n", sfp_port_data); + return sprintf(buf, "%d\n", (int)sfp_port_data); } static ssize_t set_w_lp_mode_data(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c index 00ed5ebe..ba63bdc8 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c @@ -32,6 +32,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf); static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf); +static ssize_t show_percentage(struct device *dev, struct device_attribute *devattr, + char *buf); static ssize_t set_fan(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count); static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *devattr, @@ -57,6 +59,7 @@ static const unsigned short normal_i2c[] = { 0x2C, 0x2D, 0x2E, 0x2F, 0x4C, #define EMC2305_DEVICE 0x34 #define EMC2305_VENDOR 0x5D +#define MAX_FAN_SPEED 23000 struct emc2305_data { @@ -95,17 +98,17 @@ static SENSOR_DEVICE_ATTR(fan1_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 0); static SENSOR_DEVICE_ATTR(fan2_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 1); static SENSOR_DEVICE_ATTR(fan3_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 2); static SENSOR_DEVICE_ATTR(fan4_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); -static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 0); -static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 1); -static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 2); -static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 3); -static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 4); +//static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); +static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 0); +static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 1); +static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 2); +static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 3); +//static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 4); static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4); +//static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4); static struct attribute *emc2305_attr[] = { @@ -113,17 +116,17 @@ static struct attribute *emc2305_attr[] = &sensor_dev_attr_fan2_input.dev_attr.attr, &sensor_dev_attr_fan3_input.dev_attr.attr, &sensor_dev_attr_fan4_input.dev_attr.attr, - &sensor_dev_attr_fan5_input.dev_attr.attr, +// &sensor_dev_attr_fan5_input.dev_attr.attr, &sensor_dev_attr_fan1_input_percentage.dev_attr.attr, &sensor_dev_attr_fan2_input_percentage.dev_attr.attr, &sensor_dev_attr_fan3_input_percentage.dev_attr.attr, &sensor_dev_attr_fan4_input_percentage.dev_attr.attr, - &sensor_dev_attr_fan5_input_percentage.dev_attr.attr, +// &sensor_dev_attr_fan5_input_percentage.dev_attr.attr, &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, &sensor_dev_attr_pwm3.dev_attr.attr, &sensor_dev_attr_pwm4.dev_attr.attr, - &sensor_dev_attr_pwm5.dev_attr.attr, +// &sensor_dev_attr_pwm5.dev_attr.attr, NULL }; @@ -169,6 +172,25 @@ static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *d return count; } +static ssize_t show_percentage(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct emc2305_data *data = i2c_get_clientdata(client); + int val; + + + mutex_lock(&data->lock); + val = i2c_smbus_read_word_swapped(client, + EMC2305_REG_FAN_TACH(attr->index)); + mutex_unlock(&data->lock); + /* Left shift 3 bits for showing correct RPM */ + val = val >> 3; + if ((int)(3932160 * 2 / (val > 0 ? val : 1) == 960))return sprintf(buf, "%d\n", 0); + + return sprintf(buf, "%d\n", (int)(3932160 * 2 / (val > 0 ? val : 1) * 100 / MAX_FAN_SPEED)); +} static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf) @@ -332,7 +354,7 @@ static int emc2305_probe(struct i2c_client *client, goto exit_remove; } - for (i = 0; i < 5; i++) + for (i = 0; i < 4; i++) { /* set minimum drive to 0% */ i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_MIN_DRIVE(i), FAN_MINIMUN); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c index 3c3014e0..4b2d45f0 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c @@ -39,14 +39,14 @@ typedef struct fan_path_S static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { { NULL, NULL, NULL }, - { "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input" }, - { "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input" }, - { "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input" }, - { "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input" }, - { "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input" }, - { "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input" }, - { "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input" }, - { "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input" }, + { "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input_percentage" }, + { "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input_percentage" }, + { "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input_percentage" }, + { "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input_percentage" }, + { "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input_percentage" }, + { "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input_percentage" }, + { "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input_percentage" }, + { "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input_percentage" }, { "/6-0059/psu_fan1_fault", "/6-0059/psu_fan1_speed_rpm", "/6-0059/psu_fan1_duty_cycle_percentage" }, { "/6-0058/psu_fan1_fault", "/6-0058/psu_fan1_speed_rpm", "/6-0058/psu_fan1_duty_cycle_percentage" } }; @@ -55,7 +55,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { \ { ONLP_FAN_ID_CREATE(FAN_##id##_ON_FAN_BOARD), "Chassis Fan "#id, 0 }, \ 0x0, \ - (ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ 0, \ 0, \ ONLP_FAN_MODE_INVALID, \ @@ -274,7 +274,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) case FAN_6_ON_FAN_BOARD: case FAN_7_ON_FAN_BOARD: case FAN_8_ON_FAN_BOARD: - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed); break; default: return ONLP_STATUS_E_INVALID; @@ -303,13 +303,21 @@ onlp_fani_percentage_set(onlp_oid_t id, int percentage) /* Select PSU member */ switch (local_id) { - case FAN_1_ON_PSU1: - case FAN_1_ON_PSU2: - break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + case FAN_7_ON_FAN_BOARD: + case FAN_8_ON_FAN_BOARD: + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + break; default: return ONLP_STATUS_E_INVALID; } - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); /* Write percentage to psu_fan1_duty_cycle_percentage */ sprintf(data, "%d", percentage); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c index 4400b2cc..a6584362 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c @@ -2,7 +2,7 @@ * * * Copyright 2014 Big Switch Networks, Inc. - * Copyright (C) 2017 Delta Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. * * Licensed under the Eclipse Public License, Version 1.0 (the * "License"); you may not use this file except in compliance @@ -43,44 +43,44 @@ * Get the information for the given LED OID. */ static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ { - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - }; + { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, +}; /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -104,10 +104,10 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) dev_info.flags = DEFAULT_FLAG; /* Set front panel's mode of leds */ - r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); + r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); int local_id = ONLP_OID_ID_GET(id); switch(local_id) - { + { case LED_FRONT_FAN: if((r_data & 0xc0) == 0x80) info->mode = ONLP_LED_MODE_GREEN; @@ -118,6 +118,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) else info->mode = ONLP_LED_MODE_OFF; break; + case LED_FRONT_SYS: if((r_data & 0x30) == 0x10) info->mode = ONLP_LED_MODE_GREEN; @@ -125,9 +126,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) info->mode = ONLP_LED_MODE_ORANGE; else if((r_data & 0x30) == 0x00) info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0x30) == 0x30) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; else return ONLP_STATUS_E_INTERNAL; break; + case LED_FRONT_PWR: if((r_data & 0x06) == 0x04) info->mode = ONLP_LED_MODE_GREEN; @@ -138,67 +142,80 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) else info->mode = ONLP_LED_MODE_OFF; break; + case LED_REAR_FAN_TRAY_1: dev_info.addr = FAN_TRAY_1; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x01) == 0x01) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x01) == 0x01) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x02) == 0x02) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_2: dev_info.addr = FAN_TRAY_2; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x04) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_3: dev_info.addr = FAN_TRAY_3; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x10) == 0x10) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x10) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x20) == 0x20) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_4: dev_info.addr = FAN_TRAY_4; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x40) == 0x40) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x40) == 0x40) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x80) == 0x80) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + default: break; - } + } /* Set the on/off status */ - if (info->mode == ONLP_LED_MODE_OFF) + if (info->mode == ONLP_LED_MODE_OFF) info->status |= ONLP_LED_STATUS_FAILED; else info->status |=ONLP_LED_STATUS_PRESENT; @@ -236,186 +253,145 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0 ,fan_board_not_present_count = 0 , fan_stat2_reg_mask = 0 , fan_stat1_reg_mask = 0 ; - int fantray_present = -1, rpm = 0, rpm1 = 0; - uint8_t front_panel_led_value, power_state,fan_tray_led_reg_value, fan_led_status_value, fan_tray_pres_value; - uint8_t psu1_state, psu2_state, alarm_reg_value, fan_tray_interface_detected_value; - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; + uint8_t front_panel_led_value,fan_tray_led_reg_value; front_panel_led_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); fan_tray_led_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); - fan_led_status_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT1_REG); - fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); - alarm_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,ALARM_REG); - + switch(local_id) - { + { case LED_FRONT_FAN: - /* Clean the bit 7,6 */ - front_panel_led_value &= ~0xC0; - fan_board_not_present_count = 0; - /* Read cpld fan status to check present. Fan tray 1-4 */ - for(i = 0; i < 4; i++) - { - fan_stat2_reg_mask = 0x01 << i; - fan_stat1_reg_mask = 0x01 << (i * 2); - if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask) - fan_board_not_present_count++; - else if((fan_led_status_value & fan_stat1_reg_mask) == fan_stat1_reg_mask) - count++; - } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST) - { - front_panel_led_value |= 0x80;/*Solid green, FAN operates normally.*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - else if (fan_board_not_present_count > 0) - { - front_panel_led_value |= 0xc0;/*Blinking Yellow , FAN is failed */ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } + front_panel_led_value &= ~0xc0; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x80; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x40; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0xc0; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } else - { - front_panel_led_value |= 0x40;/*Solid Amber FAN operating is NOT present */ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - - break; - - case LED_FRONT_PWR: - /* Clean bit 2,1 */ - front_panel_led_value &= ~0x06; - /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_6; - dev_info.addr = PSU1_EEPROM; - psu1_state = dni_i2c_lock_read(NULL, &dev_info); - /* switch CPLD to PSU 2 */ - dev_info.addr = PSU2_EEPROM; - psu2_state = dni_i2c_lock_read(NULL, &dev_info); - - if(psu1_state == 1 && psu2_state == 1) - { - power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG); - - if((power_state & 0x40) == 0x40 || (power_state & 0x04) == 0x04) - { - front_panel_led_value |= 0x06; /*Blinking Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - else - { - front_panel_led_value |= 0x04; /*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - } - else - front_panel_led_value |= 0x02; /*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); break; case LED_FRONT_SYS: - /* Clean bit 4,5 */ front_panel_led_value &= ~0x30; - fan_board_not_present_count = 0; - /* Read fan eeprom to check present */ - for(i = 0;i < 4; i++) - { - fan_stat2_reg_mask = 0x01 << i; - if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask) - fan_board_not_present_count++; - } - if(fan_board_not_present_count > 0 || (alarm_reg_value & 0xff) == 0xff) - { - fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG); - if(fan_tray_interface_detected_value == 0xfe || (alarm_reg_value & 0xff) == 0xff) - { - front_panel_led_value |= 0x20; - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value); - } - } + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x10; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x20; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x00; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0x30; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } else - { - front_panel_led_value |= 0x10; - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + break; + + case LED_FRONT_PWR: + front_panel_led_value &= ~0x06; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x04; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x02; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0x06; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); break; case LED_REAR_FAN_TRAY_1: - dev_info.addr = FAN_TRAY_1; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); fan_tray_led_reg_value &= ~0x03; - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x01;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x01; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x02; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x02;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_2: - dev_info.addr = FAN_TRAY_2; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); fan_tray_led_reg_value &= ~0x0c; - - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x04;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x04; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x08; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x08;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_3: - dev_info.addr = FAN_TRAY_3; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); fan_tray_led_reg_value &= ~0x30; - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x10;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x10; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x20; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x20;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_4: - dev_info.addr = FAN_TRAY_4; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); fan_tray_led_reg_value &= ~0xc0; - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm !=0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x40; /*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x40; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x80; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x80;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + break; + } return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c index 648296d3..d6046c6e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c @@ -41,24 +41,29 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in int fd; int len; - if ((buffer == NULL) || (buf_size < 0)) { + if ((buffer == NULL) || (buf_size < 0)) + { return -1; } - if ((fd = open(filename, O_RDONLY)) == -1) { + if ((fd = open(filename, O_RDONLY)) == -1) + { return -1; } - if ((len = read(fd, buffer, buf_size)) < 0) { + if ((len = read(fd, buffer, buf_size)) < 0) + { close(fd); return -1; } - if ((close(fd) == -1)) { + if ((close(fd) == -1)) + { return -1; } - if ((len > buf_size) || (data_len != 0 && len != data_len)) { + if ((len > buf_size) || (data_len != 0 && len != data_len)) + { return -1; } @@ -278,3 +283,31 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data) return -1; } + +int dni_fan_speed_good() +{ + int rpm = 0, rpm1 = 0, speed_good = 0; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + return speed_good; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h index 8e617859..80792c62 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h @@ -39,7 +39,7 @@ #define MAX_REAR_FAN_SPEED 20500 #define MAX_FRONT_FAN_SPEED 23000 -#define MAX_PSU_FAN_SPEED 19000 +#define MAX_PSU_FAN_SPEED 20256 #define NUM_OF_SFP 48 #define NUM_OF_QSFP 6 @@ -94,6 +94,7 @@ #define TURN_OFF (0) #define TURN_ON (1) #define ALL_FAN_TRAY_EXIST (4) +#define FAN_SPEED_NORMALLY (4) #define PSU_STATUS_PRESENT (1) #define PSU_NODE_MAX_PATH_LEN (64) #define FAN_ZERO_RPM (960) @@ -133,7 +134,6 @@ #define FAN_STAT1_REG (0x05) #define FAN_STAT2_REG (0x06) #define PSU_STAT_REG (0x03) -#define ALARM_REG (0x06) #define INTERRUPT_REG (0x02) #define PORT_ADDR (0x50) @@ -170,6 +170,7 @@ 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_cpld_write_attribute(char *cpld_path, int addr, int data); int dni_lock_cpld_read_attribute(char *cpld_path, int addr); +int dni_fan_speed_good(); #define DEBUG_MODE 0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c index f5e6204b..183d15fe 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c @@ -172,10 +172,10 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max) int onlp_sysi_platform_manage_fans(void) { - int i = 0; - int new_percentage; - int highest_temp = 0; - onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS]; + int i = 0; + int new_percentage; + int highest_temp = 0; + onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS]; /* Get current temperature */ if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), &thermal[0]) != ONLP_STATUS_OK || onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), &thermal[1]) != ONLP_STATUS_OK || @@ -234,77 +234,136 @@ onlp_sysi_platform_manage_fans(void) int onlp_sysi_platform_manage_leds(void) { - /* Set front lights: fan, power supply 1, 2*/ - uint8_t addr, present_bit = 0x00; + int fantray_present = -1, rpm = 0, rpm1 = 0; + uint8_t psu1_state, psu2_state, power_state, fan_tray_interface_detected_value; + int fan_tray_pres_value, fan_board_not_present_count,i ,fan_stat_reg_mask; - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - /* Turn the fan led on or off */ - if((addr & 0xc0) == 0 ) + + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + /* Fan tray 1 */ + dev_info.addr = FAN_TRAY_1; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED); } - /* Set front light of SYS */ - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - if((addr & 0x30) == 0x30) + /* Fan tray 2 */ + dev_info.addr = FAN_TRAY_2; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED); } - /* Set front light of PSU */ - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - - if((addr & 0x06) == 0x00) + /* Fan tray 3 */ + dev_info.addr = FAN_TRAY_3; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED); } + + /* Fan tray 4 */ + dev_info.addr = FAN_TRAY_4; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); + } + else + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED); + } + + /* FRONT FAN & SYS LED */ + fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); + fan_board_not_present_count = 0; + + for(i = 0;i < 4; i++) + { + fan_stat_reg_mask = 0x01 << i; + if((fan_tray_pres_value & fan_stat_reg_mask) == fan_stat_reg_mask) + fan_board_not_present_count++; + } + + if(fan_board_not_present_count == 0 && dni_fan_speed_good() == FAN_SPEED_NORMALLY) + { + /* Green FAN operates normally */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_GREEN); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_GREEN); + } + else + { + /* Solid Amber FAN or more failed*/ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_ORANGE); + fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG); + + if(fan_tray_interface_detected_value == 0xfe || (fan_tray_pres_value & 0x10) != 0x10) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_ORANGE); + } + } + + /* Set front light of PWR */ + dev_info.bus = I2C_BUS_6; + dev_info.addr = PSU1_EEPROM; + psu1_state = dni_i2c_lock_read(NULL, &dev_info); - /* Turn on or off the FAN tray leds */ - present_bit = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); - if((present_bit & 0x01) == 0x00) + dev_info.addr = PSU2_EEPROM; + psu2_state = dni_i2c_lock_read(NULL, &dev_info); + power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG); + + if( psu1_state == 1 && psu2_state == 1 && (power_state & 0x22) == 0x22 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else if((power_state & 0x42) == 0x42 || (power_state & 0x24) == 0x24) + { + /* Blinking Amber */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE_BLINKING); } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); - } - if((present_bit & 0x02) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); - } - if((present_bit & 0x04) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); - } - if((present_bit & 0x08) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); + else if ( ( power_state & 0x42 ) != 0x42 || ( power_state & 0x24 ) != 0x24 ) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c index 22448190..b6ff50af 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c @@ -69,28 +69,28 @@ static char* cpu_coretemp_files[] = /* Static values */ static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(70000,80000,85000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) }, @@ -98,11 +98,11 @@ static onlp_thermal_info_t linfo[] = { ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS } @@ -151,5 +151,4 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) info->mcelsius = r_data / temp_base; return ONLP_STATUS_OK; -} - +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py index 336790ff..ae6dbc53 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py @@ -62,7 +62,6 @@ class OnlPlatform_x86_64_delta_ag5648_r0(OnlPlatformDelta, os.system("echo 80000 > /sys/class/hwmon/hwmon8/temp1_max_hyst") os.system("echo 60000 > /sys/class/hwmon/hwmon9/temp1_max_hyst") os.system("echo 55000 > /sys/class/hwmon/hwmon10/temp1_max_hyst") - return True From 706c08de46b4898e79420956eb76031bd80b9b47 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Wed, 1 Nov 2017 10:28:54 +0000 Subject: [PATCH 058/244] Added doc and support for building behind an HTTP proxy --- .../any/rootfs/jessie/standard/standard.yml | 2 +- .../any/rootfs/stretch/standard/standard.yml | 2 +- .../any/rootfs/wheezy/standard/standard.yml | 2 +- docs/README-proxy.md | 29 +++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 docs/README-proxy.md diff --git a/builds/any/rootfs/jessie/standard/standard.yml b/builds/any/rootfs/jessie/standard/standard.yml index fad73bd8..b7aa4067 100644 --- a/builds/any/rootfs/jessie/standard/standard.yml +++ b/builds/any/rootfs/jessie/standard/standard.yml @@ -42,7 +42,7 @@ Multistrap: ONL: packages: *Packages - source: http://apt.opennetlinux.org/debian + source: http://${APT_CACHE}apt.opennetlinux.org/debian suite: unstable omitdebsrc: true diff --git a/builds/any/rootfs/stretch/standard/standard.yml b/builds/any/rootfs/stretch/standard/standard.yml index 48969cbe..b57fe6c7 100644 --- a/builds/any/rootfs/stretch/standard/standard.yml +++ b/builds/any/rootfs/stretch/standard/standard.yml @@ -42,7 +42,7 @@ Multistrap: ONL: packages: *Packages - source: http://apt.opennetlinux.org/debian + source: http://${APT_CACHE}apt.opennetlinux.org/debian suite: unstable omitdebsrc: true diff --git a/builds/any/rootfs/wheezy/standard/standard.yml b/builds/any/rootfs/wheezy/standard/standard.yml index 083fb7a9..22530fb0 100644 --- a/builds/any/rootfs/wheezy/standard/standard.yml +++ b/builds/any/rootfs/wheezy/standard/standard.yml @@ -42,7 +42,7 @@ Multistrap: ONL: packages: *Packages - source: http://apt.opennetlinux.org/debian + source: http://${APT_CACHE}apt.opennetlinux.org/debian suite: unstable omitdebsrc: true diff --git a/docs/README-proxy.md b/docs/README-proxy.md new file mode 100644 index 00000000..f36d9f1d --- /dev/null +++ b/docs/README-proxy.md @@ -0,0 +1,29 @@ +===== How to build ONL behind an HTTP Proxy ===== + +Many corporate environments don't provide native access to the Internet +and instead all access must go through an HTTP proxy. Since the ONL +build process dynamically pulls lots of things, this can be a pain. +While everyone's setup is different, hopefully these directions help +reduce that pain. + + +1) Update the git modules to point to http: instead of git: + + sed -i -e 's/git:/http:/' $ONL/.gitmodules + +2) Make sure you have apt-cacher-ng installed in your host (non-docker) + environment and that docker starts it. Next, configure it to use + your proxy: + + $ grep Proxy /etc/apt-cacher-ng/acng.conf + Proxy: http://myproxy.mycompany.com:8080 + # /etc/init.d/apt-cacher-ng restart + +3) Make sure your git config is configured correctly for + proxies: + + $ cat ~/.gitconfig + [https] + proxy = myproxy.mycompany.com:8080 + [https] + proxy = myproxy.mycompany.com:8080 From 0e2505a30710096888900915a8fb1840c5d112b3 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Wed, 1 Nov 2017 10:37:41 -0700 Subject: [PATCH 059/244] Update README-proxy.md --- docs/README-proxy.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README-proxy.md b/docs/README-proxy.md index f36d9f1d..d69bae87 100644 --- a/docs/README-proxy.md +++ b/docs/README-proxy.md @@ -1,4 +1,4 @@ -===== How to build ONL behind an HTTP Proxy ===== +# How to build ONL behind an HTTP Proxy Many corporate environments don't provide native access to the Internet and instead all access must go through an HTTP proxy. Since the ONL @@ -17,7 +17,7 @@ reduce that pain. $ grep Proxy /etc/apt-cacher-ng/acng.conf Proxy: http://myproxy.mycompany.com:8080 - # /etc/init.d/apt-cacher-ng restart + $ sudo /etc/init.d/apt-cacher-ng restart 3) Make sure your git config is configured correctly for proxies: From cf5e803786c8d19a42ac74229468802af938a2ff Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Wed, 1 Nov 2017 10:41:16 -0700 Subject: [PATCH 060/244] Update README-proxy.md --- docs/README-proxy.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/README-proxy.md b/docs/README-proxy.md index d69bae87..f3e395de 100644 --- a/docs/README-proxy.md +++ b/docs/README-proxy.md @@ -7,23 +7,24 @@ While everyone's setup is different, hopefully these directions help reduce that pain. -1) Update the git modules to point to http: instead of git: +* Update the git modules to point to http: instead of git: - sed -i -e 's/git:/http:/' $ONL/.gitmodules -2) Make sure you have apt-cacher-ng installed in your host (non-docker) + sed -i -e 's/git:/http:/' $ONL/.gitmodules + +* Make sure you have apt-cacher-ng installed in your host (non-docker) environment and that docker starts it. Next, configure it to use your proxy: - $ grep Proxy /etc/apt-cacher-ng/acng.conf - Proxy: http://myproxy.mycompany.com:8080 - $ sudo /etc/init.d/apt-cacher-ng restart + $ grep Proxy /etc/apt-cacher-ng/acng.conf + Proxy: http://myproxy.mycompany.com:8080 + $ sudo /etc/init.d/apt-cacher-ng restart -3) Make sure your git config is configured correctly for +* Make sure your git config is configured correctly for proxies: - $ cat ~/.gitconfig - [https] - proxy = myproxy.mycompany.com:8080 - [https] - proxy = myproxy.mycompany.com:8080 + $ cat ~/.gitconfig + [https] + proxy = myproxy.mycompany.com:8080 + [https] + proxy = myproxy.mycompany.com:8080 From 183140402a5258b2488ea73876977dc593f8d772 Mon Sep 17 00:00:00 2001 From: hans Date: Thu, 2 Nov 2017 11:34:45 +0800 Subject: [PATCH 061/244] 1. Fix the psu Voltage error 2. Modify ledi.c for fan tray led 3. Modify front panel led & fan tray led function Signed-off-by: hans --- .../modules/builds/agc7648a_dps800ab.c | 6 +- .../onlp/builds/src/module/src/ledi.c | 274 +++++++++--------- .../onlp/builds/src/module/src/platform_lib.h | 2 +- .../onlp/builds/src/module/src/sysi.c | 166 ++++++++--- .../x86_64_delta_agc7648a_r0/__init__.py | 2 +- 5 files changed, 271 insertions(+), 179 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c index 0d9b4aee..cc7c54cd 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c @@ -257,9 +257,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent)); + return (exponent > 0) ? \ + sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent)); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c index b9b68115..d752236a 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c @@ -51,37 +51,37 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, }, { { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, }, { { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "REAR LED (FAN TRAY 1)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED , }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "REAR LED (FAN TRAY 2)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "REAR LED (FAN TRAY 3)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "REAR LED (FAN TRAY 4)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, } }; /* @@ -121,23 +121,35 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { case LED_FRONT_FAN: if((r_data & 0x02) == 0x02) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x01) == 0x01) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x01) == 0x01) + info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0x01) == 0x03) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if((r_data & 0x01) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_SYS: - if((r_data & 0x10) == 0x10) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x20) == 0x20) - info->mode = ONLP_LED_MODE_ORANGE; - else - return ONLP_STATUS_E_INTERNAL; + if((r_data & 0xF0) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0xF0) == 0x20) + info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0xF0) == 0xa0) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if((r_data & 0xF0) == 0x90) + info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0xF0) == 0x0) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_PWR: if((r_data & 0x08) == 0x08) - info->mode = ONLP_LED_MODE_GREEN; + info->mode = ONLP_LED_MODE_GREEN; else if((r_data & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_ORANGE; else info->mode = ONLP_LED_MODE_OFF; break; @@ -151,10 +163,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x80) == 0x80) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_2: mux_info.channel= 0x01; @@ -166,10 +180,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x10) == 0x10) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x20) == 0x20) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_3: mux_info.channel= 0x02; @@ -178,13 +194,15 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); if(fantray_present >= 0) { - if((r_data1 & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data1 & 0x08) == 0x08) - info->mode = ONLP_LED_MODE_ORANGE; + if((r_data1 & 0x04) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data1 & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_4: mux_info.channel= 0x03; @@ -196,10 +214,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x01) == 0x01) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x02) == 0x02) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; default: @@ -250,23 +270,7 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0 ; - int fantray_present = -1 ,rpm = 0,rpm1 = 0; - uint8_t front_panel_led_value, fan_tray_led_value, power_state; - - - mux_info_t mux_info; - mux_info.bus = I2C_BUS_5; - mux_info.addr = SWPLD; - mux_info.offset = FAN_MUX_REG; - mux_info.channel = 0x07; - mux_info.flags = DEFAULT_FLAG; - - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; - + uint8_t front_panel_led_value, fan_tray_led_value; front_panel_led_value = dni_lock_cpld_read_attribute(SWPLD_PATH,LED_REG); fan_tray_led_value = dni_lock_cpld_read_attribute(SWPLD_PATH,FAN_TRAY_LED_REG); @@ -275,141 +279,137 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) case LED_FRONT_FAN: /* Clean the bit 1,0 */ front_panel_led_value &= ~0x3; - /* Read fan eeprom to check present */ - for(i = 0;i < 4; i++) + if(mode == ONLP_LED_MODE_GREEN) { - mux_info.channel = i; - /* FAN TRAT 1~4: 0x52 , 0x53, 0x54, 0x55 */ - dev_info.addr = FAN_TRAY_1 + i; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - if( fantray_present >= 0 ) - count++; + front_panel_led_value |= 0x02; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST) + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) { - front_panel_led_value|=0x02; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x03; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x01; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_OFF) + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); else - { - front_panel_led_value|=0x01; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); - } - + return ONLP_STATUS_E_UNSUPPORTED; break; + case LED_FRONT_SYS: + front_panel_led_value &= ~0xF0; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x10; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0xA0; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x20; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x90; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_OFF) + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + else + return ONLP_STATUS_E_UNSUPPORTED; + break; + case LED_FRONT_PWR: /* Clean bit 3,2 */ front_panel_led_value &= ~0x0C; /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_4; - dev_info.addr = PSU_EEPROM; - mux_info.channel = 0x00; - - /* Check the state of PSU 1, "state = 1, PSU exists' */ - power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); - /* Set the light of PSU */ - if((power_state&0x80) != 0x80) + if(mode == ONLP_LED_MODE_GREEN) { - /* Red */ - front_panel_led_value|=0x04; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x08; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - else if((power_state&0x80)==0x80) + else if(mode == ONLP_LED_MODE_ORANGE) { - /* Green */ - front_panel_led_value|=0x08; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x04; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - else - dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG, front_panel_led_value); + else if(mode == ONLP_LED_MODE_OFF) + { + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else + return ONLP_STATUS_E_UNSUPPORTED; break; - case LED_REAR_FAN_TRAY_1: - mux_info.channel= 0x00; - dev_info.addr = FAN_TRAY_1; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); fan_tray_led_value &= ~0xC0; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x40; + fan_tray_led_value |= 0x40; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x80; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x80; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; - case LED_REAR_FAN_TRAY_2: - mux_info.channel= 0x01; - dev_info.addr = FAN_TRAY_2; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - fan_tray_led_value &= ~0x30; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + case LED_REAR_FAN_TRAY_2: + fan_tray_led_value &= ~0x30; + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x10; + fan_tray_led_value |= 0x10; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x20; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x20; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; case LED_REAR_FAN_TRAY_3: - mux_info.channel= 0x02; - dev_info.bus = I2C_BUS_3; - dev_info.addr = FAN_TRAY_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); fan_tray_led_value &= ~0x0c; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x04; + fan_tray_led_value |= 0x04; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x08; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x08; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; case LED_REAR_FAN_TRAY_4: - mux_info.channel= 0x03; - dev_info.addr = FAN_TRAY_4; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); fan_tray_led_value &= ~0x03; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x01; + fan_tray_led_value |= 0x01; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x02; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x02; - dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } - break; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + + break; } return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h index 3a73af24..1e1eb419 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h @@ -33,7 +33,7 @@ #define PSU1_ID 1 #define PSU2_ID 2 - +#define ALL_FAN_TRAY_EXIST 4 #define SYS_DEV_PATH "/sys/bus/i2c/devices" #define CPU_CPLD_PATH SYS_DEV_PATH "/2-0031" #define SWPLD_PATH SYS_DEV_PATH "/5-0030" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c index 22214e61..d28595f5 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c @@ -58,27 +58,27 @@ decide_percentage(int *percentage, int temper) { int level; - if(temper < 65) + if(temper <= 25) { - *percentage = 50; + *percentage = 40; level = 0; } - else if(temper >= 65 && temper <= 70) + else if(temper > 25 && temper <= 40) { *percentage = 60; level = 1; } - else if(temper > 70 && temper <= 75) + else if(temper > 40 && temper <= 55) { - *percentage = 70; + *percentage = 80; level = 2; } - else if(temper > 75 && temper <= 80) + else if(temper > 55 && temper <= 75) { - *percentage = 85; + *percentage = 90; level = 3; } - else if(temper > 80) + else if(temper > 75) { *percentage = 100; level = 4; @@ -229,64 +229,156 @@ int onlp_sysi_platform_manage_leds(void) { - uint8_t present_bit = 0 ,addr = 0; - + uint8_t count, power_state; + int fantray_present = -1 ,rpm = 0,rpm1 = 0 , i; /* set PWR led in front panel */ - addr = dni_lock_cpld_read_attribute(SWPLD_PATH,LED_REG); - /* Turn the fan led on or off */ - if((addr & 0x3) == 0 || (addr & 0x3) == 0x3 ) + mux_info_t mux_info; + mux_info.bus = I2C_BUS_5; + mux_info.addr = SWPLD; + mux_info.offset = FAN_MUX_REG; + mux_info.channel = 0x07; + mux_info.flags = DEFAULT_FLAG; + + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + + /* FRONT FAN & SYS LED */ + for(i = 0;i < 4; i++) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); + mux_info.channel = i; + /* FAN TRAT 1~4: 0x52 , 0x53, 0x54, 0x55 */ + dev_info.addr = FAN_TRAY_1 + i; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + if( fantray_present >= 0 ) + count++; + } + if(count == ALL_FAN_TRAY_EXIST) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_ORANGE); } - if(dni_psu_present_get(1) == 1) - { /* PSU1 is present */ - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF); - } - /* Rare light fan tray 1-4 */ - present_bit = dni_lock_cpld_read_attribute(SWPLD_PATH,FAN_TRAY_LED_REG); + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; - if ((present_bit& 0x08) == 0x00) + /* Check the state of PSU 1, "state = 1, PSU exists' */ + power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); + /* Set the light of PSU */ + if((power_state&0x80) != 0x80) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); + /* ORANGE */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); + } + else if((power_state&0x80)==0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + + mux_info.channel= 0x00; + dev_info.addr = FAN_TRAY_1; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED); } - if ((present_bit& 0x04) == 0x00) + /* Fan tray 2 */ + mux_info.channel= 0x01; + dev_info.addr = FAN_TRAY_2; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED); } - if ((present_bit& 0x02) == 0x00) + + /* Fan tray 3 */ + mux_info.channel= 0x02; + dev_info.bus = I2C_BUS_3; + dev_info.addr = FAN_TRAY_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED); } - if ((present_bit& 0x01) == 0x00) + + /* Fan tray 4 */ + mux_info.channel= 0x03; + dev_info.addr = FAN_TRAY_4; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED); } + + + /* Set front light of PWR */ + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; + + /* Check the state of PSU 1, "state = 1, PSU exists' */ + power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); + /* Set the light of PSU */ + + if((power_state&0x80) == 0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else if((power_state&0x80) != 0x80) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py index bb01636e..7e84909b 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py @@ -50,6 +50,6 @@ class OnlPlatform_x86_64_delta_agc7648a_r0(OnlPlatformDelta, self.new_i2c_device('agc7648a_sfp', 0x50, 8) # Set front panel green light of sys led - os.system("echo 0x30 > /sys/bus/i2c/devices/5-0030/addr") + os.system("echo 0x1c > /sys/bus/i2c/devices/5-0030/addr") os.system("echo 0x10 > /sys/bus/i2c/devices/5-0030/data") return True From d36023a1a55d7a7cc35ec791e832b52ba95ebb6e Mon Sep 17 00:00:00 2001 From: Wilson Ng Date: Thu, 9 Nov 2017 04:00:06 -0800 Subject: [PATCH 062/244] Latest bigcode. --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index a77f6c6b..a8c72b6c 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit a77f6c6b1ca1c895f954fdbf37991af49c7496d8 +Subproject commit a8c72b6c0553a3547be6be16b41fae2af5b38951 From 5b3db5947f93f673f1815c343fab7d43afa530e9 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 12 Nov 2017 19:36:24 +0000 Subject: [PATCH 063/244] Latest infra (module generator updates). --- sm/infra | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/infra b/sm/infra index 36947a54..2b72b5dc 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 36947a5451e7d4fb4e9008aa346786fffc6fc82a +Subproject commit 2b72b5dce5e910f31e855eebbeb41a0e481e35d1 From 2624a062b8f73cb6ee20b91744a5d36fbd3d1d4e Mon Sep 17 00:00:00 2001 From: Michael Shych Date: Mon, 13 Nov 2017 12:51:57 +0000 Subject: [PATCH 064/244] Add ONL based on Debian 9 and kernel 4.9.30 support for Mellanox platforms MSN2700, MSN2410, MSN2100. Signed-off-by: Michael Shych --- .../stretch/common/all-base-packages.yml | 1 + .../stretch/common/amd64-base-packages.yml | 3 +- .../configs/x86_64-all/x86_64-all.config | 396 ++- ...d-master-driver-for-Mellanox-systems.patch | 544 +++++ ...cpld-add-driver-for-Mellanox-systems.patch | 317 +++ ...x-Introduce-Mellanox-hardware-platfo.patch | 1463 ++++++++++++ ...roduce-support-for-Mellanox-hotplug-.patch | 905 +++++++ ...for-support-Mellanox-regmap-LEDs-for.patch | 398 ++++ ...0006-Mellanox-switch-drivers-changes.patch | 2118 +++++++++++++++++ ...-support-for-Intel-VID-protocol-VR13.patch | 30 + ...support-for-Texas-Instruments-tps536.patch | 151 ++ .../base/any/kernels/4.9-lts/patches/series | 8 + .../onlp/builds/src/module/src/ledi.c | 107 +- .../onlp/builds/src/module/src/platform_lib.c | 30 +- .../onlp/builds/src/module/src/platform_lib.h | 5 + .../onlp/builds/src/module/src/psui.c | 11 +- .../onlp/builds/src/module/src/sfpi.c | 25 +- .../onlp/builds/src/module/src/sysi.c | 42 +- .../r0/src/lib/x86-64-mlnx-msn2100-r0.yml | 2 +- .../onlp/builds/src/module/src/fani.c | 2 + .../onlp/builds/src/module/src/ledi.c | 111 +- .../onlp/builds/src/module/src/platform_lib.c | 30 + .../onlp/builds/src/module/src/platform_lib.h | 5 + .../onlp/builds/src/module/src/psui.c | 4 +- .../onlp/builds/src/module/src/sfpi.c | 19 +- .../onlp/builds/src/module/src/sysi.c | 48 +- .../r0/src/lib/x86-64-mlnx-msn2410-r0.yml | 2 +- .../onlp/builds/src/module/src/fani.c | 5 +- .../onlp/builds/src/module/src/ledi.c | 111 +- .../onlp/builds/src/module/src/platform_lib.c | 30 + .../onlp/builds/src/module/src/platform_lib.h | 5 + .../onlp/builds/src/module/src/psui.c | 4 +- .../onlp/builds/src/module/src/sfpi.c | 25 +- .../onlp/builds/src/module/src/sysi.c | 49 +- .../r0/src/lib/x86-64-mlnx-msn2700-r0.yml | 2 +- 35 files changed, 6934 insertions(+), 74 deletions(-) create mode 100644 packages/base/any/kernels/4.9-lts/patches/0001-i2c-mlxcpld-add-master-driver-for-Mellanox-systems.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0002-i2c-mux-mlxcpld-add-driver-for-Mellanox-systems.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0003-platform-mellanox-Introduce-Mellanox-hardware-platfo.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0004-platform-x86-Introduce-support-for-Mellanox-hotplug-.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0005-leds-add-driver-for-support-Mellanox-regmap-LEDs-for.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0006-Mellanox-switch-drivers-changes.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0007-hwmon-pmbus-Add-support-for-Intel-VID-protocol-VR13.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0008-hwmon-pmbus-Add-support-for-Texas-Instruments-tps536.patch diff --git a/builds/any/rootfs/stretch/common/all-base-packages.yml b/builds/any/rootfs/stretch/common/all-base-packages.yml index e6ef6a3a..9c5db8ff 100644 --- a/builds/any/rootfs/stretch/common/all-base-packages.yml +++ b/builds/any/rootfs/stretch/common/all-base-packages.yml @@ -41,6 +41,7 @@ - usbutils - mtd-utils - i2c-tools +- kmod - isc-dhcp-client - ntp - wget diff --git a/builds/any/rootfs/stretch/common/amd64-base-packages.yml b/builds/any/rootfs/stretch/common/amd64-base-packages.yml index efaf425b..33b95236 100644 --- a/builds/any/rootfs/stretch/common/amd64-base-packages.yml +++ b/builds/any/rootfs/stretch/common/amd64-base-packages.yml @@ -9,7 +9,6 @@ - grub2 - onl-upgrade - hw-management -- sx-kernel -- onl-kernel-3.16-lts-x86-64-all-modules +- onl-kernel-4.9-lts-x86-64-all-modules - efibootmgr - gdisk diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index b616ae79..f475b11d 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -399,7 +399,6 @@ CONFIG_X86_EXTENDED_PLATFORM=y # CONFIG_X86_VSMP is not set # CONFIG_X86_GOLDFISH is not set # CONFIG_X86_INTEL_MID is not set -# CONFIG_MLX_PLATFORM is not set # CONFIG_X86_INTEL_LPSS is not set # CONFIG_X86_AMD_PLATFORM_DEVICE is not set # CONFIG_IOSF_MBI is not set @@ -1143,6 +1142,7 @@ CONFIG_DEBUG_DEVRES=y CONFIG_GENERIC_CPU_AUTOPROBE=y CONFIG_REGMAP=y CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_SPI=y CONFIG_DMA_SHARED_BUFFER=y # CONFIG_FENCE_TRACE is not set @@ -1207,17 +1207,21 @@ CONFIG_VIRTIO_BLK=y # CONFIG_SENSORS_APDS990X is not set # CONFIG_HMC6352 is not set # CONFIG_DS1682 is not set +# CONFIG_TI_DAC7512 is not set # CONFIG_USB_SWITCH_FSA9480 is not set +# CONFIG_LATTICE_ECP3_CONFIG is not set # CONFIG_SRAM is not set # CONFIG_C2PORT is not set # # EEPROM support # -# CONFIG_EEPROM_AT24 is not set +CONFIG_EEPROM_AT24=m +# CONFIG_EEPROM_AT25 is not set # CONFIG_EEPROM_LEGACY is not set # CONFIG_EEPROM_MAX6875 is not set # CONFIG_EEPROM_93CX6 is not set +# CONFIG_EEPROM_93XX46 is not set # CONFIG_CB710_CORE is not set # @@ -1580,11 +1584,21 @@ CONFIG_NET_VENDOR_MELLANOX=y # CONFIG_MLX4_EN is not set # CONFIG_MLX4_CORE is not set # CONFIG_MLX5_CORE is not set -# CONFIG_MLXSW_CORE is not set +CONFIG_MLXSW_CORE=y +CONFIG_MLXSW_CORE_HWMON=y +CONFIG_MLXSW_CORE_THERMAL=y +CONFIG_MLXSW_CORE_QSFP=y +# CONFIG_MLXSW_PCI is not set +CONFIG_MLXSW_I2C=y +CONFIG_MLXSW_MINIMAL=y CONFIG_NET_VENDOR_MICREL=y # CONFIG_KS8842 is not set +# CONFIG_KS8851 is not set # CONFIG_KS8851_MLL is not set # CONFIG_KSZ884X_PCI is not set +CONFIG_NET_VENDOR_MICROCHIP=y +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set CONFIG_NET_VENDOR_MYRI=y # CONFIG_MYRI10GE is not set # CONFIG_FEALNX is not set @@ -1704,6 +1718,7 @@ CONFIG_PHYLIB=y # CONFIG_TERANETICS_PHY is not set # CONFIG_VITESSE_PHY is not set # CONFIG_XILINX_GMII2RGMII is not set +# CONFIG_MICREL_KS8995MA is not set # CONFIG_PPP is not set # CONFIG_SLIP is not set CONFIG_USB_NET_DRIVERS=y @@ -1827,6 +1842,7 @@ CONFIG_INPUT_EVDEV=y # Input Device Drivers # CONFIG_INPUT_KEYBOARD=y +# CONFIG_KEYBOARD_ADC is not set # CONFIG_KEYBOARD_ADP5588 is not set # CONFIG_KEYBOARD_ADP5589 is not set CONFIG_KEYBOARD_ATKBD=y @@ -1899,6 +1915,8 @@ CONFIG_INPUT_TABLET=y # CONFIG_TABLET_SERIAL_WACOM4 is not set CONFIG_INPUT_TOUCHSCREEN=y CONFIG_TOUCHSCREEN_PROPERTIES=y +# CONFIG_TOUCHSCREEN_ADS7846 is not set +# CONFIG_TOUCHSCREEN_AD7877 is not set # CONFIG_TOUCHSCREEN_AD7879 is not set # CONFIG_TOUCHSCREEN_ATMEL_MXT is not set # CONFIG_TOUCHSCREEN_BU21013 is not set @@ -1933,6 +1951,7 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y # CONFIG_TOUCHSCREEN_TOUCHIT213 is not set # CONFIG_TOUCHSCREEN_TSC_SERIO is not set # CONFIG_TOUCHSCREEN_TSC2004 is not set +# CONFIG_TOUCHSCREEN_TSC2005 is not set # CONFIG_TOUCHSCREEN_TSC2007 is not set # CONFIG_TOUCHSCREEN_SILEAD is not set # CONFIG_TOUCHSCREEN_ST1232 is not set @@ -2038,6 +2057,8 @@ CONFIG_SERIAL_8250_MID=y # # Non-8250 serial port support # +# CONFIG_SERIAL_MAX3100 is not set +# CONFIG_SERIAL_MAX310X is not set # CONFIG_SERIAL_UARTLITE is not set CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y @@ -2086,8 +2107,15 @@ CONFIG_I2C=y CONFIG_ACPI_I2C_OPREGION=y CONFIG_I2C_BOARDINFO=y CONFIG_I2C_COMPAT=y -# CONFIG_I2C_CHARDEV is not set -# CONFIG_I2C_MUX is not set +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_MUX=y + +# +# Multiplexer I2C Chip support +# +# CONFIG_I2C_MUX_PCA9541 is not set +CONFIG_I2C_MUX_REG=y +CONFIG_I2C_MUX_MLXCPLD=y CONFIG_I2C_HELPER_AUTO=y CONFIG_I2C_SMBUS=y CONFIG_I2C_ALGOBIT=y @@ -2142,12 +2170,38 @@ CONFIG_I2C_I801=y # # Other I2C/SMBus bus drivers # +CONFIG_I2C_MLXCPLD=y # CONFIG_I2C_STUB is not set # CONFIG_I2C_SLAVE is not set # CONFIG_I2C_DEBUG_CORE is not set # CONFIG_I2C_DEBUG_ALGO is not set # CONFIG_I2C_DEBUG_BUS is not set -# CONFIG_SPI is not set +CONFIG_SPI=y +# CONFIG_SPI_DEBUG is not set +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +# CONFIG_SPI_ALTERA is not set +# CONFIG_SPI_AXI_SPI_ENGINE is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_SPI_CADENCE is not set +# CONFIG_SPI_DESIGNWARE is not set +# CONFIG_SPI_PXA2XX is not set +# CONFIG_SPI_PXA2XX_PCI is not set +# CONFIG_SPI_ROCKCHIP is not set +# CONFIG_SPI_SC18IS602 is not set +# CONFIG_SPI_XCOMM is not set +# CONFIG_SPI_XILINX is not set +# CONFIG_SPI_ZYNQMP_GQSPI is not set + +# +# SPI Protocol Masters +# +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_LOOPBACK_TEST is not set +# CONFIG_SPI_TLE62X0 is not set # CONFIG_SPMI is not set # CONFIG_HSI is not set @@ -2183,6 +2237,7 @@ CONFIG_PTP_1588_CLOCK=y CONFIG_POWER_SUPPLY=y # CONFIG_POWER_SUPPLY_DEBUG is not set # CONFIG_PDA_POWER is not set +# CONFIG_GENERIC_ADC_BATTERY is not set # CONFIG_TEST_POWER is not set # CONFIG_BATTERY_DS2780 is not set # CONFIG_BATTERY_DS2781 is not set @@ -2205,6 +2260,7 @@ CONFIG_HWMON=y # # CONFIG_SENSORS_ABITUGURU is not set # CONFIG_SENSORS_ABITUGURU3 is not set +# CONFIG_SENSORS_AD7314 is not set # CONFIG_SENSORS_AD7414 is not set # CONFIG_SENSORS_AD7418 is not set # CONFIG_SENSORS_ADM1021 is not set @@ -2213,6 +2269,7 @@ CONFIG_HWMON=y # CONFIG_SENSORS_ADM1029 is not set # CONFIG_SENSORS_ADM1031 is not set # CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7310 is not set # CONFIG_SENSORS_ADT7410 is not set # CONFIG_SENSORS_ADT7411 is not set # CONFIG_SENSORS_ADT7462 is not set @@ -2239,8 +2296,9 @@ CONFIG_HWMON=y # CONFIG_SENSORS_G760A is not set # CONFIG_SENSORS_G762 is not set # CONFIG_SENSORS_HIH6130 is not set +CONFIG_SENSORS_IIO_HWMON=y # CONFIG_SENSORS_I5500 is not set -# CONFIG_SENSORS_CORETEMP is not set +CONFIG_SENSORS_CORETEMP=y # CONFIG_SENSORS_IT87 is not set # CONFIG_SENSORS_JC42 is not set # CONFIG_SENSORS_POWR1220 is not set @@ -2253,19 +2311,23 @@ CONFIG_HWMON=y # CONFIG_SENSORS_LTC4245 is not set # CONFIG_SENSORS_LTC4260 is not set # CONFIG_SENSORS_LTC4261 is not set +# CONFIG_SENSORS_MAX1111 is not set # CONFIG_SENSORS_MAX16065 is not set # CONFIG_SENSORS_MAX1619 is not set # CONFIG_SENSORS_MAX1668 is not set # CONFIG_SENSORS_MAX197 is not set +# CONFIG_SENSORS_MAX31722 is not set # CONFIG_SENSORS_MAX6639 is not set # CONFIG_SENSORS_MAX6642 is not set # CONFIG_SENSORS_MAX6650 is not set # CONFIG_SENSORS_MAX6697 is not set # CONFIG_SENSORS_MAX31790 is not set # CONFIG_SENSORS_MCP3021 is not set +# CONFIG_SENSORS_ADCXX is not set # CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set # CONFIG_SENSORS_LM73 is not set -# CONFIG_SENSORS_LM75 is not set +CONFIG_SENSORS_LM75=y # CONFIG_SENSORS_LM77 is not set # CONFIG_SENSORS_LM78 is not set # CONFIG_SENSORS_LM80 is not set @@ -2286,7 +2348,21 @@ CONFIG_HWMON=y # CONFIG_SENSORS_NCT7802 is not set # CONFIG_SENSORS_NCT7904 is not set # CONFIG_SENSORS_PCF8591 is not set -# CONFIG_PMBUS is not set +CONFIG_PMBUS=y +CONFIG_SENSORS_PMBUS=y +# CONFIG_SENSORS_ADM1275 is not set +CONFIG_SENSORS_LM25066=y +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_LTC3815 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX20751 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX8688 is not set +# CONFIG_SENSORS_TPS40422 is not set +CONFIG_SENSORS_TPS53679=y +CONFIG_SENSORS_UCD9000=y +CONFIG_SENSORS_UCD9200=y +# CONFIG_SENSORS_ZL6100 is not set # CONFIG_SENSORS_SHT21 is not set # CONFIG_SENSORS_SHT3x is not set # CONFIG_SENSORS_SHTC1 is not set @@ -2305,13 +2381,14 @@ CONFIG_HWMON=y # CONFIG_SENSORS_ADC128D818 is not set # CONFIG_SENSORS_ADS1015 is not set # CONFIG_SENSORS_ADS7828 is not set +# CONFIG_SENSORS_ADS7871 is not set # CONFIG_SENSORS_AMC6821 is not set # CONFIG_SENSORS_INA209 is not set # CONFIG_SENSORS_INA2XX is not set # CONFIG_SENSORS_INA3221 is not set # CONFIG_SENSORS_TC74 is not set # CONFIG_SENSORS_THMC50 is not set -# CONFIG_SENSORS_TMP102 is not set +CONFIG_SENSORS_TMP102=y # CONFIG_SENSORS_TMP103 is not set # CONFIG_SENSORS_TMP401 is not set # CONFIG_SENSORS_TMP421 is not set @@ -2356,6 +2433,7 @@ CONFIG_X86_PKG_TEMP_THERMAL=m # # CONFIG_INT340X_THERMAL is not set # CONFIG_INTEL_PCH_THERMAL is not set +# CONFIG_GENERIC_ADC_THERMAL is not set CONFIG_WATCHDOG=y # CONFIG_WATCHDOG_CORE is not set # CONFIG_WATCHDOG_NOWAYOUT is not set @@ -2441,6 +2519,7 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_AXP20X_I2C is not set # CONFIG_MFD_CROS_EC is not set # CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_DA9052_SPI is not set # CONFIG_MFD_DA9052_I2C is not set # CONFIG_MFD_DA9055 is not set # CONFIG_MFD_DA9062 is not set @@ -2448,6 +2527,7 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_DA9150 is not set # CONFIG_MFD_DLN2 is not set # CONFIG_MFD_EXYNOS_LPASS is not set +# CONFIG_MFD_MC13XXX_SPI is not set # CONFIG_MFD_MC13XXX_I2C is not set # CONFIG_HTC_PASIC3 is not set # CONFIG_LPC_ICH is not set @@ -2468,6 +2548,7 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_MAX8998 is not set # CONFIG_MFD_MT6397 is not set # CONFIG_MFD_MENF21BMC is not set +# CONFIG_EZX_PCAP is not set # CONFIG_MFD_VIPERBOARD is not set # CONFIG_MFD_RETU is not set # CONFIG_MFD_PCF50633 is not set @@ -2496,6 +2577,7 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_TPS65218 is not set # CONFIG_MFD_TPS6586X is not set # CONFIG_MFD_TPS65912_I2C is not set +# CONFIG_MFD_TPS65912_SPI is not set # CONFIG_MFD_TPS80031 is not set # CONFIG_TWL4030_CORE is not set # CONFIG_TWL6040_CORE is not set @@ -2504,8 +2586,10 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_TMIO is not set # CONFIG_MFD_VX855 is not set # CONFIG_MFD_ARIZONA_I2C is not set +# CONFIG_MFD_ARIZONA_SPI is not set # CONFIG_MFD_WM8400 is not set # CONFIG_MFD_WM831X_I2C is not set +# CONFIG_MFD_WM831X_SPI is not set # CONFIG_MFD_WM8350_I2C is not set # CONFIG_MFD_WM8994 is not set # CONFIG_REGULATOR is not set @@ -2806,6 +2890,7 @@ CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0 CONFIG_SND_HDA_CORE=y CONFIG_SND_HDA_I915=y CONFIG_SND_HDA_PREALLOC_SIZE=64 +# CONFIG_SND_SPI is not set CONFIG_SND_USB=y # CONFIG_SND_USB_AUDIO is not set # CONFIG_SND_USB_UA101 is not set @@ -2961,6 +3046,7 @@ CONFIG_USB_EHCI_PCI=y # CONFIG_USB_ISP116X_HCD is not set # CONFIG_USB_ISP1362_HCD is not set # CONFIG_USB_FOTG210_HCD is not set +# CONFIG_USB_MAX3421_HCD is not set CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_HCD_PCI=y # CONFIG_USB_OHCI_HCD_PLATFORM is not set @@ -3079,6 +3165,7 @@ CONFIG_LEDS_CLASS=y # CONFIG_LEDS_CLEVO_MAIL is not set # CONFIG_LEDS_PCA955X is not set # CONFIG_LEDS_PCA963X is not set +# CONFIG_LEDS_DAC124S085 is not set # CONFIG_LEDS_BD2802 is not set # CONFIG_LEDS_INTEL_SS4200 is not set # CONFIG_LEDS_TCA6507 is not set @@ -3090,12 +3177,15 @@ CONFIG_LEDS_CLASS=y # # CONFIG_LEDS_BLINKM is not set # CONFIG_LEDS_MLXCPLD is not set +CONFIG_LEDS_MLXREG=y +# CONFIG_LEDS_USER is not set +# CONFIG_LEDS_NIC78BX is not set # # LED Triggers # CONFIG_LEDS_TRIGGERS=y -# CONFIG_LEDS_TRIGGER_TIMER is not set +CONFIG_LEDS_TRIGGER_TIMER=y # CONFIG_LEDS_TRIGGER_ONESHOT is not set # CONFIG_LEDS_TRIGGER_DISK is not set # CONFIG_LEDS_TRIGGER_HEARTBEAT is not set @@ -3165,6 +3255,21 @@ CONFIG_RTC_INTF_DEV=y # # SPI RTC drivers # +# CONFIG_RTC_DRV_M41T93 is not set +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1302 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1343 is not set +# CONFIG_RTC_DRV_DS1347 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6916 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RX4581 is not set +# CONFIG_RTC_DRV_RX6110 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_PCF2123 is not set +# CONFIG_RTC_DRV_MCP795 is not set CONFIG_RTC_I2C_AND_SPI=y # @@ -3289,7 +3394,10 @@ CONFIG_EEEPC_LAPTOP=y # CONFIG_INTEL_PMC_IPC is not set # CONFIG_SURFACE_PRO3_BUTTON is not set # CONFIG_INTEL_PUNIT_IPC is not set +CONFIG_MLX_PLATFORM=y # CONFIG_CHROME_PLATFORMS is not set +CONFIG_MELLANOX_PLATFORM=y +CONFIG_MLXREG_HOTPLUG=y # # Hardware Spinlock drivers @@ -3344,7 +3452,269 @@ CONFIG_INTEL_IOMMU_FLOPPY_WA=y # CONFIG_PM_DEVFREQ is not set # CONFIG_EXTCON is not set # CONFIG_MEMORY is not set -# CONFIG_IIO is not set +CONFIG_IIO=y +CONFIG_IIO_BUFFER=y +# CONFIG_IIO_BUFFER_CB is not set +CONFIG_IIO_KFIFO_BUF=y +CONFIG_IIO_TRIGGERED_BUFFER=y +# CONFIG_IIO_CONFIGFS is not set +CONFIG_IIO_TRIGGER=y +CONFIG_IIO_CONSUMERS_PER_TRIGGER=2 +# CONFIG_IIO_SW_DEVICE is not set +# CONFIG_IIO_SW_TRIGGER is not set + +# +# Accelerometers +# +# CONFIG_BMA180 is not set +# CONFIG_BMA220 is not set +# CONFIG_BMC150_ACCEL is not set +# CONFIG_DMARD09 is not set +# CONFIG_IIO_ST_ACCEL_3AXIS is not set +# CONFIG_KXSD9 is not set +# CONFIG_KXCJK1013 is not set +# CONFIG_MC3230 is not set +# CONFIG_MMA7455_I2C is not set +# CONFIG_MMA7455_SPI is not set +# CONFIG_MMA7660 is not set +# CONFIG_MMA8452 is not set +# CONFIG_MMA9551 is not set +# CONFIG_MMA9553 is not set +# CONFIG_MXC4005 is not set +# CONFIG_MXC6255 is not set +# CONFIG_STK8312 is not set +# CONFIG_STK8BA50 is not set + +# +# Analog to digital converters +# +# CONFIG_AD7266 is not set +# CONFIG_AD7291 is not set +# CONFIG_AD7298 is not set +# CONFIG_AD7476 is not set +# CONFIG_AD7791 is not set +# CONFIG_AD7793 is not set +# CONFIG_AD7887 is not set +# CONFIG_AD7923 is not set +# CONFIG_AD799X is not set +# CONFIG_HI8435 is not set +# CONFIG_INA2XX_ADC is not set +# CONFIG_LTC2485 is not set +# CONFIG_MAX1027 is not set +CONFIG_MAX1363=y +# CONFIG_MCP320X is not set +# CONFIG_MCP3422 is not set +# CONFIG_NAU7802 is not set +# CONFIG_TI_ADC081C is not set +# CONFIG_TI_ADC0832 is not set +# CONFIG_TI_ADC12138 is not set +# CONFIG_TI_ADC128S052 is not set +# CONFIG_TI_ADC161S626 is not set +# CONFIG_TI_ADS1015 is not set + +# +# Amplifiers +# +# CONFIG_AD8366 is not set + +# +# Chemical Sensors +# +# CONFIG_ATLAS_PH_SENSOR is not set +# CONFIG_IAQCORE is not set +# CONFIG_VZ89X is not set + +# +# Hid Sensor IIO Common +# + +# +# SSP Sensor Common +# +# CONFIG_IIO_SSP_SENSORHUB is not set + +# +# Digital to analog converters +# +# CONFIG_AD5064 is not set +# CONFIG_AD5360 is not set +# CONFIG_AD5380 is not set +# CONFIG_AD5421 is not set +# CONFIG_AD5446 is not set +# CONFIG_AD5449 is not set +# CONFIG_AD5592R is not set +# CONFIG_AD5593R is not set +# CONFIG_AD5504 is not set +# CONFIG_AD5624R_SPI is not set +# CONFIG_AD5686 is not set +# CONFIG_AD5755 is not set +# CONFIG_AD5761 is not set +# CONFIG_AD5764 is not set +# CONFIG_AD5791 is not set +# CONFIG_AD7303 is not set +# CONFIG_AD8801 is not set +# CONFIG_M62332 is not set +# CONFIG_MAX517 is not set +# CONFIG_MCP4725 is not set +# CONFIG_MCP4922 is not set + +# +# IIO dummy driver +# + +# +# Frequency Synthesizers DDS/PLL +# + +# +# Clock Generator/Distribution +# +# CONFIG_AD9523 is not set + +# +# Phase-Locked Loop (PLL) frequency synthesizers +# +# CONFIG_ADF4350 is not set + +# +# Digital gyroscope sensors +# +# CONFIG_ADIS16080 is not set +# CONFIG_ADIS16130 is not set +# CONFIG_ADIS16136 is not set +# CONFIG_ADIS16260 is not set +# CONFIG_ADXRS450 is not set +# CONFIG_BMG160 is not set +# CONFIG_IIO_ST_GYRO_3AXIS is not set +# CONFIG_ITG3200 is not set + +# +# Health Sensors +# + +# +# Heart Rate Monitors +# +# CONFIG_AFE4403 is not set +# CONFIG_AFE4404 is not set +# CONFIG_MAX30100 is not set + +# +# Humidity sensors +# +# CONFIG_AM2315 is not set +# CONFIG_HDC100X is not set +# CONFIG_HTU21 is not set +# CONFIG_SI7005 is not set +# CONFIG_SI7020 is not set + +# +# Inertial measurement units +# +# CONFIG_ADIS16400 is not set +# CONFIG_ADIS16480 is not set +# CONFIG_BMI160_I2C is not set +# CONFIG_BMI160_SPI is not set +# CONFIG_KMX61 is not set +# CONFIG_INV_MPU6050_I2C is not set +# CONFIG_INV_MPU6050_SPI is not set + +# +# Light sensors +# +# CONFIG_ACPI_ALS is not set +# CONFIG_ADJD_S311 is not set +# CONFIG_AL3320A is not set +# CONFIG_APDS9300 is not set +# CONFIG_APDS9960 is not set +# CONFIG_BH1750 is not set +# CONFIG_BH1780 is not set +# CONFIG_CM32181 is not set +# CONFIG_CM3232 is not set +# CONFIG_CM3323 is not set +# CONFIG_CM36651 is not set +# CONFIG_GP2AP020A00F is not set +# CONFIG_ISL29125 is not set +# CONFIG_JSA1212 is not set +# CONFIG_RPR0521 is not set +# CONFIG_LTR501 is not set +# CONFIG_MAX44000 is not set +# CONFIG_OPT3001 is not set +# CONFIG_PA12203001 is not set +# CONFIG_SI1145 is not set +# CONFIG_STK3310 is not set +# CONFIG_TCS3414 is not set +# CONFIG_TCS3472 is not set +# CONFIG_SENSORS_TSL2563 is not set +# CONFIG_TSL4531 is not set +# CONFIG_US5182D is not set +# CONFIG_VCNL4000 is not set +# CONFIG_VEML6070 is not set + +# +# Magnetometer sensors +# +# CONFIG_BMC150_MAGN_I2C is not set +# CONFIG_BMC150_MAGN_SPI is not set +# CONFIG_MAG3110 is not set +# CONFIG_MMC35240 is not set +# CONFIG_IIO_ST_MAGN_3AXIS is not set +# CONFIG_SENSORS_HMC5843_I2C is not set +# CONFIG_SENSORS_HMC5843_SPI is not set + +# +# Inclinometer sensors +# + +# +# Triggers - standalone +# +# CONFIG_IIO_INTERRUPT_TRIGGER is not set +# CONFIG_IIO_SYSFS_TRIGGER is not set + +# +# Digital potentiometers +# +# CONFIG_DS1803 is not set +# CONFIG_MAX5487 is not set +# CONFIG_MCP4131 is not set +# CONFIG_MCP4531 is not set +# CONFIG_TPL0102 is not set + +# +# Pressure sensors +# +# CONFIG_BMP280 is not set +# CONFIG_HP03 is not set +# CONFIG_MPL115_I2C is not set +# CONFIG_MPL115_SPI is not set +# CONFIG_MPL3115 is not set +# CONFIG_MS5611 is not set +# CONFIG_MS5637 is not set +# CONFIG_IIO_ST_PRESS is not set +# CONFIG_T5403 is not set +# CONFIG_HP206C is not set +# CONFIG_ZPA2326 is not set + +# +# Lightning sensors +# +# CONFIG_AS3935 is not set + +# +# Proximity sensors +# +# CONFIG_LIDAR_LITE_V2 is not set +# CONFIG_SX9500 is not set + +# +# Temperature sensors +# +# CONFIG_MAXIM_THERMOCOUPLE is not set +# CONFIG_MLX90614 is not set +# CONFIG_TMP006 is not set +# CONFIG_TSYS01 is not set +# CONFIG_TSYS02D is not set # CONFIG_NTB is not set # CONFIG_VME_BUS is not set # CONFIG_PWM is not set @@ -3375,7 +3745,7 @@ CONFIG_RAS=y # # CONFIG_ANDROID is not set # CONFIG_LIBNVDIMM is not set -# CONFIG_NVMEM is not set +CONFIG_NVMEM=m # CONFIG_STM is not set # CONFIG_INTEL_TH is not set diff --git a/packages/base/any/kernels/4.9-lts/patches/0001-i2c-mlxcpld-add-master-driver-for-Mellanox-systems.patch b/packages/base/any/kernels/4.9-lts/patches/0001-i2c-mlxcpld-add-master-driver-for-Mellanox-systems.patch new file mode 100644 index 00000000..54431bcc --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0001-i2c-mlxcpld-add-master-driver-for-Mellanox-systems.patch @@ -0,0 +1,544 @@ +Linux backport patch. Includes following commits: +899e11216e1c215b97f2f8f92c7b010a4e88f38e + + +diff -Nur a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig +--- a/drivers/i2c/busses/Kconfig 2017-11-12 08:08:32.136039784 +0000 ++++ b/drivers/i2c/busses/Kconfig 2017-11-12 08:08:40.776039899 +0000 +@@ -1150,6 +1150,17 @@ + This support is also available as a module. If so, the module + will be called i2c-elektor. + ++config I2C_MLXCPLD ++ tristate "Mellanox I2C driver" ++ depends on X86_64 ++ help ++ This exposes the Mellanox platform I2C busses to the linux I2C layer ++ for X86 based systems. ++ Controller is implemented as CPLD logic. ++ ++ This driver can also be built as a module. If so, the module will be ++ called as i2c-mlxcpld. ++ + config I2C_PCA_ISA + tristate "PCA9564/PCA9665 on an ISA bus" + depends on ISA +diff -Nur a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile +--- a/drivers/i2c/busses/Makefile 2017-11-12 08:08:32.140039784 +0000 ++++ b/drivers/i2c/busses/Makefile 2017-11-12 08:08:40.780039899 +0000 +@@ -116,6 +116,7 @@ + obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o + obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o + obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o ++obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o + obj-$(CONFIG_I2C_OPAL) += i2c-opal.o + obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o + obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o +diff -Nur a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c +--- a/drivers/i2c/busses/i2c-mlxcpld.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/i2c/busses/i2c-mlxcpld.c 2017-11-12 08:08:40.780039899 +0000 +@@ -0,0 +1,504 @@ ++/* ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Michael Shych ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* General defines */ ++#define MLXPLAT_CPLD_LPC_I2C_BASE_ADDR 0x2000 ++#define MLXCPLD_I2C_DEVICE_NAME "i2c_mlxcpld" ++#define MLXCPLD_I2C_VALID_FLAG (I2C_M_RECV_LEN | I2C_M_RD) ++#define MLXCPLD_I2C_BUS_NUM 1 ++#define MLXCPLD_I2C_DATA_REG_SZ 36 ++#define MLXCPLD_I2C_MAX_ADDR_LEN 4 ++#define MLXCPLD_I2C_RETR_NUM 2 ++#define MLXCPLD_I2C_XFER_TO 500000 /* usec */ ++#define MLXCPLD_I2C_POLL_TIME 2000 /* usec */ ++ ++/* LPC I2C registers */ ++#define MLXCPLD_LPCI2C_LPF_REG 0x0 ++#define MLXCPLD_LPCI2C_CTRL_REG 0x1 ++#define MLXCPLD_LPCI2C_HALF_CYC_REG 0x4 ++#define MLXCPLD_LPCI2C_I2C_HOLD_REG 0x5 ++#define MLXCPLD_LPCI2C_CMD_REG 0x6 ++#define MLXCPLD_LPCI2C_NUM_DAT_REG 0x7 ++#define MLXCPLD_LPCI2C_NUM_ADDR_REG 0x8 ++#define MLXCPLD_LPCI2C_STATUS_REG 0x9 ++#define MLXCPLD_LPCI2C_DATA_REG 0xa ++ ++/* LPC I2C masks and parametres */ ++#define MLXCPLD_LPCI2C_RST_SEL_MASK 0x1 ++#define MLXCPLD_LPCI2C_TRANS_END 0x1 ++#define MLXCPLD_LPCI2C_STATUS_NACK 0x10 ++#define MLXCPLD_LPCI2C_NO_IND 0 ++#define MLXCPLD_LPCI2C_ACK_IND 1 ++#define MLXCPLD_LPCI2C_NACK_IND 2 ++ ++struct mlxcpld_i2c_curr_xfer { ++ u8 cmd; ++ u8 addr_width; ++ u8 data_len; ++ u8 msg_num; ++ struct i2c_msg *msg; ++}; ++ ++struct mlxcpld_i2c_priv { ++ struct i2c_adapter adap; ++ u32 base_addr; ++ struct mutex lock; ++ struct mlxcpld_i2c_curr_xfer xfer; ++ struct device *dev; ++}; ++ ++static void mlxcpld_i2c_lpc_write_buf(u8 *data, u8 len, u32 addr) ++{ ++ int i; ++ ++ for (i = 0; i < len - len % 4; i += 4) ++ outl(*(u32 *)(data + i), addr + i); ++ for (; i < len; ++i) ++ outb(*(data + i), addr + i); ++} ++ ++static void mlxcpld_i2c_lpc_read_buf(u8 *data, u8 len, u32 addr) ++{ ++ int i; ++ ++ for (i = 0; i < len - len % 4; i += 4) ++ *(u32 *)(data + i) = inl(addr + i); ++ for (; i < len; ++i) ++ *(data + i) = inb(addr + i); ++} ++ ++static void mlxcpld_i2c_read_comm(struct mlxcpld_i2c_priv *priv, u8 offs, ++ u8 *data, u8 datalen) ++{ ++ u32 addr = priv->base_addr + offs; ++ ++ switch (datalen) { ++ case 1: ++ *(data) = inb(addr); ++ break; ++ case 2: ++ *((u16 *)data) = inw(addr); ++ break; ++ case 3: ++ *((u16 *)data) = inw(addr); ++ *(data + 2) = inb(addr + 2); ++ break; ++ case 4: ++ *((u32 *)data) = inl(addr); ++ break; ++ default: ++ mlxcpld_i2c_lpc_read_buf(data, datalen, addr); ++ break; ++ } ++} ++ ++static void mlxcpld_i2c_write_comm(struct mlxcpld_i2c_priv *priv, u8 offs, ++ u8 *data, u8 datalen) ++{ ++ u32 addr = priv->base_addr + offs; ++ ++ switch (datalen) { ++ case 1: ++ outb(*(data), addr); ++ break; ++ case 2: ++ outw(*((u16 *)data), addr); ++ break; ++ case 3: ++ outw(*((u16 *)data), addr); ++ outb(*(data + 2), addr + 2); ++ break; ++ case 4: ++ outl(*((u32 *)data), addr); ++ break; ++ default: ++ mlxcpld_i2c_lpc_write_buf(data, datalen, addr); ++ break; ++ } ++} ++ ++/* ++ * Check validity of received i2c messages parameters. ++ * Returns 0 if OK, other - in case of invalid parameters. ++ */ ++static int mlxcpld_i2c_check_msg_params(struct mlxcpld_i2c_priv *priv, ++ struct i2c_msg *msgs, int num) ++{ ++ int i; ++ ++ if (!num) { ++ dev_err(priv->dev, "Incorrect 0 num of messages\n"); ++ return -EINVAL; ++ } ++ ++ if (unlikely(msgs[0].addr > 0x7f)) { ++ dev_err(priv->dev, "Invalid address 0x%03x\n", ++ msgs[0].addr); ++ return -EINVAL; ++ } ++ ++ for (i = 0; i < num; ++i) { ++ if (unlikely(!msgs[i].buf)) { ++ dev_err(priv->dev, "Invalid buf in msg[%d]\n", ++ i); ++ return -EINVAL; ++ } ++ if (unlikely(msgs[0].addr != msgs[i].addr)) { ++ dev_err(priv->dev, "Invalid addr in msg[%d]\n", ++ i); ++ return -EINVAL; ++ } ++ } ++ ++ return 0; ++} ++ ++/* ++ * Check if transfer is completed and status of operation. ++ * Returns 0 - transfer completed (both ACK or NACK), ++ * negative - transfer isn't finished. ++ */ ++static int mlxcpld_i2c_check_status(struct mlxcpld_i2c_priv *priv, int *status) ++{ ++ u8 val; ++ ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_STATUS_REG, &val, 1); ++ ++ if (val & MLXCPLD_LPCI2C_TRANS_END) { ++ if (val & MLXCPLD_LPCI2C_STATUS_NACK) ++ /* ++ * The slave is unable to accept the data. No such ++ * slave, command not understood, or unable to accept ++ * any more data. ++ */ ++ *status = MLXCPLD_LPCI2C_NACK_IND; ++ else ++ *status = MLXCPLD_LPCI2C_ACK_IND; ++ return 0; ++ } ++ *status = MLXCPLD_LPCI2C_NO_IND; ++ ++ return -EIO; ++} ++ ++static void mlxcpld_i2c_set_transf_data(struct mlxcpld_i2c_priv *priv, ++ struct i2c_msg *msgs, int num, ++ u8 comm_len) ++{ ++ priv->xfer.msg = msgs; ++ priv->xfer.msg_num = num; ++ ++ /* ++ * All upper layers currently are never use transfer with more than ++ * 2 messages. Actually, it's also not so relevant in Mellanox systems ++ * because of HW limitation. Max size of transfer is not more than 32 ++ * bytes in the current x86 LPCI2C bridge. ++ */ ++ priv->xfer.cmd = msgs[num - 1].flags & I2C_M_RD; ++ ++ if (priv->xfer.cmd == I2C_M_RD && comm_len != msgs[0].len) { ++ priv->xfer.addr_width = msgs[0].len; ++ priv->xfer.data_len = comm_len - priv->xfer.addr_width; ++ } else { ++ priv->xfer.addr_width = 0; ++ priv->xfer.data_len = comm_len; ++ } ++} ++ ++/* Reset CPLD LPCI2C block */ ++static void mlxcpld_i2c_reset(struct mlxcpld_i2c_priv *priv) ++{ ++ u8 val; ++ ++ mutex_lock(&priv->lock); ++ ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_CTRL_REG, &val, 1); ++ val &= ~MLXCPLD_LPCI2C_RST_SEL_MASK; ++ mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_CTRL_REG, &val, 1); ++ ++ mutex_unlock(&priv->lock); ++} ++ ++/* Make sure the CPLD is ready to start transmitting. */ ++static int mlxcpld_i2c_check_busy(struct mlxcpld_i2c_priv *priv) ++{ ++ u8 val; ++ ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_STATUS_REG, &val, 1); ++ ++ if (val & MLXCPLD_LPCI2C_TRANS_END) ++ return 0; ++ ++ return -EIO; ++} ++ ++static int mlxcpld_i2c_wait_for_free(struct mlxcpld_i2c_priv *priv) ++{ ++ int timeout = 0; ++ ++ do { ++ if (!mlxcpld_i2c_check_busy(priv)) ++ break; ++ usleep_range(MLXCPLD_I2C_POLL_TIME / 2, MLXCPLD_I2C_POLL_TIME); ++ timeout += MLXCPLD_I2C_POLL_TIME; ++ } while (timeout <= MLXCPLD_I2C_XFER_TO); ++ ++ if (timeout > MLXCPLD_I2C_XFER_TO) ++ return -ETIMEDOUT; ++ ++ return 0; ++} ++ ++/* ++ * Wait for master transfer to complete. ++ * It puts current process to sleep until we get interrupt or timeout expires. ++ * Returns the number of transferred or read bytes or error (<0). ++ */ ++static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv) ++{ ++ int status, i, timeout = 0; ++ u8 datalen; ++ ++ do { ++ usleep_range(MLXCPLD_I2C_POLL_TIME / 2, MLXCPLD_I2C_POLL_TIME); ++ if (!mlxcpld_i2c_check_status(priv, &status)) ++ break; ++ timeout += MLXCPLD_I2C_POLL_TIME; ++ } while (status == 0 && timeout < MLXCPLD_I2C_XFER_TO); ++ ++ switch (status) { ++ case MLXCPLD_LPCI2C_NO_IND: ++ return -ETIMEDOUT; ++ ++ case MLXCPLD_LPCI2C_ACK_IND: ++ if (priv->xfer.cmd != I2C_M_RD) ++ return (priv->xfer.addr_width + priv->xfer.data_len); ++ ++ if (priv->xfer.msg_num == 1) ++ i = 0; ++ else ++ i = 1; ++ ++ if (!priv->xfer.msg[i].buf) ++ return -EINVAL; ++ ++ /* ++ * Actual read data len will be always the same as ++ * requested len. 0xff (line pull-up) will be returned ++ * if slave has no data to return. Thus don't read ++ * MLXCPLD_LPCI2C_NUM_DAT_REG reg from CPLD. ++ */ ++ datalen = priv->xfer.data_len; ++ ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_DATA_REG, ++ priv->xfer.msg[i].buf, datalen); ++ ++ return datalen; ++ ++ case MLXCPLD_LPCI2C_NACK_IND: ++ return -ENXIO; ++ ++ default: ++ return -EINVAL; ++ } ++} ++ ++static void mlxcpld_i2c_xfer_msg(struct mlxcpld_i2c_priv *priv) ++{ ++ int i, len = 0; ++ u8 cmd; ++ ++ mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG, ++ &priv->xfer.data_len, 1); ++ mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG, ++ &priv->xfer.addr_width, 1); ++ ++ for (i = 0; i < priv->xfer.msg_num; i++) { ++ if ((priv->xfer.msg[i].flags & I2C_M_RD) != I2C_M_RD) { ++ /* Don't write to CPLD buffer in read transaction */ ++ mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_DATA_REG + ++ len, priv->xfer.msg[i].buf, ++ priv->xfer.msg[i].len); ++ len += priv->xfer.msg[i].len; ++ } ++ } ++ ++ /* ++ * Set target slave address with command for master transfer. ++ * It should be latest executed function before CPLD transaction. ++ */ ++ cmd = (priv->xfer.msg[0].addr << 1) | priv->xfer.cmd; ++ mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_CMD_REG, &cmd, 1); ++} ++ ++/* ++ * Generic lpc-i2c transfer. ++ * Returns the number of processed messages or error (<0). ++ */ ++static int mlxcpld_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, ++ int num) ++{ ++ struct mlxcpld_i2c_priv *priv = i2c_get_adapdata(adap); ++ u8 comm_len = 0; ++ int i, err; ++ ++ err = mlxcpld_i2c_check_msg_params(priv, msgs, num); ++ if (err) { ++ dev_err(priv->dev, "Incorrect message\n"); ++ return err; ++ } ++ ++ for (i = 0; i < num; ++i) ++ comm_len += msgs[i].len; ++ ++ /* Check bus state */ ++ if (mlxcpld_i2c_wait_for_free(priv)) { ++ dev_err(priv->dev, "LPCI2C bridge is busy\n"); ++ ++ /* ++ * Usually it means something serious has happened. ++ * We can not have unfinished previous transfer ++ * so it doesn't make any sense to try to stop it. ++ * Probably we were not able to recover from the ++ * previous error. ++ * The only reasonable thing - is soft reset. ++ */ ++ mlxcpld_i2c_reset(priv); ++ if (mlxcpld_i2c_check_busy(priv)) { ++ dev_err(priv->dev, "LPCI2C bridge is busy after reset\n"); ++ return -EIO; ++ } ++ } ++ ++ mlxcpld_i2c_set_transf_data(priv, msgs, num, comm_len); ++ ++ mutex_lock(&priv->lock); ++ ++ /* Do real transfer. Can't fail */ ++ mlxcpld_i2c_xfer_msg(priv); ++ ++ /* Wait for transaction complete */ ++ err = mlxcpld_i2c_wait_for_tc(priv); ++ ++ mutex_unlock(&priv->lock); ++ ++ return err < 0 ? err : num; ++} ++ ++static u32 mlxcpld_i2c_func(struct i2c_adapter *adap) ++{ ++ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; ++} ++ ++static const struct i2c_algorithm mlxcpld_i2c_algo = { ++ .master_xfer = mlxcpld_i2c_xfer, ++ .functionality = mlxcpld_i2c_func ++}; ++ ++static struct i2c_adapter_quirks mlxcpld_i2c_quirks = { ++ .flags = I2C_AQ_COMB_WRITE_THEN_READ, ++ .max_read_len = MLXCPLD_I2C_DATA_REG_SZ - MLXCPLD_I2C_MAX_ADDR_LEN, ++ .max_write_len = MLXCPLD_I2C_DATA_REG_SZ, ++ .max_comb_1st_msg_len = 4, ++}; ++ ++static struct i2c_adapter mlxcpld_i2c_adapter = { ++ .owner = THIS_MODULE, ++ .name = "i2c-mlxcpld", ++ .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, ++ .algo = &mlxcpld_i2c_algo, ++ .quirks = &mlxcpld_i2c_quirks, ++ .retries = MLXCPLD_I2C_RETR_NUM, ++ .nr = MLXCPLD_I2C_BUS_NUM, ++}; ++ ++static int mlxcpld_i2c_probe(struct platform_device *pdev) ++{ ++ struct mlxcpld_i2c_priv *priv; ++ int err; ++ ++ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ mutex_init(&priv->lock); ++ platform_set_drvdata(pdev, priv); ++ ++ priv->dev = &pdev->dev; ++ ++ /* Register with i2c layer */ ++ mlxcpld_i2c_adapter.timeout = usecs_to_jiffies(MLXCPLD_I2C_XFER_TO); ++ priv->adap = mlxcpld_i2c_adapter; ++ priv->adap.dev.parent = &pdev->dev; ++ priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR; ++ i2c_set_adapdata(&priv->adap, priv); ++ ++ err = i2c_add_numbered_adapter(&priv->adap); ++ if (err) ++ mutex_destroy(&priv->lock); ++ ++ return err; ++} ++ ++static int mlxcpld_i2c_remove(struct platform_device *pdev) ++{ ++ struct mlxcpld_i2c_priv *priv = platform_get_drvdata(pdev); ++ ++ i2c_del_adapter(&priv->adap); ++ mutex_destroy(&priv->lock); ++ ++ return 0; ++} ++ ++static struct platform_driver mlxcpld_i2c_driver = { ++ .probe = mlxcpld_i2c_probe, ++ .remove = mlxcpld_i2c_remove, ++ .driver = { ++ .name = MLXCPLD_I2C_DEVICE_NAME, ++ }, ++}; ++ ++module_platform_driver(mlxcpld_i2c_driver); ++ ++MODULE_AUTHOR("Michael Shych "); ++MODULE_DESCRIPTION("Mellanox I2C-CPLD controller driver"); ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_ALIAS("platform:i2c-mlxcpld"); diff --git a/packages/base/any/kernels/4.9-lts/patches/0002-i2c-mux-mlxcpld-add-driver-for-Mellanox-systems.patch b/packages/base/any/kernels/4.9-lts/patches/0002-i2c-mux-mlxcpld-add-driver-for-Mellanox-systems.patch new file mode 100644 index 00000000..4ce71385 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0002-i2c-mux-mlxcpld-add-driver-for-Mellanox-systems.patch @@ -0,0 +1,317 @@ +Linux backport patch. Includes following commits: +e3448e71adb1fdd7f403c568ef5c2ed5adf2b197 +c3bb77620da428884807fb2f6f3485644e146f84 +db5f807ee3dcc779b78f59982cc3e89863069e9c + + +diff -Nur a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig +--- a/drivers/i2c/muxes/Kconfig 2017-11-12 08:13:59.176044126 +0000 ++++ b/drivers/i2c/muxes/Kconfig 2017-11-12 08:14:27.992044509 +0000 +@@ -82,4 +82,15 @@ + demultiplexer that uses the pinctrl subsystem. This is useful if you + want to change the I2C master at run-time depending on features. + ++config I2C_MUX_MLXCPLD ++ tristate "Mellanox CPLD based I2C multiplexer" ++ help ++ If you say yes to this option, support will be included for a ++ CPLD based I2C multiplexer. This driver provides access to ++ I2C busses connected through a MUX, which is controlled ++ by a CPLD register. ++ ++ This driver can also be built as a module. If so, the module ++ will be called i2c-mux-mlxcpld. ++ + endmenu +diff -Nur a/drivers/i2c/muxes/Makefile b/drivers/i2c/muxes/Makefile +--- a/drivers/i2c/muxes/Makefile 2017-11-12 08:13:59.176044126 +0000 ++++ b/drivers/i2c/muxes/Makefile 2017-11-12 08:14:27.992044509 +0000 +@@ -6,6 +6,7 @@ + obj-$(CONFIG_I2C_DEMUX_PINCTRL) += i2c-demux-pinctrl.o + + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o ++obj-$(CONFIG_I2C_MUX_MLXCPLD) += i2c-mux-mlxcpld.o + obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o + obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o + obj-$(CONFIG_I2C_MUX_PINCTRL) += i2c-mux-pinctrl.o +diff -Nur a/drivers/i2c/muxes/i2c-mux-mlxcpld.c b/drivers/i2c/muxes/i2c-mux-mlxcpld.c +--- a/drivers/i2c/muxes/i2c-mux-mlxcpld.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/i2c/muxes/i2c-mux-mlxcpld.c 2017-11-12 08:14:27.992044509 +0000 +@@ -0,0 +1,221 @@ ++/* ++ * drivers/i2c/muxes/i2c-mux-mlxcpld.c ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Michael Shych ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define CPLD_MUX_MAX_NCHANS 8 ++ ++/* mlxcpld_mux - mux control structure: ++ * @last_chan - last register value ++ * @client - I2C device client ++ */ ++struct mlxcpld_mux { ++ u8 last_chan; ++ struct i2c_client *client; ++}; ++ ++/* MUX logic description. ++ * Driver can support different mux control logic, according to CPLD ++ * implementation. ++ * ++ * Connectivity schema. ++ * ++ * i2c-mlxcpld Digital Analog ++ * driver ++ * *--------* * -> mux1 (virt bus2) -> mux -> | ++ * | I2CLPC | i2c physical * -> mux2 (virt bus3) -> mux -> | ++ * | bridge | bus 1 *---------* | ++ * | logic |---------------------> * mux reg * | ++ * | in CPLD| *---------* | ++ * *--------* i2c-mux-mlxpcld ^ * -> muxn (virt busn) -> mux -> | ++ * | driver | | ++ * | *---------------* | Devices ++ * | * CPLD (i2c bus)* select | ++ * | * registers for *--------* ++ * | * mux selection * deselect ++ * | *---------------* ++ * | | ++ * <--------> <-----------> ++ * i2c cntrl Board cntrl reg ++ * reg space space (mux select, ++ * IO, LED, WD, info) ++ * ++ */ ++ ++static const struct i2c_device_id mlxcpld_mux_id[] = { ++ { "mlxcpld_mux_module", 0 }, ++ { } ++}; ++MODULE_DEVICE_TABLE(i2c, mlxcpld_mux_id); ++ ++/* Write to mux register. Don't use i2c_transfer() and i2c_smbus_xfer() ++ * for this as they will try to lock adapter a second time. ++ */ ++static int mlxcpld_mux_reg_write(struct i2c_adapter *adap, ++ struct i2c_client *client, u8 val) ++{ ++ struct mlxcpld_mux_plat_data *pdata = dev_get_platdata(&client->dev); ++ int ret = -ENODEV; ++ ++ if (adap->algo->master_xfer) { ++ struct i2c_msg msg; ++ u8 msgbuf[] = {pdata->sel_reg_addr, val}; ++ ++ msg.addr = client->addr; ++ msg.flags = 0; ++ msg.len = 2; ++ msg.buf = msgbuf; ++ ret = __i2c_transfer(adap, &msg, 1); ++ ++ if (ret >= 0 && ret != 1) ++ ret = -EREMOTEIO; ++ } else if (adap->algo->smbus_xfer) { ++ union i2c_smbus_data data; ++ ++ data.byte = val; ++ ret = adap->algo->smbus_xfer(adap, client->addr, ++ client->flags, I2C_SMBUS_WRITE, ++ pdata->sel_reg_addr, ++ I2C_SMBUS_BYTE_DATA, &data); ++ } ++ ++ return ret; ++} ++ ++static int mlxcpld_mux_select_chan(struct i2c_mux_core *muxc, u32 chan) ++{ ++ struct mlxcpld_mux *data = i2c_mux_priv(muxc); ++ struct i2c_client *client = data->client; ++ u8 regval = chan + 1; ++ int err = 0; ++ ++ /* Only select the channel if its different from the last channel */ ++ if (data->last_chan != regval) { ++ err = mlxcpld_mux_reg_write(muxc->parent, client, regval); ++ data->last_chan = err < 0 ? 0 : regval; ++ } ++ ++ return err; ++} ++ ++static int mlxcpld_mux_deselect(struct i2c_mux_core *muxc, u32 chan) ++{ ++ struct mlxcpld_mux *data = i2c_mux_priv(muxc); ++ struct i2c_client *client = data->client; ++ ++ /* Deselect active channel */ ++ data->last_chan = 0; ++ ++ return mlxcpld_mux_reg_write(muxc->parent, client, data->last_chan); ++} ++ ++/* Probe/reomove functions */ ++static int mlxcpld_mux_probe(struct i2c_client *client, ++ const struct i2c_device_id *id) ++{ ++ struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); ++ struct mlxcpld_mux_plat_data *pdata = dev_get_platdata(&client->dev); ++ struct i2c_mux_core *muxc; ++ int num, force; ++ struct mlxcpld_mux *data; ++ int err; ++ ++ if (!pdata) ++ return -EINVAL; ++ ++ if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) ++ return -ENODEV; ++ ++ muxc = i2c_mux_alloc(adap, &client->dev, CPLD_MUX_MAX_NCHANS, ++ sizeof(*data), 0, mlxcpld_mux_select_chan, ++ mlxcpld_mux_deselect); ++ if (!muxc) ++ return -ENOMEM; ++ ++ data = i2c_mux_priv(muxc); ++ i2c_set_clientdata(client, muxc); ++ data->client = client; ++ data->last_chan = 0; /* force the first selection */ ++ ++ /* Create an adapter for each channel. */ ++ for (num = 0; num < CPLD_MUX_MAX_NCHANS; num++) { ++ if (num >= pdata->num_adaps) ++ /* discard unconfigured channels */ ++ break; ++ ++ force = pdata->adap_ids[num]; ++ ++ err = i2c_mux_add_adapter(muxc, force, num, 0); ++ if (err) ++ goto virt_reg_failed; ++ } ++ ++ return 0; ++ ++virt_reg_failed: ++ i2c_mux_del_adapters(muxc); ++ return err; ++} ++ ++static int mlxcpld_mux_remove(struct i2c_client *client) ++{ ++ struct i2c_mux_core *muxc = i2c_get_clientdata(client); ++ ++ i2c_mux_del_adapters(muxc); ++ return 0; ++} ++ ++static struct i2c_driver mlxcpld_mux_driver = { ++ .driver = { ++ .name = "mlxcpld-mux", ++ }, ++ .probe = mlxcpld_mux_probe, ++ .remove = mlxcpld_mux_remove, ++ .id_table = mlxcpld_mux_id, ++}; ++ ++module_i2c_driver(mlxcpld_mux_driver); ++ ++MODULE_AUTHOR("Michael Shych (michaels@mellanox.com)"); ++MODULE_DESCRIPTION("Mellanox I2C-CPLD-MUX driver"); ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_ALIAS("platform:i2c-mux-mlxcpld"); +diff -Nur a/include/linux/i2c/mlxcpld.h b/include/linux/i2c/mlxcpld.h +--- a/include/linux/i2c/mlxcpld.h 1970-01-01 00:00:00.000000000 +0000 ++++ b/include/linux/i2c/mlxcpld.h 2017-11-12 08:17:03.032046568 +0000 +@@ -0,0 +1,52 @@ ++/* ++ * mlxcpld.h - Mellanox I2C multiplexer support in CPLD ++ * ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Michael Shych ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef _LINUX_I2C_MLXCPLD_H ++#define _LINUX_I2C_MLXCPLD_H ++ ++/* Platform data for the CPLD I2C multiplexers */ ++ ++/* mlxcpld_mux_plat_data - per mux data, used with i2c_register_board_info ++ * @adap_ids - adapter array ++ * @num_adaps - number of adapters ++ * @sel_reg_addr - mux select register offset in CPLD space ++ */ ++struct mlxcpld_mux_plat_data { ++ int *adap_ids; ++ int num_adaps; ++ int sel_reg_addr; ++}; ++ ++#endif /* _LINUX_I2C_MLXCPLD_H */ diff --git a/packages/base/any/kernels/4.9-lts/patches/0003-platform-mellanox-Introduce-Mellanox-hardware-platfo.patch b/packages/base/any/kernels/4.9-lts/patches/0003-platform-mellanox-Introduce-Mellanox-hardware-platfo.patch new file mode 100644 index 00000000..a2b6a9f4 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0003-platform-mellanox-Introduce-Mellanox-hardware-platfo.patch @@ -0,0 +1,1463 @@ +Linux backport patch. Includes following commits: +2926024b5081fc8d4b086677bafa1ac55ea0b911 +eab85698a91e0191e1a00b547ebded411dd9061c +91973760712f350048a0fa8e0363e260bf874313 +ae4c6f185a791890dcf9cab7bc7764ba44e2e696 +90fcad9b077a4660896dbdc815509cee3440886b +290e505b287fe664549cb72b26507d8ffb4a6d39 +d53bc5dc941653f0ed93b11a647bd6ff40f40ef2 +daf155fe70c9d69c28bba632b6a758ac8feab6e7 +c7c1fe5b608cd11668834761404f9d03bf616bdd + + +diff -Nur a/arch/x86/Kconfig b/arch/x86/Kconfig +--- a/arch/x86/Kconfig 2017-11-12 10:26:01.808149323 +0000 ++++ b/arch/x86/Kconfig 2017-11-12 10:27:38.576150608 +0000 +@@ -550,18 +550,6 @@ + Say Y here if you have a Quark based system such as the Arduino + compatible Intel Galileo. + +-config MLX_PLATFORM +- tristate "Mellanox Technologies platform support" +- depends on X86_64 +- depends on X86_EXTENDED_PLATFORM +- ---help--- +- This option enables system support for the Mellanox Technologies +- platform. +- +- Say Y here if you are building a kernel for Mellanox system. +- +- Otherwise, say N. +- + config X86_INTEL_LPSS + bool "Intel Low Power Subsystem Support" + depends on X86 && ACPI +diff -Nur a/arch/x86/platform/Makefile b/arch/x86/platform/Makefile +--- a/arch/x86/platform/Makefile 2017-11-12 10:25:48.640149148 +0000 ++++ b/arch/x86/platform/Makefile 2017-11-12 10:27:24.924150426 +0000 +@@ -8,7 +8,6 @@ + obj-y += intel/ + obj-y += intel-mid/ + obj-y += intel-quark/ +-obj-y += mellanox/ + obj-y += olpc/ + obj-y += scx200/ + obj-y += sfi/ +diff -Nur a/arch/x86/platform/mellanox/Makefile b/arch/x86/platform/mellanox/Makefile +--- a/arch/x86/platform/mellanox/Makefile 2017-11-12 10:25:26.704148857 +0000 ++++ b/arch/x86/platform/mellanox/Makefile 1970-01-01 00:00:00.000000000 +0000 +@@ -1 +0,0 @@ +-obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o +diff -Nur a/arch/x86/platform/mellanox/mlx-platform.c b/arch/x86/platform/mellanox/mlx-platform.c +--- a/arch/x86/platform/mellanox/mlx-platform.c 2017-11-12 10:25:26.704148857 +0000 ++++ b/arch/x86/platform/mellanox/mlx-platform.c 1970-01-01 00:00:00.000000000 +0000 +@@ -1,266 +0,0 @@ +-/* +- * arch/x86/platform/mellanox/mlx-platform.c +- * Copyright (c) 2016 Mellanox Technologies. All rights reserved. +- * Copyright (c) 2016 Vadim Pasternak +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * 3. Neither the names of the copyright holders nor the names of its +- * contributors may be used to endorse or promote products derived from +- * this software without specific prior written permission. +- * +- * Alternatively, this software may be distributed under the terms of the +- * GNU General Public License ("GPL") version 2 as published by the Free +- * Software Foundation. +- * +- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +- * POSSIBILITY OF SUCH DAMAGE. +- */ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#define MLX_PLAT_DEVICE_NAME "mlxplat" +- +-/* LPC bus IO offsets */ +-#define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR 0x2000 +-#define MLXPLAT_CPLD_LPC_REG_BASE_ADRR 0x2500 +-#define MLXPLAT_CPLD_LPC_IO_RANGE 0x100 +-#define MLXPLAT_CPLD_LPC_I2C_CH1_OFF 0xdb +-#define MLXPLAT_CPLD_LPC_I2C_CH2_OFF 0xda +-#define MLXPLAT_CPLD_LPC_PIO_OFFSET 0x10000UL +-#define MLXPLAT_CPLD_LPC_REG1 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \ +- MLXPLAT_CPLD_LPC_I2C_CH1_OFF) | \ +- MLXPLAT_CPLD_LPC_PIO_OFFSET) +-#define MLXPLAT_CPLD_LPC_REG2 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \ +- MLXPLAT_CPLD_LPC_I2C_CH2_OFF) | \ +- MLXPLAT_CPLD_LPC_PIO_OFFSET) +- +-/* Start channel numbers */ +-#define MLXPLAT_CPLD_CH1 2 +-#define MLXPLAT_CPLD_CH2 10 +- +-/* Number of LPC attached MUX platform devices */ +-#define MLXPLAT_CPLD_LPC_MUX_DEVS 2 +- +-/* mlxplat_priv - platform private data +- * @pdev_i2c - i2c controller platform device +- * @pdev_mux - array of mux platform devices +- */ +-struct mlxplat_priv { +- struct platform_device *pdev_i2c; +- struct platform_device *pdev_mux[MLXPLAT_CPLD_LPC_MUX_DEVS]; +-}; +- +-/* Regions for LPC I2C controller and LPC base register space */ +-static const struct resource mlxplat_lpc_resources[] = { +- [0] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_I2C_BASE_ADRR, +- MLXPLAT_CPLD_LPC_IO_RANGE, +- "mlxplat_cpld_lpc_i2c_ctrl", IORESOURCE_IO), +- [1] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_REG_BASE_ADRR, +- MLXPLAT_CPLD_LPC_IO_RANGE, +- "mlxplat_cpld_lpc_regs", +- IORESOURCE_IO), +-}; +- +-/* Platform default channels */ +-static const int mlxplat_default_channels[][8] = { +- { +- MLXPLAT_CPLD_CH1, MLXPLAT_CPLD_CH1 + 1, MLXPLAT_CPLD_CH1 + 2, +- MLXPLAT_CPLD_CH1 + 3, MLXPLAT_CPLD_CH1 + 4, MLXPLAT_CPLD_CH1 + +- 5, MLXPLAT_CPLD_CH1 + 6, MLXPLAT_CPLD_CH1 + 7 +- }, +- { +- MLXPLAT_CPLD_CH2, MLXPLAT_CPLD_CH2 + 1, MLXPLAT_CPLD_CH2 + 2, +- MLXPLAT_CPLD_CH2 + 3, MLXPLAT_CPLD_CH2 + 4, MLXPLAT_CPLD_CH2 + +- 5, MLXPLAT_CPLD_CH2 + 6, MLXPLAT_CPLD_CH2 + 7 +- }, +-}; +- +-/* Platform channels for MSN21xx system family */ +-static const int mlxplat_msn21xx_channels[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; +- +-/* Platform mux data */ +-static struct i2c_mux_reg_platform_data mlxplat_mux_data[] = { +- { +- .parent = 1, +- .base_nr = MLXPLAT_CPLD_CH1, +- .write_only = 1, +- .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1, +- .reg_size = 1, +- .idle_in_use = 1, +- }, +- { +- .parent = 1, +- .base_nr = MLXPLAT_CPLD_CH2, +- .write_only = 1, +- .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2, +- .reg_size = 1, +- .idle_in_use = 1, +- }, +- +-}; +- +-static struct platform_device *mlxplat_dev; +- +-static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) +-{ +- int i; +- +- for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { +- mlxplat_mux_data[i].values = mlxplat_default_channels[i]; +- mlxplat_mux_data[i].n_values = +- ARRAY_SIZE(mlxplat_default_channels[i]); +- } +- +- return 1; +-}; +- +-static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) +-{ +- int i; +- +- for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { +- mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; +- mlxplat_mux_data[i].n_values = +- ARRAY_SIZE(mlxplat_msn21xx_channels); +- } +- +- return 1; +-}; +- +-static struct dmi_system_id mlxplat_dmi_table[] __initdata = { +- { +- .callback = mlxplat_dmi_default_matched, +- .matches = { +- DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), +- DMI_MATCH(DMI_PRODUCT_NAME, "MSN24"), +- }, +- }, +- { +- .callback = mlxplat_dmi_default_matched, +- .matches = { +- DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), +- DMI_MATCH(DMI_PRODUCT_NAME, "MSN27"), +- }, +- }, +- { +- .callback = mlxplat_dmi_default_matched, +- .matches = { +- DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), +- DMI_MATCH(DMI_PRODUCT_NAME, "MSB"), +- }, +- }, +- { +- .callback = mlxplat_dmi_default_matched, +- .matches = { +- DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), +- DMI_MATCH(DMI_PRODUCT_NAME, "MSX"), +- }, +- }, +- { +- .callback = mlxplat_dmi_msn21xx_matched, +- .matches = { +- DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), +- DMI_MATCH(DMI_PRODUCT_NAME, "MSN21"), +- }, +- }, +- { } +-}; +- +-static int __init mlxplat_init(void) +-{ +- struct mlxplat_priv *priv; +- int i, err; +- +- if (!dmi_check_system(mlxplat_dmi_table)) +- return -ENODEV; +- +- mlxplat_dev = platform_device_register_simple(MLX_PLAT_DEVICE_NAME, -1, +- mlxplat_lpc_resources, +- ARRAY_SIZE(mlxplat_lpc_resources)); +- +- if (IS_ERR(mlxplat_dev)) +- return PTR_ERR(mlxplat_dev); +- +- priv = devm_kzalloc(&mlxplat_dev->dev, sizeof(struct mlxplat_priv), +- GFP_KERNEL); +- if (!priv) { +- err = -ENOMEM; +- goto fail_alloc; +- } +- platform_set_drvdata(mlxplat_dev, priv); +- +- priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", -1, +- NULL, 0); +- if (IS_ERR(priv->pdev_i2c)) { +- err = PTR_ERR(priv->pdev_i2c); +- goto fail_alloc; +- }; +- +- for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { +- priv->pdev_mux[i] = platform_device_register_resndata( +- &mlxplat_dev->dev, +- "i2c-mux-reg", i, NULL, +- 0, &mlxplat_mux_data[i], +- sizeof(mlxplat_mux_data[i])); +- if (IS_ERR(priv->pdev_mux[i])) { +- err = PTR_ERR(priv->pdev_mux[i]); +- goto fail_platform_mux_register; +- } +- } +- +- return 0; +- +-fail_platform_mux_register: +- while (--i >= 0) +- platform_device_unregister(priv->pdev_mux[i]); +- platform_device_unregister(priv->pdev_i2c); +-fail_alloc: +- platform_device_unregister(mlxplat_dev); +- +- return err; +-} +-module_init(mlxplat_init); +- +-static void __exit mlxplat_exit(void) +-{ +- struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev); +- int i; +- +- for (i = ARRAY_SIZE(mlxplat_mux_data) - 1; i >= 0 ; i--) +- platform_device_unregister(priv->pdev_mux[i]); +- +- platform_device_unregister(priv->pdev_i2c); +- platform_device_unregister(mlxplat_dev); +-} +-module_exit(mlxplat_exit); +- +-MODULE_AUTHOR("Vadim Pasternak (vadimp@mellanox.com)"); +-MODULE_DESCRIPTION("Mellanox platform driver"); +-MODULE_LICENSE("Dual BSD/GPL"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSN24*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSN27*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSB*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSX*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSN21*:"); +diff -Nur a/drivers/platform/Kconfig b/drivers/platform/Kconfig +--- a/drivers/platform/Kconfig 2017-11-12 11:01:23.768177498 +0000 ++++ b/drivers/platform/Kconfig 2017-11-12 11:01:47.784177817 +0000 +@@ -8,3 +8,5 @@ + source "drivers/platform/goldfish/Kconfig" + + source "drivers/platform/chrome/Kconfig" ++ ++source "drivers/platform/mellanox/Kconfig" +diff -Nur a/drivers/platform/Makefile b/drivers/platform/Makefile +--- a/drivers/platform/Makefile 2017-11-12 11:01:23.768177498 +0000 ++++ b/drivers/platform/Makefile 2017-11-12 11:01:47.784177817 +0000 +@@ -3,6 +3,7 @@ + # + + obj-$(CONFIG_X86) += x86/ ++obj-$(CONFIG_MELLANOX_PLATFORM) += mellanox/ + obj-$(CONFIG_MIPS) += mips/ + obj-$(CONFIG_OLPC) += olpc/ + obj-$(CONFIG_GOLDFISH) += goldfish/ +diff -Nur a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig +--- a/drivers/platform/x86/Kconfig 2017-11-12 11:03:10.600178917 +0000 ++++ b/drivers/platform/x86/Kconfig 2017-11-12 11:03:56.776179530 +0000 +@@ -1027,4 +1027,17 @@ + used to get various SoC events and parameters + directly via debugfs files. Various tools may use + this interface for SoC state monitoring. ++ ++config MLX_PLATFORM ++ tristate "Mellanox Technologies platform support" ++ depends on X86_64 ++ ---help--- ++ This option enables system support for the Mellanox Technologies ++ platform. The Mellanox systems provide data center networking ++ solutions based on Virtual Protocol Interconnect (VPI) technology ++ enable seamless connectivity to 56/100Gb/s InfiniBand or 10/40/56GbE ++ connection. ++ ++ If you have a Mellanox system, say Y or M here. ++ + endif # X86_PLATFORM_DEVICES +diff -Nur a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile +--- a/drivers/platform/x86/Makefile 2017-11-12 11:03:10.600178917 +0000 ++++ b/drivers/platform/x86/Makefile 2017-11-12 11:03:56.776179530 +0000 +@@ -71,3 +71,4 @@ + intel_telemetry_pltdrv.o \ + intel_telemetry_debugfs.o + obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o ++obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o +diff -Nur a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +--- a/drivers/platform/x86/mlx-platform.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/platform/x86/mlx-platform.c 2017-11-12 11:03:56.776179530 +0000 +@@ -0,0 +1,1090 @@ ++/* ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MLX_PLAT_DEVICE_NAME "mlxplat" ++ ++/* LPC bus IO offsets */ ++#define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR 0x2000 ++#define MLXPLAT_CPLD_LPC_REG_BASE_ADRR 0x2500 ++#define MLXPLAT_CPLD_LPC_REG_LED1_OFF 0x20 ++#define MLXPLAT_CPLD_LPC_REG_LED2_OFF 0x21 ++#define MLXPLAT_CPLD_LPC_REG_LED3_OFF 0x22 ++#define MLXPLAT_CPLD_LPC_REG_LED4_OFF 0x23 ++#define MLXPLAT_CPLD_LPC_REG_LED5_OFF 0x24 ++#define MLXPLAT_CPLD_LPC_REG_AGGR_OFF 0x3a ++#define MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF 0x40 ++#define MLXPLAT_CPLD_LPC_REG_PSU_OFF 0x58 ++#define MLXPLAT_CPLD_LPC_REG_PWR_OFF 0x64 ++#define MLXPLAT_CPLD_LPC_REG_FAN_OFF 0x88 ++#define MLXPLAT_CPLD_LPC_IO_RANGE 0x100 ++#define MLXPLAT_CPLD_LPC_I2C_CH1_OFF 0xdb ++#define MLXPLAT_CPLD_LPC_I2C_CH2_OFF 0xda ++#define MLXPLAT_CPLD_LPC_PIO_OFFSET 0x10000UL ++#define MLXPLAT_CPLD_LPC_REG1 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \ ++ MLXPLAT_CPLD_LPC_I2C_CH1_OFF) | \ ++ MLXPLAT_CPLD_LPC_PIO_OFFSET) ++#define MLXPLAT_CPLD_LPC_REG2 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \ ++ MLXPLAT_CPLD_LPC_I2C_CH2_OFF) | \ ++ MLXPLAT_CPLD_LPC_PIO_OFFSET) ++ ++/* Masks for aggregation, psu, pwr and fan event in CPLD related registers. */ ++#define MLXPLAT_CPLD_AGGR_PSU_MASK_DEF 0x08 ++#define MLXPLAT_CPLD_AGGR_PWR_MASK_DEF 0x08 ++#define MLXPLAT_CPLD_AGGR_FAN_MASK_DEF 0x40 ++#define MLXPLAT_CPLD_AGGR_MASK_DEF (MLXPLAT_CPLD_AGGR_PSU_MASK_DEF | \ ++ MLXPLAT_CPLD_AGGR_FAN_MASK_DEF) ++#define MLXPLAT_CPLD_AGGR_MASK_NG_DEF 0x04 ++#define MLXPLAT_CPLD_LOW_AGGR_MASK_LOW 0xc0 ++#define MLXPLAT_CPLD_AGGR_MASK_MSN21XX 0x04 ++#define MLXPLAT_CPLD_PSU_MASK GENMASK(1, 0) ++#define MLXPLAT_CPLD_PWR_MASK GENMASK(1, 0) ++#define MLXPLAT_CPLD_FAN_MASK GENMASK(3, 0) ++#define MLXPLAT_CPLD_FAN_NG_MASK GENMASK(5, 0) ++#define MLXPLAT_CPLD_LED_LO_NIBBLE_MASK GENMASK(7, 4) ++#define MLXPLAT_CPLD_LED_HI_NIBBLE_MASK GENMASK(3, 0) ++ ++/* Start channel numbers */ ++#define MLXPLAT_CPLD_CH1 2 ++#define MLXPLAT_CPLD_CH2 10 ++ ++/* Number of LPC attached MUX platform devices */ ++#define MLXPLAT_CPLD_LPC_MUX_DEVS 2 ++ ++/* PSU adapter numbers */ ++#define MLXPLAT_CPLD_PSU_DEFAULT_NR 10 ++#define MLXPLAT_CPLD_PSU_MSNXXXX_NR 4 ++ ++/* mlxplat_priv - platform private data ++ * @pdev_i2c - i2c controller platform device ++ * @pdev_mux - array of mux platform devices ++ * @pdev_hotplug - hotplug platform devices ++ * @pdev_led - led platform devices ++ */ ++struct mlxplat_priv { ++ struct platform_device *pdev_i2c; ++ struct platform_device *pdev_mux[MLXPLAT_CPLD_LPC_MUX_DEVS]; ++ struct platform_device *pdev_hotplug; ++ struct platform_device *pdev_led; ++}; ++ ++/* Regions for LPC I2C controller and LPC base register space */ ++static const struct resource mlxplat_lpc_resources[] = { ++ [0] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_I2C_BASE_ADRR, ++ MLXPLAT_CPLD_LPC_IO_RANGE, ++ "mlxplat_cpld_lpc_i2c_ctrl", IORESOURCE_IO), ++ [1] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_REG_BASE_ADRR, ++ MLXPLAT_CPLD_LPC_IO_RANGE, ++ "mlxplat_cpld_lpc_regs", ++ IORESOURCE_IO), ++}; ++ ++/* Platform default channels */ ++static const int mlxplat_default_channels[][8] = { ++ { ++ MLXPLAT_CPLD_CH1, MLXPLAT_CPLD_CH1 + 1, MLXPLAT_CPLD_CH1 + 2, ++ MLXPLAT_CPLD_CH1 + 3, MLXPLAT_CPLD_CH1 + 4, MLXPLAT_CPLD_CH1 + ++ 5, MLXPLAT_CPLD_CH1 + 6, MLXPLAT_CPLD_CH1 + 7 ++ }, ++ { ++ MLXPLAT_CPLD_CH2, MLXPLAT_CPLD_CH2 + 1, MLXPLAT_CPLD_CH2 + 2, ++ MLXPLAT_CPLD_CH2 + 3, MLXPLAT_CPLD_CH2 + 4, MLXPLAT_CPLD_CH2 + ++ 5, MLXPLAT_CPLD_CH2 + 6, MLXPLAT_CPLD_CH2 + 7 ++ }, ++}; ++ ++/* Platform channels for MSN21xx system family */ ++static const int mlxplat_msn21xx_channels[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; ++ ++/* Platform mux data */ ++static struct i2c_mux_reg_platform_data mlxplat_mux_data[] = { ++ { ++ .parent = 1, ++ .base_nr = MLXPLAT_CPLD_CH1, ++ .write_only = 1, ++ .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1, ++ .reg_size = 1, ++ .idle_in_use = 1, ++ }, ++ { ++ .parent = 1, ++ .base_nr = MLXPLAT_CPLD_CH2, ++ .write_only = 1, ++ .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2, ++ .reg_size = 1, ++ .idle_in_use = 1, ++ }, ++ ++}; ++ ++/* Platform hotplug devices */ ++static struct i2c_board_info mlxplat_mlxcpld_psu[] = { ++ { ++ I2C_BOARD_INFO("24c02", 0x51), ++ }, ++ { ++ I2C_BOARD_INFO("24c02", 0x50), ++ }, ++}; ++ ++static struct i2c_board_info mlxplat_mlxcpld_pwr[] = { ++ { ++ I2C_BOARD_INFO("dps460", 0x59), ++ }, ++ { ++ I2C_BOARD_INFO("dps460", 0x58), ++ }, ++}; ++ ++static struct i2c_board_info mlxplat_mlxcpld_fan[] = { ++ { ++ I2C_BOARD_INFO("24c32", 0x50), ++ }, ++ { ++ I2C_BOARD_INFO("24c32", 0x50), ++ }, ++ { ++ I2C_BOARD_INFO("24c32", 0x50), ++ }, ++ { ++ I2C_BOARD_INFO("24c32", 0x50), ++ }, ++}; ++ ++/* Platform hotplug default data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_psu_items_data[] = { ++ { ++ .label = "psu1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ }, ++ { ++ .label = "psu2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_items_data[] = { ++ { ++ .label = "pwr1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ }, ++ { ++ .label = "pwr2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_items_data[] = { ++ { ++ .label = "fan1", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_fan[0], ++ .hpdev.nr = 11, ++ }, ++ { ++ .label = "fan2", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_fan[1], ++ .hpdev.nr = 12, ++ }, ++ { ++ .label = "fan3", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(2), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_fan[2], ++ .hpdev.nr = 13, ++ }, ++ { ++ .label = "fan4", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(3), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_fan[3], ++ .hpdev.nr = 14, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_default_items[] = { ++ { ++ .data = mlxplat_mlxcpld_default_psu_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_PSU_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = MLXPLAT_CPLD_PSU_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = MLXPLAT_CPLD_PWR_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), ++ .inversed = 0, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_fan_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_FAN_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = MLXPLAT_CPLD_FAN_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_fan), ++ .inversed = 1, ++ .health = false, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_data = { ++ .items = mlxplat_mlxcpld_default_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, ++}; ++ ++/* Platform hotplug MSN21xx system family data */ ++static struct i2c_board_info mlxplat_mlxcpld_msn21xx_pwr[] = { ++ { ++ I2C_BOARD_INFO("holder", 0x59), ++ }, ++ { ++ I2C_BOARD_INFO("holder", 0x58), ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_pwr_items_data[] = { ++ { ++ .label = "pwr1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ }, ++ { ++ .label = "pwr2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_msn21xx_items[] = { ++ { ++ .data = mlxplat_mlxcpld_msn21xx_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = MLXPLAT_CPLD_PWR_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_pwr_items_data), ++ .inversed = 0, ++ .health = false, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { ++ .items = mlxplat_mlxcpld_msn21xx_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, ++}; ++ ++/* Platform hotplug MSN201x system family data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn201x_pwr_items_data[] = { ++ { ++ .label = "pwr1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++ { ++ .label = "pwr2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_msn201x_items[] = { ++ { ++ .data = mlxplat_mlxcpld_msn201x_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = MLXPLAT_CPLD_PWR_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_pwr_items_data), ++ .inversed = 0, ++ .health = false, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn201x_data = { ++ .items = mlxplat_mlxcpld_msn21xx_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, ++}; ++ ++/* Platform hotplug next generation system family data */ ++static struct i2c_board_info mlxplat_mlxcpld_ng_fan = { ++ I2C_BOARD_INFO("holder", 0x50), ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = { ++ { ++ .label = "psu1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++ { ++ .label = "psu2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_pwr_items_data[] = { ++ { ++ .label = "pwr1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++ { ++ .label = "pwr2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_fan_items_data[] = { ++ { ++ .label = "fan1", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 11, ++ }, ++ { ++ .label = "fan2", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 12, ++ }, ++ { ++ .label = "fan3", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(2), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 13, ++ }, ++ { ++ .label = "fan4", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(3), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 14, ++ }, ++ { ++ .label = "fan5", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(3), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 15, ++ }, ++ { ++ .label = "fan6", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(3), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 16, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_default_ng_items[] = { ++ { ++ .data = mlxplat_mlxcpld_default_ng_psu_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = MLXPLAT_CPLD_PSU_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_ng_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = MLXPLAT_CPLD_PWR_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), ++ .inversed = 0, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_ng_fan_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = MLXPLAT_CPLD_FAN_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_ng_data = { ++ .items = mlxplat_mlxcpld_default_ng_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_fan_items_data[] = { ++ { ++ .label = "fan1", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 11, ++ }, ++ { ++ .label = "fan2", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 12, ++ }, ++ { ++ .label = "fan3", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(2), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 13, ++ }, ++ { ++ .label = "fan4", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = BIT(3), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, ++ .hpdev.nr = 14, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_msn274x_items[] = { ++ { ++ .data = mlxplat_mlxcpld_default_ng_psu_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .mask = MLXPLAT_CPLD_PSU_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), ++ .inversed = 1, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_ng_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .mask = MLXPLAT_CPLD_PWR_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), ++ .inversed = 0, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_msn274x_fan_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .mask = MLXPLAT_CPLD_FAN_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_fan_items_data), ++ .inversed = 1, ++ .health = false, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn274x_data = { ++ .items = mlxplat_mlxcpld_msn274x_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, ++}; ++ ++/* Platform led default data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = { ++ { ++ .label = "status:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "status:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK ++ }, ++ { ++ .label = "psu:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "psu:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan1:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan1:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan2:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan2:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan3:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan3:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan4:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan4:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++}; ++ ++static struct mlxreg_core_led_platform_data mlxplat_default_led_data = { ++ .data = mlxplat_mlxcpld_default_led_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_led_data), ++}; ++ ++/* Platform led MSN21xx system family data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_led_data[] = { ++ { ++ .label = "status:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "status:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK ++ }, ++ { ++ .label = "fan:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "psu1:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "psu1:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "psu2:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "psu2:red", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "uid:blue", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++}; ++ ++static struct mlxreg_core_led_platform_data mlxplat_msn21xx_led_data = { ++ .data = mlxplat_mlxcpld_msn21xx_led_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_led_data), ++}; ++ ++/* Platform led for default data for 200GbE systems */ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_led_data[] = { ++ { ++ .label = "status:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "status:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK ++ }, ++ { ++ .label = "psu:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "psu:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan1:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan1:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan2:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan2:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan3:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan3:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan4:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan4:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan5:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan5:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan6:green", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++ { ++ .label = "fan6:orange", ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, ++ }, ++}; ++ ++static struct mlxreg_core_led_platform_data mlxplat_default_ng_led_data = { ++ .data = mlxplat_mlxcpld_default_ng_led_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_led_data), ++}; ++ ++static int ++mlxplat_mlxcpld_reg_read(void *context, unsigned int reg, unsigned int *val) ++{ ++ *val = ioread8(context + reg); ++ return 0; ++} ++ ++static int ++mlxplat_mlxcpld_reg_write(void *context, unsigned int reg, unsigned int val) ++{ ++ iowrite8(val, context + reg); ++ return 0; ++} ++ ++const struct regmap_config mlxplat_mlxcpld_regmap_config = { ++ .reg_bits = 8, ++ .val_bits = 8, ++ .max_register = 255, ++ .reg_read = mlxplat_mlxcpld_reg_read, ++ .reg_write = mlxplat_mlxcpld_reg_write, ++}; ++ ++static struct resource mlxplat_mlxcpld_resources[] = { ++ [0] = DEFINE_RES_IRQ_NAMED(17, "mlxreg-hotplug"), ++}; ++ ++struct platform_device *mlxplat_dev; ++struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug; ++struct mlxreg_core_led_platform_data *mlxplat_led; ++ ++static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ mlxplat_mux_data[i].values = mlxplat_default_channels[i]; ++ mlxplat_mux_data[i].n_values = ++ ARRAY_SIZE(mlxplat_default_channels[i]); ++ } ++ mlxplat_hotplug = &mlxplat_mlxcpld_default_data; ++ mlxplat_led = &mlxplat_default_led_data; ++ ++ return 1; ++}; ++ ++static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; ++ mlxplat_mux_data[i].n_values = ++ ARRAY_SIZE(mlxplat_msn21xx_channels); ++ } ++ mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data; ++ mlxplat_led = &mlxplat_msn21xx_led_data; ++ ++ return 1; ++}; ++ ++static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; ++ mlxplat_mux_data[i].n_values = ++ ARRAY_SIZE(mlxplat_msn21xx_channels); ++ } ++ mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data; ++ mlxplat_led = &mlxplat_default_led_data; ++ ++ return 1; ++}; ++ ++static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; ++ mlxplat_mux_data[i].n_values = ++ ARRAY_SIZE(mlxplat_msn21xx_channels); ++ } ++ mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data; ++ mlxplat_led = &mlxplat_default_ng_led_data; ++ ++ return 1; ++}; ++ ++static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) ++{ ++ int i; ++ ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; ++ mlxplat_mux_data[i].n_values = ++ ARRAY_SIZE(mlxplat_msn21xx_channels); ++ } ++ mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data; ++ mlxplat_led = &mlxplat_msn21xx_led_data; ++ ++ return 1; ++}; ++ ++static struct dmi_system_id mlxplat_dmi_table[] __initdata = { ++ { ++ .callback = mlxplat_dmi_msn274x_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN274"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_default_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN24"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_default_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN27"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_default_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSB"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_default_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSX"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_msn21xx_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN21"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_msn201x_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN201"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_qmb7xx_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "QMB7"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_qmb7xx_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "SN37"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_qmb7xx_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "SN34"), ++ }, ++ }, ++ { } ++}; ++ ++static int __init mlxplat_init(void) ++{ ++ struct mlxplat_priv *priv; ++ void __iomem *base; ++ int i, err = 0; ++ ++ if (!dmi_check_system(mlxplat_dmi_table)) ++ return -ENODEV; ++ ++ mlxplat_dev = platform_device_register_simple(MLX_PLAT_DEVICE_NAME, -1, ++ mlxplat_lpc_resources, ++ ARRAY_SIZE(mlxplat_lpc_resources)); ++ ++ if (IS_ERR(mlxplat_dev)) ++ return PTR_ERR(mlxplat_dev); ++ ++ priv = devm_kzalloc(&mlxplat_dev->dev, sizeof(struct mlxplat_priv), ++ GFP_KERNEL); ++ if (!priv) { ++ err = -ENOMEM; ++ goto fail_alloc; ++ } ++ platform_set_drvdata(mlxplat_dev, priv); ++ ++ priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", -1, ++ NULL, 0); ++ if (IS_ERR(priv->pdev_i2c)) { ++ err = PTR_ERR(priv->pdev_i2c); ++ goto fail_alloc; ++ } ++ ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ priv->pdev_mux[i] = platform_device_register_resndata( ++ &mlxplat_dev->dev, ++ "i2c-mux-reg", i, NULL, ++ 0, &mlxplat_mux_data[i], ++ sizeof(mlxplat_mux_data[i])); ++ if (IS_ERR(priv->pdev_mux[i])) { ++ err = PTR_ERR(priv->pdev_mux[i]); ++ goto fail_platform_mux_register; ++ } ++ } ++ ++ base = devm_ioport_map(&mlxplat_dev->dev, ++ mlxplat_lpc_resources[1].start, 1); ++ if (IS_ERR(base)) ++ goto fail_platform_mux_register; ++ ++ mlxplat_hotplug->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL, ++ base, &mlxplat_mlxcpld_regmap_config); ++ if (IS_ERR(mlxplat_hotplug->regmap)) ++ goto fail_platform_mux_register; ++ ++ priv->pdev_hotplug = platform_device_register_resndata( ++ &mlxplat_dev->dev, "mlxreg-hotplug", ++ PLATFORM_DEVID_NONE, ++ mlxplat_mlxcpld_resources, ++ ARRAY_SIZE(mlxplat_mlxcpld_resources), ++ mlxplat_hotplug, sizeof(*mlxplat_hotplug)); ++ if (IS_ERR(priv->pdev_hotplug)) { ++ err = PTR_ERR(priv->pdev_hotplug); ++ goto fail_platform_mux_register; ++ } ++ ++ mlxplat_led->regmap = mlxplat_hotplug->regmap; ++ priv->pdev_led = platform_device_register_resndata( ++ &mlxplat_dev->dev, "leds-mlxreg", ++ PLATFORM_DEVID_NONE, NULL, 0, ++ mlxplat_led, sizeof(*mlxplat_led)); ++ if (IS_ERR(priv->pdev_led)) { ++ err = PTR_ERR(priv->pdev_led); ++ goto fail_platform_hotplug_register; ++ } ++ ++ return 0; ++ ++fail_platform_hotplug_register: ++ platform_device_unregister(priv->pdev_hotplug); ++fail_platform_mux_register: ++ while (--i >= 0) ++ platform_device_unregister(priv->pdev_mux[i]); ++ platform_device_unregister(priv->pdev_i2c); ++fail_alloc: ++ platform_device_unregister(mlxplat_dev); ++ ++ return err; ++} ++module_init(mlxplat_init); ++ ++static void __exit mlxplat_exit(void) ++{ ++ struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev); ++ int i; ++ ++ platform_device_unregister(priv->pdev_led); ++ platform_device_unregister(priv->pdev_hotplug); ++ ++ for (i = ARRAY_SIZE(mlxplat_mux_data) - 1; i >= 0 ; i--) ++ platform_device_unregister(priv->pdev_mux[i]); ++ ++ platform_device_unregister(priv->pdev_i2c); ++ platform_device_unregister(mlxplat_dev); ++} ++module_exit(mlxplat_exit); ++ ++MODULE_AUTHOR("Vadim Pasternak (vadimp@mellanox.com)"); ++MODULE_DESCRIPTION("Mellanox platform driver"); ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_ALIAS("dmi:*:*Mellanox*:MSN24*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*:MSN27*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*:MSB*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*:MSX*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*:MSN21*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*MSN274*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*MSN201*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*QMB7*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*SN37*:"); ++MODULE_ALIAS("dmi:*:*Mellanox*QM34*:"); diff --git a/packages/base/any/kernels/4.9-lts/patches/0004-platform-x86-Introduce-support-for-Mellanox-hotplug-.patch b/packages/base/any/kernels/4.9-lts/patches/0004-platform-x86-Introduce-support-for-Mellanox-hotplug-.patch new file mode 100644 index 00000000..58973010 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0004-platform-x86-Introduce-support-for-Mellanox-hotplug-.patch @@ -0,0 +1,905 @@ +Linux backport patch. Includes following commits: +2926024b5081fc8d4b086677bafa1ac55ea0b911 +6124fdf76488681713f278f3fdf2ba2dfe760211 +c84002d15210ca130263e23911cc399202124eb4 +07b89c2b2a5e8ce30166b96f87b324c6b419f108 +91973760712f350048a0fa8e0363e260bf874313 +c2e714e56360e34f88e0a75ee74e467d8b82de75 +af4779be0f2cec63f4cb15d3db78c5de3523756a +d53bc5dc941653f0ed93b11a647bd6ff40f40ef2 + + +diff -Nur a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig +--- a/drivers/platform/mellanox/Kconfig 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/platform/mellanox/Kconfig 2017-11-12 08:54:58.200076777 +0000 +@@ -0,0 +1,25 @@ ++# ++# Platform support for Mellanox hardware ++# ++ ++menuconfig MELLANOX_PLATFORM ++ bool "Platform support for Mellanox hardware" ++ depends on X86 || ARM || COMPILE_TEST ++ ---help--- ++ Say Y here to get to see options for platform support for ++ Mellanox systems. This option alone does not add any kernel code. ++ ++ If you say N, all options in this submenu will be skipped and disabled. ++ ++if MELLANOX_PLATFORM ++ ++config MLXREG_HOTPLUG ++ tristate "Mellanox platform hotplug driver support" ++ depends on REGMAP ++ depends on HWMON ++ depends on I2C ++ ---help--- ++ This driver handles hot-plug events for the power suppliers, power ++ cables and fans on the wide range Mellanox IB and Ethernet systems. ++ ++endif # MELLANOX_PLATFORM +diff -Nur a/drivers/platform/mellanox/Makefile b/drivers/platform/mellanox/Makefile +--- a/drivers/platform/mellanox/Makefile 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/platform/mellanox/Makefile 2017-11-12 08:54:58.200076777 +0000 +@@ -0,0 +1 @@ ++obj-$(CONFIG_MLXREG_HOTPLUG) += mlxreg-hotplug.o +diff -Nur a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c +--- a/drivers/platform/mellanox/mlxreg-hotplug.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/platform/mellanox/mlxreg-hotplug.c 2017-11-12 08:54:58.200076777 +0000 +@@ -0,0 +1,710 @@ ++/* ++ * Copyright (c) 2017 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2017 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Offset of event and mask registers from status register. */ ++#define MLXREG_HOTPLUG_EVENT_OFF 1 ++#define MLXREG_HOTPLUG_MASK_OFF 2 ++#define MLXREG_HOTPLUG_AGGR_MASK_OFF 1 ++ ++/* ASIC health parameters. */ ++#define MLXREG_HOTPLUG_HEALTH_MASK 0x02 ++#define MLXREG_HOTPLUG_RST_CNTR 3 ++ ++#define MLXREG_HOTPLUG_PROP_OKAY "okay" ++#define MLXREG_HOTPLUG_PROP_DISABLED "disabled" ++#define MLXREG_HOTPLUG_PROP_STATUS "status" ++ ++#define MLXREG_HOTPLUG_ATTRS_MAX 24 ++ ++/** ++ * struct mlxreg_hotplug_priv_data - platform private data: ++ * @irq: platform device interrupt number; ++ * @pdev: platform device; ++ * @plat: platform data; ++ * @dwork: delayed work template; ++ * @lock: spin lock; ++ * @hwmon: hwmon device; ++ * @mlxreg_hotplug_attr: sysfs attributes array; ++ * @mlxreg_hotplug_dev_attr: sysfs sensor device attribute array; ++ * @group: sysfs attribute group; ++ * @groups: list of sysfs attribute group for hwmon registration; ++ * @cell: location of top aggregation interrupt register; ++ * @mask: top aggregation interrupt common mask; ++ * @aggr_cache: last value of aggregation register status; ++ */ ++struct mlxreg_hotplug_priv_data { ++ int irq; ++ struct device *dev; ++ struct platform_device *pdev; ++ struct mlxreg_hotplug_platform_data *plat; ++ struct regmap *regmap; ++ struct delayed_work dwork_irq; ++ struct delayed_work dwork; ++ spinlock_t lock; /* sync with interrupt */ ++ struct device *hwmon; ++ struct attribute *mlxreg_hotplug_attr[MLXREG_HOTPLUG_ATTRS_MAX + 1]; ++ struct sensor_device_attribute_2 ++ mlxreg_hotplug_dev_attr[MLXREG_HOTPLUG_ATTRS_MAX]; ++ struct attribute_group group; ++ const struct attribute_group *groups[2]; ++ u32 cell; ++ u32 mask; ++ u32 aggr_cache; ++ bool after_probe; ++}; ++ ++#if defined(CONFIG_OF_DYNAMIC) ++/** ++ * struct mlxreg_hotplug_device_en - Open Firmware property for enabling device ++ * ++ * @name - property name; ++ * @value - property value string; ++ * @length - length of proprty value string; ++ * ++ * The structure is used for the devices, which require some dynamic ++ * selection operation allowing access to them. ++ */ ++static struct property mlxreg_hotplug_device_en = { ++ .name = MLXREG_HOTPLUG_PROP_STATUS, ++ .value = MLXREG_HOTPLUG_PROP_OKAY, ++ .length = sizeof(MLXREG_HOTPLUG_PROP_OKAY), ++}; ++ ++/** ++ * struct mlxreg_hotplug_device_dis - Open Firmware property for disabling ++ * device ++ * ++ * @name - property name; ++ * @value - property value string; ++ * @length - length of proprty value string; ++ * ++ * The structure is used for the devices, which require some dynamic ++ * selection operation disallowing access to them. ++ */ ++static struct property mlxreg_hotplug_device_dis = { ++ .name = MLXREG_HOTPLUG_PROP_STATUS, ++ .value = MLXREG_HOTPLUG_PROP_DISABLED, ++ .length = sizeof(MLXREG_HOTPLUG_PROP_DISABLED), ++}; ++ ++static int mlxreg_hotplug_of_device_create(struct mlxreg_core_data *data) ++{ ++ return of_update_property(data->np, &mlxreg_hotplug_device_en); ++} ++ ++static void mlxreg_hotplug_of_device_destroy(struct mlxreg_core_data *data) ++{ ++ of_update_property(data->np, &mlxreg_hotplug_device_dis); ++ of_node_clear_flag(data->np, OF_POPULATED); ++} ++#else ++static int mlxreg_hotplug_of_device_create(struct mlxreg_core_data *data) ++{ ++ return 0; ++} ++ ++static void mlxreg_hotplug_of_device_destroy(struct mlxreg_core_data *data) ++{ ++} ++#endif ++ ++static int mlxreg_hotplug_device_create(struct mlxreg_core_data *data) ++{ ++ data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr); ++ if (!data->hpdev.adapter) ++ return -EFAULT; ++ ++ data->hpdev.client = i2c_new_device(data->hpdev.adapter, ++ data->hpdev.brdinfo); ++ if (!data->hpdev.client) { ++ i2c_put_adapter(data->hpdev.adapter); ++ data->hpdev.adapter = NULL; ++ return -EFAULT; ++ } ++ ++ return 0; ++} ++ ++static void mlxreg_hotplug_device_destroy(struct mlxreg_core_data *data) ++{ ++ if (data->hpdev.client) { ++ i2c_unregister_device(data->hpdev.client); ++ data->hpdev.client = NULL; ++ } ++ ++ if (data->hpdev.adapter) { ++ i2c_put_adapter(data->hpdev.adapter); ++ data->hpdev.adapter = NULL; ++ } ++} ++ ++static int mlxreg_hotplug_dev_enable(struct mlxreg_core_data *data) ++{ ++ int err; ++ ++ /* Enable and create device. */ ++ if (data->np) ++ err = mlxreg_hotplug_of_device_create(data); ++ else ++ err = mlxreg_hotplug_device_create(data); ++ ++ return err; ++} ++ ++static void mlxreg_hotplug_dev_disable(struct mlxreg_core_data *data) ++{ ++ /* Disable and unregister platform device. */ ++ if (data->np) ++ mlxreg_hotplug_of_device_destroy(data); ++ else ++ mlxreg_hotplug_device_destroy(data); ++} ++ ++static ssize_t mlxreg_hotplug_attr_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct mlxreg_hotplug_priv_data *priv = dev_get_drvdata(dev); ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ int index = to_sensor_dev_attr_2(attr)->index; ++ int nr = to_sensor_dev_attr_2(attr)->nr; ++ struct mlxreg_core_item *item; ++ struct mlxreg_core_data *data; ++ u32 regval; ++ int ret; ++ ++ pdata = dev_get_platdata(&priv->pdev->dev); ++ item = pdata->items + nr; ++ data = item->data + index; ++ ++ ret = regmap_read(priv->regmap, data->reg, ®val); ++ if (ret) ++ return ret; ++ ++ if (item->health) { ++ regval &= data->mask; ++ } else { ++ /* Bit = 0 : functional if item->inversed is true. */ ++ if (item->inversed) ++ regval = !(regval & data->mask); ++ else ++ regval = !!(regval & data->mask); ++ } ++ ++ return sprintf(buf, "%u\n", regval); ++} ++ ++#define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i] ++#define PRIV_DEV_ATTR(i) priv->mlxreg_hotplug_dev_attr[i] ++ ++static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv) ++{ ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ struct mlxreg_core_item *item; ++ struct mlxreg_core_data *data; ++ int num_attrs = 0, id = 0, i, j; ++ ++ pdata = dev_get_platdata(&priv->pdev->dev); ++ item = pdata->items; ++ ++ /* Go over all kinds of items - psu, pwr, fan. */ ++ for (i = 0; i < pdata->counter; i++, item++) { ++ num_attrs += item->count; ++ data = item->data; ++ /* Go over all units within the item. */ ++ for (j = 0; j < item->count; j++, data++, id++) { ++ PRIV_ATTR(id) = &PRIV_DEV_ATTR(id).dev_attr.attr; ++ PRIV_ATTR(id)->name = devm_kasprintf(&priv->pdev->dev, ++ GFP_KERNEL, ++ data->label); ++ ++ if (!PRIV_ATTR(id)->name) { ++ dev_err(priv->dev, "Memory allocation failed for attr %d.\n", ++ id); ++ return -ENOMEM; ++ } ++ ++ PRIV_DEV_ATTR(id).dev_attr.attr.name = ++ PRIV_ATTR(id)->name; ++ PRIV_DEV_ATTR(id).dev_attr.attr.mode = 0444; ++ PRIV_DEV_ATTR(id).dev_attr.show = ++ mlxreg_hotplug_attr_show; ++ PRIV_DEV_ATTR(id).nr = i; ++ PRIV_DEV_ATTR(id).index = j; ++ sysfs_attr_init(&PRIV_DEV_ATTR(id).dev_attr.attr); ++ } ++ } ++ ++ priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs * ++ sizeof(struct attribute *), ++ GFP_KERNEL); ++ if (!priv->group.attrs) ++ return -ENOMEM; ++ ++ priv->group.attrs = priv->mlxreg_hotplug_attr; ++ priv->groups[0] = &priv->group; ++ priv->groups[1] = NULL; ++ ++ return 0; ++} ++ ++static void ++mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv, ++ struct mlxreg_core_item *item) ++{ ++ struct mlxreg_core_data *data; ++ u32 asserted, regval, bit; ++ int ret; ++ ++ /* ++ * Validate if item related to received signal type is valid. ++ * It should never happen, excepted the situation when some ++ * piece of hardware is broken. In such situation just produce ++ * error message and return. Caller must continue to handle the ++ * signals from other devices if any. ++ */ ++ if (unlikely(!item)) { ++ dev_err(priv->dev, "False signal: at offset:mask 0x%02x:0x%02x.\n", ++ item->reg, item->mask); ++ ++ return; ++ } ++ ++ /* Mask event. */ ++ ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF, ++ 0); ++ if (ret) ++ goto access_error; ++ ++ /* Read status. */ ++ ret = regmap_read(priv->regmap, item->reg, ®val); ++ if (ret) ++ goto access_error; ++ ++ /* Set asserted bits and save last status. */ ++ regval &= item->mask; ++ asserted = item->cache ^ regval; ++ item->cache = regval; ++ ++ for_each_set_bit(bit, (unsigned long *)&asserted, 8) { ++ data = item->data + bit; ++ if (regval & BIT(bit)) { ++ if (item->inversed) ++ mlxreg_hotplug_dev_disable(data); ++ else ++ mlxreg_hotplug_dev_enable(data); ++ } else { ++ if (item->inversed) ++ mlxreg_hotplug_dev_enable(data); ++ else ++ mlxreg_hotplug_dev_disable(data); ++ } ++ } ++ ++ /* Acknowledge event. */ ++ ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_EVENT_OFF, ++ 0); ++ if (ret) ++ goto access_error; ++ ++ /* Unmask event. */ ++ ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF, ++ item->mask); ++ if (ret) ++ goto access_error; ++ ++ return; ++ ++access_error: ++ dev_err(priv->dev, "Failed to complete workqueue.\n"); ++} ++ ++static void ++mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv, ++ struct mlxreg_core_item *item) ++{ ++ struct mlxreg_core_data *data = item->data; ++ u32 regval; ++ int i, ret; ++ ++ for (i = 0; i < item->count; i++, data++) { ++ /* Mask event. */ ++ ret = regmap_write(priv->regmap, data->reg + ++ MLXREG_HOTPLUG_MASK_OFF, 0); ++ if (ret) ++ goto access_error; ++ ++ /* Read status. */ ++ ret = regmap_read(priv->regmap, data->reg, ®val); ++ if (ret) ++ goto access_error; ++ ++ regval &= data->mask; ++ item->cache = regval; ++ if (regval == MLXREG_HOTPLUG_HEALTH_MASK) { ++ if ((data->health_cntr++ == MLXREG_HOTPLUG_RST_CNTR) || ++ !priv->after_probe) { ++ mlxreg_hotplug_dev_enable(data); ++ data->attached = true; ++ } ++ } else { ++ if (data->attached) { ++ mlxreg_hotplug_dev_disable(data); ++ data->attached = false; ++ data->health_cntr = 0; ++ } ++ } ++ ++ /* Acknowledge event. */ ++ ret = regmap_write(priv->regmap, data->reg + ++ MLXREG_HOTPLUG_EVENT_OFF, 0); ++ if (ret) ++ goto access_error; ++ ++ /* Unmask event. */ ++ ret = regmap_write(priv->regmap, data->reg + ++ MLXREG_HOTPLUG_MASK_OFF, data->mask); ++ if (ret) ++ goto access_error; ++ } ++ ++ return; ++ ++access_error: ++ dev_err(priv->dev, "Failed to complete workqueue.\n"); ++} ++ ++/* ++ * mlxreg_hotplug_work_handler - performs traversing of device interrupt ++ * registers according to the below hierarchy schema: ++ * ++ * Aggregation registers (status/mask) ++ * PSU registers: *---* ++ * *-----------------* | | ++ * |status/event/mask|-----> | * | ++ * *-----------------* | | ++ * Power registers: | | ++ * *-----------------* | | ++ * |status/event/mask|-----> | * | ++ * *-----------------* | | ++ * FAN registers: | |--> CPU ++ * *-----------------* | | ++ * |status/event/mask|-----> | * | ++ * *-----------------* | | ++ * ASIC registers: | | ++ * *-----------------* | | ++ * |status/event/mask|-----> | * | ++ * *-----------------* | | ++ * *---* ++ * ++ * In case some system changed are detected: FAN in/out, PSU in/out, power ++ * cable attached/detached, ASIC helath good/bad, relevant device is created ++ * or destroyed. ++ */ ++static void mlxreg_hotplug_work_handler(struct work_struct *work) ++{ ++ struct mlxreg_hotplug_priv_data *priv = container_of(work, ++ struct mlxreg_hotplug_priv_data, dwork_irq.work); ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ struct mlxreg_core_item *item; ++ unsigned long flags; ++ u32 regval, aggr_asserted; ++ int i; ++ int ret; ++ ++ pdata = dev_get_platdata(&priv->pdev->dev); ++ item = pdata->items; ++ /* Mask aggregation event. */ ++ ret = regmap_write(priv->regmap, pdata->cell + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, 0); ++ if (ret < 0) ++ goto access_error; ++ ++ /* Read aggregation status. */ ++ ret = regmap_read(priv->regmap, pdata->cell, ®val); ++ if (ret) ++ goto access_error; ++ ++ regval &= pdata->mask; ++ aggr_asserted = priv->aggr_cache ^ regval; ++ priv->aggr_cache = regval; ++ ++ /* Handle topology and health configuration changes. */ ++ for (i = 0; i < pdata->counter; i++, item++) { ++ if (aggr_asserted & item->aggr_mask) { ++ if (item->health) ++ mlxreg_hotplug_health_work_helper(priv, item); ++ else ++ mlxreg_hotplug_work_helper(priv, item); ++ } ++ } ++ ++ if (aggr_asserted) { ++ spin_lock_irqsave(&priv->lock, flags); ++ ++ /* ++ * It is possible, that some signals have been inserted, while ++ * interrupt has been masked by mlxreg_hotplug_work_handler. ++ * In this case such signals will be missed. In order to handle ++ * these signals delayed work is canceled and work task ++ * re-scheduled for immediate execution. It allows to handle ++ * missed signals, if any. In other case work handler just ++ * validates that no new signals have been received during ++ * masking. ++ */ ++ cancel_delayed_work(&priv->dwork_irq); ++ schedule_delayed_work(&priv->dwork_irq, 0); ++ ++ spin_unlock_irqrestore(&priv->lock, flags); ++ ++ return; ++ } ++ ++ /* Unmask aggregation event (no need acknowledge). */ ++ ret = regmap_write(priv->regmap, pdata->cell + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); ++ if (ret) ++ goto access_error; ++ ++ return; ++ ++access_error: ++ dev_err(priv->dev, "Failed to complete workqueue.\n"); ++} ++ ++static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) ++{ ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ struct mlxreg_core_item *item; ++ int i; ++ int ret; ++ ++ pdata = dev_get_platdata(&priv->pdev->dev); ++ item = pdata->items; ++ ++ for (i = 0; i < pdata->counter; i++, item++) { ++ /* Clear group presense event. */ ++ ret = regmap_write(priv->regmap, item->reg + ++ MLXREG_HOTPLUG_EVENT_OFF, 0); ++ if (ret) ++ goto access_error; ++ ++ /* Set group initial status as mask and unmask group event. */ ++ if (item->inversed) { ++ item->cache = item->mask; ++ ret = regmap_write(priv->regmap, item->reg + ++ MLXREG_HOTPLUG_MASK_OFF, ++ item->mask); ++ if (ret) ++ goto access_error; ++ } ++ } ++ ++ /* Keep aggregation initial status as zero and unmask events. */ ++ ret = regmap_write(priv->regmap, pdata->cell + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); ++ if (ret) ++ goto access_error; ++ ++ /* Keep low aggregation initial status as zero and unmask events. */ ++ ret = regmap_write(priv->regmap, pdata->cell_low + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask_low); ++ if (ret) ++ goto access_error; ++ ++ /* Invoke work handler for initializing hot plug devices setting. */ ++ mlxreg_hotplug_work_handler(&priv->dwork_irq.work); ++ ++ enable_irq(priv->irq); ++ ++ return 0; ++ ++access_error: ++ dev_err(priv->dev, "Failed to set interrupts.\n"); ++ ++ enable_irq(priv->irq); ++ ++ return ret; ++} ++ ++static void mlxreg_hotplug_unset_irq(struct mlxreg_hotplug_priv_data *priv) ++{ ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ struct mlxreg_core_item *item; ++ struct mlxreg_core_data *data; ++ int count, i, j; ++ ++ pdata = dev_get_platdata(&priv->pdev->dev); ++ item = pdata->items; ++ disable_irq(priv->irq); ++ cancel_delayed_work_sync(&priv->dwork_irq); ++ ++ /* Mask low aggregation event. */ ++ regmap_write(priv->regmap, pdata->cell_low + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, 0); ++ ++ /* Mask aggregation event. */ ++ regmap_write(priv->regmap, pdata->cell + MLXREG_HOTPLUG_AGGR_MASK_OFF, ++ 0); ++ ++ /* Clear topology configurations. */ ++ for (i = 0; i < pdata->counter; i++, item++) { ++ data = item->data; ++ /* Mask group presense event. */ ++ regmap_write(priv->regmap, data->reg + MLXREG_HOTPLUG_MASK_OFF, ++ 0); ++ /* Clear group presense event. */ ++ regmap_write(priv->regmap, data->reg + ++ MLXREG_HOTPLUG_EVENT_OFF, 0); ++ ++ /* Remove all the attached devices in group. */ ++ count = item->count; ++ for (j = 0; j < count; j++, data++) ++ mlxreg_hotplug_dev_disable(data); ++ } ++} ++ ++static irqreturn_t mlxreg_hotplug_irq_handler(int irq, void *dev) ++{ ++ struct mlxreg_hotplug_priv_data *priv = ++ (struct mlxreg_hotplug_priv_data *)dev; ++ ++ /* Schedule work task for immediate execution.*/ ++ schedule_delayed_work(&priv->dwork_irq, 0); ++ ++ return IRQ_HANDLED; ++} ++ ++static int mlxreg_hotplug_probe(struct platform_device *pdev) ++{ ++ struct mlxreg_core_hotplug_platform_data *pdata; ++ struct mlxreg_hotplug_priv_data *priv; ++ int err; ++ ++ pdata = dev_get_platdata(&pdev->dev); ++ if (!pdata) { ++ dev_err(&pdev->dev, "Failed to get platform data.\n"); ++ return -EINVAL; ++ } ++ ++ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ if (pdata->irq) { ++ priv->irq = pdata->irq; ++ } else { ++ priv->irq = platform_get_irq(pdev, 0); ++ if (priv->irq < 0) { ++ dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ++ priv->irq); ++ return priv->irq; ++ } ++ } ++ ++ priv->regmap = pdata->regmap; ++ priv->dev = pdev->dev.parent; ++ priv->pdev = pdev; ++ ++ err = devm_request_irq(&pdev->dev, priv->irq, ++ mlxreg_hotplug_irq_handler, IRQF_TRIGGER_FALLING ++ | IRQF_SHARED, "mlxreg-hotplug", priv); ++ if (err) { ++ dev_err(&pdev->dev, "Failed to request irq: %d\n", err); ++ return err; ++ } ++ ++ disable_irq(priv->irq); ++ spin_lock_init(&priv->lock); ++ INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler); ++ /* Perform initial interrupts setup. */ ++ mlxreg_hotplug_set_irq(priv); ++ ++ priv->after_probe = true; ++ dev_set_drvdata(&pdev->dev, priv); ++ ++ err = mlxreg_hotplug_attr_init(priv); ++ if (err) { ++ dev_err(&pdev->dev, "Failed to allocate attributes: %d\n", ++ err); ++ return err; ++ } ++ ++ priv->hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, ++ "mlxreg_hotplug", priv, priv->groups); ++ if (IS_ERR(priv->hwmon)) { ++ dev_err(&pdev->dev, "Failed to register hwmon device %ld\n", ++ PTR_ERR(priv->hwmon)); ++ return PTR_ERR(priv->hwmon); ++ } ++ ++ return 0; ++} ++ ++static int mlxreg_hotplug_remove(struct platform_device *pdev) ++{ ++ struct mlxreg_hotplug_priv_data *priv = dev_get_drvdata(&pdev->dev); ++ ++ /* Clean interrupts setup. */ ++ mlxreg_hotplug_unset_irq(priv); ++ ++ return 0; ++} ++ ++static struct platform_driver mlxreg_hotplug_driver = { ++ .driver = { ++ .name = "mlxreg-hotplug", ++ }, ++ .probe = mlxreg_hotplug_probe, ++ .remove = mlxreg_hotplug_remove, ++}; ++ ++module_platform_driver(mlxreg_hotplug_driver); ++ ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox regmap hotplug platform driver"); ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_ALIAS("platform:mlxreg-hotplug"); +diff -Nur a/include/linux/platform_data/mlxreg.h b/include/linux/platform_data/mlxreg.h +--- a/include/linux/platform_data/mlxreg.h 1970-01-01 00:00:00.000000000 +0000 ++++ b/include/linux/platform_data/mlxreg.h 2017-11-12 09:04:09.796084101 +0000 +@@ -0,0 +1,142 @@ ++/* ++ * Copyright (c) 2017 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2017 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef __LINUX_PLATFORM_DATA_MLXREG_H ++#define __LINUX_PLATFORM_DATA_MLXREG_H ++ ++#define MLXREG_CORE_LABEL_MAX_SIZE 32 ++ ++/** ++ * struct mlxreg_hotplug_device - I2C device data: ++ * ++ * @adapter: I2C device adapter; ++ * @client: I2C device client; ++ * @brdinfo: device board information; ++ * @nr: I2C device adapter number, to which device is to be attached; ++ * ++ * Structure represents I2C hotplug device static data (board topology) and ++ * dynamic data (related kernel objects handles). ++ */ ++struct mlxreg_hotplug_device { ++ struct i2c_adapter *adapter; ++ struct i2c_client *client; ++ struct i2c_board_info *brdinfo; ++ int nr; ++}; ++ ++/** ++ * struct mlxreg_core_data - attributes control data: ++ * ++ * @label: attribute label; ++ * @label: attribute register offset; ++ * @reg: attribute register; ++ * @mask: attribute access mask; ++ * @bit: attribute effective bit; ++ * @np - pointer to node platform associated with attribute; ++ * @hpdev - hotplug device data; ++ * @health_cntr: dynamic device health indication counter; ++ * @attached: true if device has been attached after good helath indication; ++ */ ++struct mlxreg_core_data { ++ char label[MLXREG_CORE_LABEL_MAX_SIZE]; ++ u32 reg; ++ u32 mask; ++ u32 bit; ++ struct device_node *np; ++ struct mlxreg_hotplug_device hpdev; ++ u8 health_cntr; ++ bool attached; ++}; ++ ++/** ++ * struct mlxreg_core_item - same type components controlled by the driver: ++ * ++ * @data: component data; ++ * @aggr_mask: group aggregation mask; ++ * @reg: group interrupt status register; ++ * @mask: group interrupt mask; ++ * @cache: last status value for elements fro the same group; ++ * @count: number of available elements in the group; ++ * @ind: element's index inside the group; ++ * @inversed: if 0: 0 for signal status is OK, if 1 - 1 is OK; ++ * @health: true if device has health indication, false in other case; ++ */ ++struct mlxreg_core_item { ++ struct mlxreg_core_data *data; ++ u32 aggr_mask; ++ u32 reg; ++ u32 mask; ++ u32 cache; ++ u8 count; ++ u8 ind; ++ u8 inversed; ++ u8 health; ++}; ++ ++/** ++ * struct mlxreg_core_led_platform_data - led platform data: ++ * ++ * @led_data: led private data; ++ * @regmap: register map of parent device; ++ * @counter: number of led instances; ++ */ ++struct mlxreg_core_led_platform_data { ++ struct mlxreg_core_data *data; ++ void *regmap; ++ int counter; ++}; ++ ++/** ++ * struct mlxreg_core_hotplug_platform_data - hotplug platform data: ++ * ++ * @items: same type components with the hotplug capability; ++ * @irq: platform interrupt number; ++ * @regmap: register map of parent device; ++ * @counter: number of the components with the hotplug capability; ++ * @cell: location of top aggregation interrupt register; ++ * @mask: top aggregation interrupt common mask; ++ * @cell_low: location of low aggregation interrupt register; ++ * @mask_low: low aggregation interrupt common mask; ++ */ ++struct mlxreg_core_hotplug_platform_data { ++ struct mlxreg_core_item *items; ++ int irq; ++ void *regmap; ++ int counter; ++ u32 cell; ++ u32 mask; ++ u32 cell_low; ++ u32 mask_low; ++}; ++ ++#endif /* __LINUX_PLATFORM_DATA_MLXREG_H */ diff --git a/packages/base/any/kernels/4.9-lts/patches/0005-leds-add-driver-for-support-Mellanox-regmap-LEDs-for.patch b/packages/base/any/kernels/4.9-lts/patches/0005-leds-add-driver-for-support-Mellanox-regmap-LEDs-for.patch new file mode 100644 index 00000000..558cbbc4 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0005-leds-add-driver-for-support-Mellanox-regmap-LEDs-for.patch @@ -0,0 +1,398 @@ +Linux backport patch. Includes following commits: +7dc37aeb560416771cbdc286357157c7565dc1fe +9244ef4cb79a8411656cb8fc2366f32f2294a0c9 +daf155fe70c9d69c28bba632b6a758ac8feab6e7 + + +diff -Nur a/drivers/leds/Kconfig b/drivers/leds/Kconfig +--- a/drivers/leds/Kconfig 2017-11-12 09:08:40.740087699 +0000 ++++ b/drivers/leds/Kconfig 2017-11-12 09:06:54.580086289 +0000 +@@ -659,6 +659,35 @@ + This option enabled support for the LEDs on the Mellanox + boards. Say Y to enabled these. + ++config LEDS_MLXREG ++ tristate "LED support for the Mellanox BMC cards" ++ depends on LEDS_CLASS ++ help ++ This option enabled support for the LEDs on the Mellanox BMC cards. ++ The driver can be activated from the device tree or by the direct ++ platform device add call. Say Y to enabled these. To compile this ++ driver as a module, choose 'M' here: the module will be called ++ leds-mlxreg. ++ ++config LEDS_USER ++ tristate "Userspace LED support" ++ depends on LEDS_CLASS ++ help ++ This option enables support for userspace LEDs. Say 'y' to enable this ++ support in kernel. To compile this driver as a module, choose 'm' here: ++ the module will be called uleds. ++ ++config LEDS_NIC78BX ++ tristate "LED support for NI PXI NIC78bx devices" ++ depends on LEDS_CLASS ++ depends on X86 && ACPI ++ help ++ This option enables support for the User1 and User2 LEDs on NI ++ PXI NIC78bx devices. ++ ++ To compile this driver as a module, choose M here: the module ++ will be called leds-nic78bx. ++ + comment "LED Triggers" + source "drivers/leds/trigger/Kconfig" + +diff -Nur a/drivers/leds/Makefile b/drivers/leds/Makefile +--- a/drivers/leds/Makefile 2017-11-12 09:08:40.740087699 +0000 ++++ b/drivers/leds/Makefile 2017-11-12 09:06:54.580086289 +0000 +@@ -71,6 +71,7 @@ + obj-$(CONFIG_LEDS_IS31FL32XX) += leds-is31fl32xx.o + obj-$(CONFIG_LEDS_PM8058) += leds-pm8058.o + obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o ++obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o + + # LED SPI Drivers + obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o +diff -Nur a/drivers/leds/leds-mlxcpld.c b/drivers/leds/leds-mlxcpld.c +--- a/drivers/leds/leds-mlxcpld.c 2017-11-12 09:08:40.740087699 +0000 ++++ b/drivers/leds/leds-mlxcpld.c 2017-11-12 09:08:05.620087233 +0000 +@@ -400,6 +400,9 @@ + struct platform_device *pdev; + int err; + ++ if (!dmi_match(DMI_CHASSIS_VENDOR, "Mellanox Technologies Ltd.")) ++ return -ENODEV; ++ + pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0); + if (IS_ERR(pdev)) { + pr_err("Device allocation failed\n"); +@@ -426,5 +429,5 @@ + + MODULE_AUTHOR("Vadim Pasternak "); + MODULE_DESCRIPTION("Mellanox board LED driver"); +-MODULE_LICENSE("GPL v2"); ++MODULE_LICENSE("Dual BSD/GPL"); + MODULE_ALIAS("platform:leds_mlxcpld"); +diff -Nur a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c +--- a/drivers/leds/leds-mlxreg.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/leds/leds-mlxreg.c 2017-11-12 09:06:54.580086289 +0000 +@@ -0,0 +1,318 @@ ++/* ++ * Copyright (c) 2017 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2017 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Codes for LEDs. */ ++#define MLXREG_LED_OFFSET_BLINK_3HZ 0x01 /* Offset from solid: 3Hz blink */ ++#define MLXREG_LED_OFFSET_BLINK_6HZ 0x02 /* Offset from solid: 6Hz blink */ ++#define MLXREG_LED_IS_OFF 0x00 /* Off */ ++#define MLXREG_LED_RED_SOLID 0x05 /* Solid red */ ++#define MLXREG_LED_GREEN_SOLID 0x0D /* Solid green */ ++#define MLXREG_LED_AMBER_SOLID 0x09 /* Solid amber */ ++#define MLXREG_LED_BLINK_3HZ 167 /* ~167 msec off/on - HW support */ ++#define MLXREG_LED_BLINK_6HZ 83 /* ~83 msec off/on - HW support */ ++ ++/** ++ * struct mlxreg_led_data - led control data: ++ * ++ * @data: led configuration data; ++ * @led_classdev: led class data; ++ * @base_color: base led color (other colors have constant offset from base); ++ * @led_data: led data; ++ * @data_parent: pointer to private device control data of parent; ++ */ ++struct mlxreg_led_data { ++ struct mlxreg_core_data *data; ++ struct led_classdev led_cdev; ++ u8 base_color; ++ void *data_parent; ++ char led_cdev_name[MLXREG_CORE_LABEL_MAX_SIZE]; ++}; ++ ++#define cdev_to_priv(c) container_of(c, struct mlxreg_led_data, led_cdev) ++ ++/** ++ * struct mlxreg_led_priv_data - platform private data: ++ * ++ * @pdev: platform device; ++ * @pdata: platform data; ++ * @access_lock: mutex for attribute IO access; ++ */ ++struct mlxreg_led_priv_data { ++ struct platform_device *pdev; ++ struct mlxreg_core_led_platform_data *pdata; ++ struct mutex access_lock; /* protect IO operations */ ++}; ++ ++static int ++mlxreg_led_store_hw(struct mlxreg_led_data *led_data, u8 vset) ++{ ++ struct mlxreg_led_priv_data *priv = led_data->data_parent; ++ struct mlxreg_core_led_platform_data *led_pdata = priv->pdata; ++ struct mlxreg_core_data *data = led_data->data; ++ u32 regval; ++ u32 nib; ++ int ret; ++ ++ /* ++ * Each LED is controlled through low or high nibble of the relevant ++ * register byte. Register offset is specified by off parameter. ++ * Parameter vset provides color code: 0x0 for off, 0x5 for solid red, ++ * 0x6 for 3Hz blink red, 0xd for solid green, 0xe for 3Hz blink ++ * green. ++ * Parameter mask specifies which nibble is used for specific LED: mask ++ * 0xf0 - lower nibble is to be used (bits from 0 to 3), mask 0x0f - ++ * higher nibble (bits from 4 to 7). ++ */ ++ mutex_lock(&priv->access_lock); ++ ++ ret = regmap_read(led_pdata->regmap, data->reg, ®val); ++ if (ret) ++ goto access_error; ++ ++ nib = (ror32(data->mask, data->bit) == 0xf0) ? rol32(vset, data->bit) : ++ rol32(vset, data->bit + 4); ++ regval = (regval & data->mask) | nib; ++ ++ ret = regmap_write(led_pdata->regmap, data->reg, regval); ++ ++access_error: ++ mutex_unlock(&priv->access_lock); ++ ++ return ret; ++} ++ ++static enum led_brightness ++mlxreg_led_get_hw(struct mlxreg_led_data *led_data) ++{ ++ struct mlxreg_led_priv_data *priv = led_data->data_parent; ++ struct mlxreg_core_led_platform_data *led_pdata = priv->pdata; ++ struct mlxreg_core_data *data = led_data->data; ++ u32 regval; ++ int ret; ++ ++ /* ++ * Each LED is controlled through low or high nibble of the relevant ++ * register byte. Register offset is specified by off parameter. ++ * Parameter vset provides color code: 0x0 for off, 0x5 for solid red, ++ * 0x6 for 3Hz blink red, 0xd for solid green, 0xe for 3Hz blink ++ * green. ++ * Parameter mask specifies which nibble is used for specific LED: mask ++ * 0xf0 - lower nibble is to be used (bits from 0 to 3), mask 0x0f - ++ * higher nibble (bits from 4 to 7). ++ */ ++ ret = regmap_read(led_pdata->regmap, data->reg, ®val); ++ if (ret < 0) { ++ dev_warn(led_data->led_cdev.dev, "Failed to get current brightness, error: %d\n", ++ ret); ++ /* Assume the LED is OFF */ ++ return LED_OFF; ++ } ++ ++ regval = regval & ~data->mask; ++ regval = (ror32(data->mask, data->bit) == 0xf0) ? ror32(regval, ++ data->bit) : ror32(regval, data->bit + 4); ++ if (regval >= led_data->base_color && ++ regval <= (led_data->base_color + MLXREG_LED_OFFSET_BLINK_6HZ)) ++ ret = LED_FULL; ++ else ++ ret = LED_OFF; ++ ++ return ret; ++} ++ ++static int ++mlxreg_led_brightness_set(struct led_classdev *cled, enum led_brightness value) ++{ ++ struct mlxreg_led_data *led_data = cdev_to_priv(cled); ++ ++ if (value) ++ return mlxreg_led_store_hw(led_data, led_data->base_color); ++ else ++ return mlxreg_led_store_hw(led_data, MLXREG_LED_IS_OFF); ++} ++ ++static enum led_brightness ++mlxreg_led_brightness_get(struct led_classdev *cled) ++{ ++ struct mlxreg_led_data *led_data = cdev_to_priv(cled); ++ ++ return mlxreg_led_get_hw(led_data); ++} ++ ++static int ++mlxreg_led_blink_set(struct led_classdev *cled, unsigned long *delay_on, ++ unsigned long *delay_off) ++{ ++ struct mlxreg_led_data *led_data = cdev_to_priv(cled); ++ int err; ++ ++ /* ++ * HW supports two types of blinking: full (6Hz) and half (3Hz). ++ * For delay on/off zero LED is setting to solid color. For others ++ * combination blinking is to be controlled by the software timer. ++ */ ++ if (!(*delay_on == 0 && *delay_off == 0) && ++ !(*delay_on == MLXREG_LED_BLINK_3HZ && ++ *delay_off == MLXREG_LED_BLINK_3HZ) && ++ !(*delay_on == MLXREG_LED_BLINK_6HZ && ++ *delay_off == MLXREG_LED_BLINK_6HZ)) ++ return -EINVAL; ++ ++ if (*delay_on == MLXREG_LED_BLINK_6HZ) ++ err = mlxreg_led_store_hw(led_data, led_data->base_color + ++ MLXREG_LED_OFFSET_BLINK_6HZ); ++ else if (*delay_on == MLXREG_LED_BLINK_3HZ) ++ err = mlxreg_led_store_hw(led_data, led_data->base_color + ++ MLXREG_LED_OFFSET_BLINK_3HZ); ++ else ++ err = mlxreg_led_store_hw(led_data, led_data->base_color); ++ ++ return err; ++} ++ ++static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) ++{ ++ struct mlxreg_core_led_platform_data *led_pdata = priv->pdata; ++ struct mlxreg_core_data *data = led_pdata->data; ++ struct mlxreg_led_data *led_data; ++ struct led_classdev *led_cdev; ++ int brightness; ++ int i; ++ int err; ++ ++ for (i = 0; i < led_pdata->counter; i++, data++) { ++ led_data = devm_kzalloc(&priv->pdev->dev, sizeof(*led_data), ++ GFP_KERNEL); ++ if (!led_data) ++ return -ENOMEM; ++ ++ led_cdev = &led_data->led_cdev; ++ led_data->data_parent = priv; ++ if (strstr(data->label, "red") || ++ strstr(data->label, "orange")) { ++ brightness = LED_OFF; ++ led_data->base_color = MLXREG_LED_RED_SOLID; ++ } else if (strstr(data->label, "amber")) { ++ brightness = LED_OFF; ++ led_data->base_color = MLXREG_LED_AMBER_SOLID; ++ } else { ++ brightness = LED_OFF; ++ led_data->base_color = MLXREG_LED_GREEN_SOLID; ++ } ++ sprintf(led_data->led_cdev_name, "%s:%s", "mlxreg", ++ data->label); ++ led_cdev->name = led_data->led_cdev_name; ++ led_cdev->brightness = brightness; ++ led_cdev->max_brightness = 1; ++ led_cdev->brightness_set_blocking = ++ mlxreg_led_brightness_set; ++ led_cdev->brightness_get = mlxreg_led_brightness_get; ++ led_cdev->blink_set = mlxreg_led_blink_set; ++ led_cdev->flags = LED_CORE_SUSPENDRESUME; ++ led_data->data = data; ++ err = devm_led_classdev_register(&priv->pdev->dev, led_cdev); ++ if (err) ++ return err; ++ ++ if (led_cdev->brightness) ++ mlxreg_led_brightness_set(led_cdev, ++ led_cdev->brightness); ++ dev_info(led_cdev->dev, "label: %s, mask: 0x%02x, offset:0x%02x\n", ++ data->label, data->mask, data->reg); ++ } ++ ++ return 0; ++} ++ ++static int mlxreg_led_probe(struct platform_device *pdev) ++{ ++ struct mlxreg_core_led_platform_data *led_pdata; ++ struct mlxreg_led_priv_data *priv; ++ ++ led_pdata = dev_get_platdata(&pdev->dev); ++ if (!led_pdata) { ++ dev_err(&pdev->dev, "Failed to get platform data.\n"); ++ return -EINVAL; ++ } ++ ++ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ mutex_init(&priv->access_lock); ++ priv->pdev = pdev; ++ priv->pdata = led_pdata; ++ ++ return mlxreg_led_config(priv); ++} ++ ++static int mlxreg_led_remove(struct platform_device *pdev) ++{ ++ struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev); ++ ++ mutex_destroy(&priv->access_lock); ++ ++ return 0; ++} ++ ++static const struct of_device_id mlxreg_led_dt_match[] = { ++ { .compatible = "mellanox,leds-mlxreg" }, ++ { }, ++}; ++MODULE_DEVICE_TABLE(of, mlxreg_led_dt_match); ++ ++static struct platform_driver mlxreg_led_driver = { ++ .driver = { ++ .name = "leds-mlxreg", ++ .of_match_table = of_match_ptr(mlxreg_led_dt_match), ++ }, ++ .probe = mlxreg_led_probe, ++ .remove = mlxreg_led_remove, ++}; ++ ++module_platform_driver(mlxreg_led_driver); ++ ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox LED regmap driver"); ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_ALIAS("platform:leds-mlxreg"); diff --git a/packages/base/any/kernels/4.9-lts/patches/0006-Mellanox-switch-drivers-changes.patch b/packages/base/any/kernels/4.9-lts/patches/0006-Mellanox-switch-drivers-changes.patch new file mode 100644 index 00000000..c820bbdc --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0006-Mellanox-switch-drivers-changes.patch @@ -0,0 +1,2118 @@ +Linux backport patch. Includes following commits: +02f1d19ecd08f7da83bf17d556ba147b16ed9dab +50deb9064015956274a989d035c0a101188c5bf2 +515dc42e5f57aa4b2dbb18fbe6b3200224d051a7 +63b01357d3f002ebed8e532b503a84dde6f45060 +7c2ed7426f0835d5408a2c97fc6ebcc67c5feea0 +65f178307a4274f1ab52f4e729e1eabe00ee2d96 +81ce6e3fefba4ed1578db80609b54ccc3ae624cb +3f65860a8b01652fbda978b991d13c02848c8ee2 +05cdb2439ba8bb00a1746ec68e27cec62ea1e142 +021697a48b00b51636d88e5056015ad65b6da821 +f6410966453b7671a0c4032652db36b2e67ba43c +acf30a9f0714a734531078b7a6d85ab7762c3589 +f334341a185bad33bbc3cf0a3b7d7189d8803bc0 +aec592f5c0d44b3ac4038dc539859fa247738f6e +589428b6233c6a9bffbf8c8bca86f62838f35021 + + +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig +--- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig 2017-11-09 12:40:31.940814834 +0000 +@@ -19,6 +19,24 @@ + ---help--- + Say Y here if you want to expose HWMON interface on mlxsw devices. + ++config MLXSW_CORE_THERMAL ++ bool "Thermal zone support for Mellanox Technologies Switch ASICs" ++ depends on MLXSW_CORE && THERMAL ++ depends on !(MLXSW_CORE=y && THERMAL=m) ++ default y ++ ---help--- ++ Say Y here if you want to automatically control fans speed according ++ ambient temperature reported by ASIC. ++ ++config MLXSW_CORE_QSFP ++ bool "QSFP support for Mellanox Technologies Switch ASICs" ++ depends on MLXSW_CORE && HWMON ++ depends on !(MLXSW_CORE=y && HWMON=m) ++ default y ++ ---help--- ++ Say Y here if you want to expose sysfs QSFP interface on mlxsw ++ devices. ++ + config MLXSW_PCI + tristate "PCI bus implementation for Mellanox Technologies Switch ASICs" + depends on PCI && HAS_DMA && HAS_IOMEM && MLXSW_CORE +@@ -29,6 +47,27 @@ + To compile this driver as a module, choose M here: the + module will be called mlxsw_pci. + ++config MLXSW_I2C ++ tristate "I2C bus implementation for Mellanox Technologies Switch ASICs" ++ depends on I2C && MLXSW_CORE ++ default m ++ ---help--- ++ This is I2C bus implementation for Mellanox Technologies Switch ASICs. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called mlxsw_i2c. ++ ++config MLXSW_SWITCHIB ++ tristate "Mellanox Technologies SwitchIB and SwitchIB-2 support" ++ depends on MLXSW_CORE && NET_SWITCHDEV ++ default m ++ ---help--- ++ This driver supports Mellanox Technologies SwitchIB and SwitchIB-2 ++ Infiniband Switch ASICs. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called mlxsw_switchib. ++ + config MLXSW_SWITCHX2 + tristate "Mellanox Technologies SwitchX-2 support" + depends on MLXSW_CORE && NET_SWITCHDEV +@@ -58,3 +97,14 @@ + ---help--- + Say Y here if you want to use Data Center Bridging (DCB) in the + driver. ++ ++config MLXSW_MINIMAL ++ tristate "Mellanox Technologies minimal I2C support" ++ depends on MLXSW_CORE && MLXSW_I2C ++ default m ++ ---help--- ++ This driver supports I2C access for Mellanox Technologies Switch ++ ASICs. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called mlxsw_minimal. +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/Makefile b/drivers/net/ethernet/mellanox/mlxsw/Makefile +--- a/drivers/net/ethernet/mellanox/mlxsw/Makefile 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/Makefile 2017-11-09 12:40:31.940814834 +0000 +@@ -1,8 +1,14 @@ + obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o + mlxsw_core-objs := core.o + mlxsw_core-$(CONFIG_MLXSW_CORE_HWMON) += core_hwmon.o ++mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o ++mlxsw_core-$(CONFIG_MLXSW_CORE_QSFP) += qsfp_sysfs.o + obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o + mlxsw_pci-objs := pci.o ++obj-$(CONFIG_MLXSW_I2C) += mlxsw_i2c.o ++mlxsw_i2c-objs := i2c.o ++obj-$(CONFIG_MLXSW_SWITCHIB) += mlxsw_switchib.o ++mlxsw_switchib-objs := switchib.o + obj-$(CONFIG_MLXSW_SWITCHX2) += mlxsw_switchx2.o + mlxsw_switchx2-objs := switchx2.o + obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o +@@ -10,3 +16,5 @@ + spectrum_switchdev.o spectrum_router.o \ + spectrum_kvdl.o + mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o ++obj-$(CONFIG_MLXSW_MINIMAL) += mlxsw_minimal.o ++mlxsw_minimal-objs := minimal.o +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c 2017-11-09 13:03:45.824833341 +0000 +@@ -113,6 +113,9 @@ + } lag; + struct mlxsw_resources resources; + struct mlxsw_hwmon *hwmon; ++ struct mlxsw_thermal *thermal; ++struct mlxsw_qsfp *qsfp; ++ struct mlxsw_core_port ports[MLXSW_PORT_MAX_PORTS]; + unsigned long driver_priv[0]; + /* driver_priv has to be always the last item */ + }; +@@ -579,6 +582,9 @@ + u64 tid; + int err; + ++ if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX)) ++ return 0; ++ + /* Set the upper 32 bits of the transaction ID field to a random + * number. This allows us to discard EMADs addressed to other + * devices. +@@ -615,6 +621,9 @@ + { + char hpkt_pl[MLXSW_REG_HPKT_LEN]; + ++ if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX)) ++ return; ++ + mlxsw_core->emad.use_emad = false; + mlxsw_reg_hpkt_pack(hpkt_pl, MLXSW_REG_HPKT_ACTION_DISCARD, + MLXSW_TRAP_ID_ETHEMAD); +@@ -1128,9 +1137,21 @@ + if (err) + goto err_hwmon_init; + +- err = mlxsw_driver->init(mlxsw_core, mlxsw_bus_info); ++ err = mlxsw_thermal_init(mlxsw_core, mlxsw_bus_info, ++ &mlxsw_core->thermal); + if (err) +- goto err_driver_init; ++ goto err_thermal_init; ++ ++ err = mlxsw_qsfp_init(mlxsw_core, mlxsw_bus_info, ++ &mlxsw_core->qsfp); ++ if (err) ++ goto err_qsfp_init; ++ ++ if (mlxsw_driver->init) { ++ err = mlxsw_driver->init(mlxsw_core, mlxsw_bus_info); ++ if (err) ++ goto err_driver_init; ++ } + + err = mlxsw_core_debugfs_init(mlxsw_core); + if (err) +@@ -1141,6 +1162,10 @@ + err_debugfs_init: + mlxsw_core->driver->fini(mlxsw_core); + err_driver_init: ++ mlxsw_qsfp_fini(mlxsw_core->qsfp); ++err_qsfp_init: ++ mlxsw_thermal_fini(mlxsw_core->thermal); ++err_thermal_init: + err_hwmon_init: + devlink_unregister(devlink); + err_devlink_register: +@@ -1165,7 +1190,10 @@ + struct devlink *devlink = priv_to_devlink(mlxsw_core); + + mlxsw_core_debugfs_fini(mlxsw_core); +- mlxsw_core->driver->fini(mlxsw_core); ++ if (mlxsw_core->driver->fini) ++ mlxsw_core->driver->fini(mlxsw_core); ++ mlxsw_qsfp_fini(mlxsw_core->qsfp); ++ mlxsw_thermal_fini(mlxsw_core->thermal); + devlink_unregister(devlink); + mlxsw_emad_fini(mlxsw_core); + mlxsw_core->bus->fini(mlxsw_core->bus_priv); +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h +--- a/drivers/net/ethernet/mellanox/mlxsw/core.h 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.h 2017-11-09 13:03:45.824833341 +0000 +@@ -300,6 +300,8 @@ + + struct mlxsw_resources *mlxsw_core_resources_get(struct mlxsw_core *mlxsw_core); + ++#define MLXSW_BUS_F_TXRX BIT(0) ++ + struct mlxsw_bus { + const char *kind; + int (*init)(void *bus_priv, struct mlxsw_core *mlxsw_core, +@@ -315,6 +317,7 @@ + char *in_mbox, size_t in_mbox_size, + char *out_mbox, size_t out_mbox_size, + u8 *p_status); ++ u8 features; + }; + + struct mlxsw_bus_info { +@@ -349,5 +352,53 @@ + } + + #endif ++ ++struct mlxsw_thermal; ++ ++#ifdef CONFIG_MLXSW_CORE_THERMAL ++ ++int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *mlxsw_bus_info, ++ struct mlxsw_thermal **p_thermal); ++void mlxsw_thermal_fini(struct mlxsw_thermal *thermal); ++ ++#else ++ ++static inline int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *mlxsw_bus_info, ++ struct mlxsw_thermal **p_thermal) ++{ ++ return 0; ++} ++ ++static inline void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) ++{ ++} ++ ++#endif ++ ++struct mlxsw_qsfp; ++ ++#ifdef CONFIG_MLXSW_CORE_QSFP ++ ++int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *mlxsw_bus_info, ++ struct mlxsw_qsfp **p_qsfp); ++void mlxsw_qsfp_fini(struct mlxsw_qsfp *qsfp); ++ ++#else ++ ++static inline int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *mlxsw_bus_info, ++ struct mlxsw_qsfp **p_qsfp) ++{ ++ return 0; ++} ++ ++static inline void mlxsw_qsfp_fini(struct mlxsw_qsfp *qsfp) ++{ ++} ++ ++#endif + + #endif +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c 2017-11-09 13:04:29.120833916 +0000 +@@ -262,7 +262,7 @@ + + static int mlxsw_hwmon_temp_init(struct mlxsw_hwmon *mlxsw_hwmon) + { +- char mtcap_pl[MLXSW_REG_MTCAP_LEN]; ++ char mtcap_pl[MLXSW_REG_MTCAP_LEN] = {0}; + char mtmp_pl[MLXSW_REG_MTMP_LEN]; + u8 sensor_count; + int i; +@@ -295,7 +295,7 @@ + + static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) + { +- char mfcr_pl[MLXSW_REG_MFCR_LEN]; ++ char mfcr_pl[MLXSW_REG_MFCR_LEN] = {0}; + enum mlxsw_reg_mfcr_pwm_frequency freq; + unsigned int type_index; + unsigned int num; +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c 2017-11-09 13:04:52.192834223 +0000 +@@ -0,0 +1,436 @@ ++/* ++ * drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++ * Copyright (c) 2016 Ivan Vecera ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "core.h" ++ ++#define MLXSW_THERMAL_POLL_INT 1000 /* ms */ ++#define MLXSW_THERMAL_MAX_TEMP 110000 /* 110C */ ++#define MLXSW_THERMAL_MAX_STATE 10 ++#define MLXSW_THERMAL_MAX_DUTY 255 ++ ++struct mlxsw_thermal_trip { ++ int type; ++ int temp; ++ int min_state; ++ int max_state; ++}; ++ ++static const struct mlxsw_thermal_trip default_thermal_trips[] = { ++ { /* Above normal - 60%-100% PWM */ ++ .type = THERMAL_TRIP_ACTIVE, ++ .temp = 75000, ++ .min_state = (6 * MLXSW_THERMAL_MAX_STATE) / 10, ++ .max_state = MLXSW_THERMAL_MAX_STATE, ++ }, ++ { ++ /* Very high - 100% PWM */ ++ .type = THERMAL_TRIP_ACTIVE, ++ .temp = 85000, ++ .min_state = MLXSW_THERMAL_MAX_STATE, ++ .max_state = MLXSW_THERMAL_MAX_STATE, ++ }, ++ { /* Warning */ ++ .type = THERMAL_TRIP_HOT, ++ .temp = 105000, ++ .min_state = MLXSW_THERMAL_MAX_STATE, ++ .max_state = MLXSW_THERMAL_MAX_STATE, ++ }, ++ { /* Critical - soft poweroff */ ++ .type = THERMAL_TRIP_CRITICAL, ++ .temp = MLXSW_THERMAL_MAX_TEMP, ++ .min_state = MLXSW_THERMAL_MAX_STATE, ++ .max_state = MLXSW_THERMAL_MAX_STATE, ++ } ++}; ++ ++#define MLXSW_THERMAL_NUM_TRIPS ARRAY_SIZE(default_thermal_trips) ++ ++/* Make sure all trips are writable */ ++#define MLXSW_THERMAL_TRIP_MASK (BIT(MLXSW_THERMAL_NUM_TRIPS) - 1) ++ ++struct mlxsw_thermal { ++ struct mlxsw_core *core; ++ const struct mlxsw_bus_info *bus_info; ++ struct thermal_zone_device *tzdev; ++ struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX]; ++ struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; ++ enum thermal_device_mode mode; ++}; ++ ++static inline u8 mlxsw_state_to_duty(int state) ++{ ++ return DIV_ROUND_CLOSEST(state * MLXSW_THERMAL_MAX_DUTY, ++ MLXSW_THERMAL_MAX_STATE); ++} ++ ++static inline int mlxsw_duty_to_state(u8 duty) ++{ ++ return DIV_ROUND_CLOSEST(duty * MLXSW_THERMAL_MAX_STATE, ++ MLXSW_THERMAL_MAX_DUTY); ++} ++ ++static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal, ++ struct thermal_cooling_device *cdev) ++{ ++ int i; ++ ++ for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) ++ if (thermal->cdevs[i] == cdev) ++ return i; ++ ++ return -ENODEV; ++} ++ ++static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev, ++ struct thermal_cooling_device *cdev) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ struct device *dev = thermal->bus_info->dev; ++ int i, err; ++ ++ /* If the cooling device is one of ours bind it */ ++ if (mlxsw_get_cooling_device_idx(thermal, cdev) < 0) ++ return 0; ++ ++ for (i = 0; i < MLXSW_THERMAL_NUM_TRIPS; i++) { ++ const struct mlxsw_thermal_trip *trip = &thermal->trips[i]; ++ ++ err = thermal_zone_bind_cooling_device(tzdev, i, cdev, ++ trip->max_state, ++ trip->min_state, ++ THERMAL_WEIGHT_DEFAULT); ++ if (err < 0) { ++ dev_err(dev, "Failed to bind cooling device to trip %d\n", i); ++ return err; ++ } ++ } ++ return 0; ++} ++ ++static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev, ++ struct thermal_cooling_device *cdev) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ struct device *dev = thermal->bus_info->dev; ++ int i; ++ int err; ++ ++ /* If the cooling device is our one unbind it */ ++ if (mlxsw_get_cooling_device_idx(thermal, cdev) < 0) ++ return 0; ++ ++ for (i = 0; i < MLXSW_THERMAL_NUM_TRIPS; i++) { ++ err = thermal_zone_unbind_cooling_device(tzdev, i, cdev); ++ if (err < 0) { ++ dev_err(dev, "Failed to unbind cooling device\n"); ++ return err; ++ } ++ } ++ return 0; ++} ++ ++static int mlxsw_thermal_get_mode(struct thermal_zone_device *tzdev, ++ enum thermal_device_mode *mode) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ ++ *mode = thermal->mode; ++ ++ return 0; ++} ++ ++static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev, ++ enum thermal_device_mode mode) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ ++ mutex_lock(&tzdev->lock); ++ ++ if (mode == THERMAL_DEVICE_ENABLED) ++ tzdev->polling_delay = MLXSW_THERMAL_POLL_INT; ++ else ++ tzdev->polling_delay = 0; ++ ++ mutex_unlock(&tzdev->lock); ++ ++ thermal->mode = mode; ++ thermal_zone_device_update(tzdev, THERMAL_EVENT_UNSPECIFIED); ++ ++ return 0; ++} ++ ++static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev, ++ int *p_temp) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ struct device *dev = thermal->bus_info->dev; ++ char mtmp_pl[MLXSW_REG_MTMP_LEN]; ++ unsigned int temp; ++ int err; ++ ++ mlxsw_reg_mtmp_pack(mtmp_pl, 0, false, false); ++ ++ err = mlxsw_reg_query(thermal->core, MLXSW_REG(mtmp), mtmp_pl); ++ if (err) { ++ dev_err(dev, "Failed to query temp sensor\n"); ++ return err; ++ } ++ mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL); ++ ++ *p_temp = (int) temp; ++ return 0; ++} ++ ++static int mlxsw_thermal_get_trip_type(struct thermal_zone_device *tzdev, ++ int trip, ++ enum thermal_trip_type *p_type) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ ++ if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) ++ return -EINVAL; ++ ++ *p_type = thermal->trips[trip].type; ++ return 0; ++} ++ ++static int mlxsw_thermal_get_trip_temp(struct thermal_zone_device *tzdev, ++ int trip, int *p_temp) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ ++ if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) ++ return -EINVAL; ++ ++ *p_temp = thermal->trips[trip].temp; ++ return 0; ++} ++ ++static int mlxsw_thermal_set_trip_temp(struct thermal_zone_device *tzdev, ++ int trip, int temp) ++{ ++ struct mlxsw_thermal *thermal = tzdev->devdata; ++ ++ if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS || ++ temp > MLXSW_THERMAL_MAX_TEMP) ++ return -EINVAL; ++ ++ thermal->trips[trip].temp = temp; ++ return 0; ++} ++ ++static struct thermal_zone_device_ops mlxsw_thermal_ops = { ++ .bind = mlxsw_thermal_bind, ++ .unbind = mlxsw_thermal_unbind, ++ .get_mode = mlxsw_thermal_get_mode, ++ .set_mode = mlxsw_thermal_set_mode, ++ .get_temp = mlxsw_thermal_get_temp, ++ .get_trip_type = mlxsw_thermal_get_trip_type, ++ .get_trip_temp = mlxsw_thermal_get_trip_temp, ++ .set_trip_temp = mlxsw_thermal_set_trip_temp, ++}; ++ ++static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev, ++ unsigned long *p_state) ++{ ++ *p_state = MLXSW_THERMAL_MAX_STATE; ++ return 0; ++} ++ ++static int mlxsw_thermal_get_cur_state(struct thermal_cooling_device *cdev, ++ unsigned long *p_state) ++ ++{ ++ struct mlxsw_thermal *thermal = cdev->devdata; ++ struct device *dev = thermal->bus_info->dev; ++ char mfsc_pl[MLXSW_REG_MFSC_LEN]; ++ int err, idx; ++ u8 duty; ++ ++ idx = mlxsw_get_cooling_device_idx(thermal, cdev); ++ if (idx < 0) ++ return idx; ++ ++ mlxsw_reg_mfsc_pack(mfsc_pl, idx, 0); ++ err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsc), mfsc_pl); ++ if (err) { ++ dev_err(dev, "Failed to query PWM duty\n"); ++ return err; ++ } ++ ++ duty = mlxsw_reg_mfsc_pwm_duty_cycle_get(mfsc_pl); ++ *p_state = mlxsw_duty_to_state(duty); ++ return 0; ++} ++ ++static int mlxsw_thermal_set_cur_state(struct thermal_cooling_device *cdev, ++ unsigned long state) ++ ++{ ++ struct mlxsw_thermal *thermal = cdev->devdata; ++ struct device *dev = thermal->bus_info->dev; ++ char mfsc_pl[MLXSW_REG_MFSC_LEN]; ++ int err, idx; ++ ++ idx = mlxsw_get_cooling_device_idx(thermal, cdev); ++ if (idx < 0) ++ return idx; ++ ++ mlxsw_reg_mfsc_pack(mfsc_pl, idx, mlxsw_state_to_duty(state)); ++ err = mlxsw_reg_write(thermal->core, MLXSW_REG(mfsc), mfsc_pl); ++ if (err) { ++ dev_err(dev, "Failed to write PWM duty\n"); ++ return err; ++ } ++ return 0; ++} ++ ++static const struct thermal_cooling_device_ops mlxsw_cooling_ops = { ++ .get_max_state = mlxsw_thermal_get_max_state, ++ .get_cur_state = mlxsw_thermal_get_cur_state, ++ .set_cur_state = mlxsw_thermal_set_cur_state, ++}; ++ ++int mlxsw_thermal_init(struct mlxsw_core *core, ++ const struct mlxsw_bus_info *bus_info, ++ struct mlxsw_thermal **p_thermal) ++{ ++ char mfcr_pl[MLXSW_REG_MFCR_LEN] = { 0 }; ++ enum mlxsw_reg_mfcr_pwm_frequency freq; ++ struct device *dev = bus_info->dev; ++ struct mlxsw_thermal *thermal; ++ u16 tacho_active; ++ u8 pwm_active; ++ int err, i; ++ ++ thermal = devm_kzalloc(dev, sizeof(*thermal), ++ GFP_KERNEL); ++ if (!thermal) ++ return -ENOMEM; ++ ++ thermal->core = core; ++ thermal->bus_info = bus_info; ++ memcpy(thermal->trips, default_thermal_trips, sizeof(thermal->trips)); ++ ++ err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl); ++ if (err) { ++ dev_err(dev, "Failed to probe PWMs\n"); ++ goto err_free_thermal; ++ } ++ mlxsw_reg_mfcr_unpack(mfcr_pl, &freq, &tacho_active, &pwm_active); ++ ++ for (i = 0; i < MLXSW_MFCR_TACHOS_MAX; i++) { ++ if (tacho_active & BIT(i)) { ++ char mfsl_pl[MLXSW_REG_MFSL_LEN]; ++ ++ mlxsw_reg_mfsl_pack(mfsl_pl, i, 0, 0); ++ ++ /* We need to query the register to preserve maximum */ ++ err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsl), ++ mfsl_pl); ++ if (err) ++ goto err_free_thermal; ++ ++ /* set the minimal RPMs to 0 */ ++ mlxsw_reg_mfsl_tach_min_set(mfsl_pl, 0); ++ err = mlxsw_reg_write(thermal->core, MLXSW_REG(mfsl), ++ mfsl_pl); ++ if (err) ++ goto err_free_thermal; ++ } ++ } ++ for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) { ++ if (pwm_active & BIT(i)) { ++ struct thermal_cooling_device *cdev; ++ ++ cdev = thermal_cooling_device_register("Fan", thermal, ++ &mlxsw_cooling_ops); ++ if (IS_ERR(cdev)) { ++ err = PTR_ERR(cdev); ++ dev_err(dev, "Failed to register cooling device\n"); ++ goto err_unreg_cdevs; ++ } ++ thermal->cdevs[i] = cdev; ++ } ++ } ++ ++ thermal->tzdev = thermal_zone_device_register("mlxsw", ++ MLXSW_THERMAL_NUM_TRIPS, ++ MLXSW_THERMAL_TRIP_MASK, ++ thermal, ++ &mlxsw_thermal_ops, ++ NULL, 0, ++ MLXSW_THERMAL_POLL_INT); ++ if (IS_ERR(thermal->tzdev)) { ++ err = PTR_ERR(thermal->tzdev); ++ dev_err(dev, "Failed to register thermal zone\n"); ++ goto err_unreg_cdevs; ++ } ++ ++ thermal->mode = THERMAL_DEVICE_ENABLED; ++ *p_thermal = thermal; ++ return 0; ++err_unreg_cdevs: ++ for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) ++ if (thermal->cdevs[i]) ++ thermal_cooling_device_unregister(thermal->cdevs[i]); ++err_free_thermal: ++ devm_kfree(dev, thermal); ++ return err; ++} ++ ++void mlxsw_thermal_fini(struct mlxsw_thermal *thermal) ++{ ++ int i; ++ ++ if (thermal->tzdev) { ++ thermal_zone_device_unregister(thermal->tzdev); ++ thermal->tzdev = NULL; ++ } ++ ++ for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++) { ++ if (thermal->cdevs[i]) { ++ thermal_cooling_device_unregister(thermal->cdevs[i]); ++ thermal->cdevs[i] = NULL; ++ } ++ } ++ ++ devm_kfree(thermal->bus_info->dev, thermal); ++} +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c +--- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c 2017-11-09 13:04:29.120833916 +0000 +@@ -0,0 +1,582 @@ ++/* ++ * drivers/net/ethernet/mellanox/mlxsw/i2c.c ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "cmd.h" ++#include "core.h" ++#include "i2c.h" ++ ++static const char mlxsw_i2c_driver_name[] = "mlxsw_i2c"; ++ ++#define MLXSW_I2C_CIR2_BASE 0x72000 ++#define MLXSW_I2C_CIR_STATUS_OFF 0x18 ++#define MLXSW_I2C_CIR2_OFF_STATUS (MLXSW_I2C_CIR2_BASE + \ ++ MLXSW_I2C_CIR_STATUS_OFF) ++#define MLXSW_I2C_OPMOD_SHIFT 12 ++#define MLXSW_I2C_GO_BIT_SHIFT 23 ++#define MLXSW_I2C_CIR_CTRL_STATUS_SHIFT 24 ++#define MLXSW_I2C_GO_BIT BIT(MLXSW_I2C_GO_BIT_SHIFT) ++#define MLXSW_I2C_GO_OPMODE BIT(MLXSW_I2C_OPMOD_SHIFT) ++#define MLXSW_I2C_SET_IMM_CMD (MLXSW_I2C_GO_OPMODE | \ ++ MLXSW_CMD_OPCODE_QUERY_FW) ++#define MLXSW_I2C_PUSH_IMM_CMD (MLXSW_I2C_GO_BIT | \ ++ MLXSW_I2C_SET_IMM_CMD) ++#define MLXSW_I2C_SET_CMD (MLXSW_CMD_OPCODE_ACCESS_REG) ++#define MLXSW_I2C_PUSH_CMD (MLXSW_I2C_GO_BIT | MLXSW_I2C_SET_CMD) ++#define MLXSW_I2C_TLV_HDR_SIZE 0x10 ++#define MLXSW_I2C_ADDR_WIDTH 4 ++#define MLXSW_I2C_PUSH_CMD_SIZE (MLXSW_I2C_ADDR_WIDTH + 4) ++#define MLXSW_I2C_READ_SEMA_SIZE 4 ++#define MLXSW_I2C_PREP_SIZE (MLXSW_I2C_ADDR_WIDTH + 28) ++#define MLXSW_I2C_MBOX_SIZE 20 ++#define MLXSW_I2C_MBOX_OUT_PARAM_OFF 12 ++#define MLXSW_I2C_MAX_BUFF_SIZE 32 ++#define MLXSW_I2C_MBOX_OFFSET_BITS 20 ++#define MLXSW_I2C_MBOX_SIZE_BITS 12 ++#define MLXSW_I2C_ADDR_BUF_SIZE 4 ++#define MLXSW_I2C_BLK_MAX 32 ++#define MLXSW_I2C_RETRY 5 ++#define MLXSW_I2C_TIMEOUT_MSECS 5000 ++ ++/** ++ * struct mlxsw_i2c - device private data: ++ * @cmd.mb_size_in: input mailbox size; ++ * @cmd.mb_off_in: input mailbox offset in register space; ++ * @cmd.mb_size_out: output mailbox size; ++ * @cmd.mb_off_out: output mailbox offset in register space; ++ * @cmd.lock: command execution lock; ++ * @dev: I2C device; ++ * @core: switch core pointer; ++ * @bus_info: bus info block; ++ */ ++struct mlxsw_i2c { ++ struct { ++ u32 mb_size_in; ++ u32 mb_off_in; ++ u32 mb_size_out; ++ u32 mb_off_out; ++ struct mutex lock; ++ } cmd; ++ struct device *dev; ++ struct mlxsw_core *core; ++ struct mlxsw_bus_info bus_info; ++}; ++ ++#define MLXSW_I2C_READ_MSG(_client, _addr_buf, _buf, _len) { \ ++ { .addr = (_client)->addr, \ ++ .buf = (_addr_buf), \ ++ .len = MLXSW_I2C_ADDR_BUF_SIZE, \ ++ .flags = 0 }, \ ++ { .addr = (_client)->addr, \ ++ .buf = (_buf), \ ++ .len = (_len), \ ++ .flags = I2C_M_RD } } ++ ++#define MLXSW_I2C_WRITE_MSG(_client, _buf, _len) \ ++ { .addr = (_client)->addr, \ ++ .buf = (u8 *)(_buf), \ ++ .len = (_len), \ ++ .flags = 0 } ++ ++/* Routine converts in and out mail boxes offset and size. */ ++static inline void ++mlxsw_i2c_convert_mbox(struct mlxsw_i2c *mlxsw_i2c, u8 *buf) ++{ ++ u32 tmp; ++ ++ /* Local in/out mailboxes: 20 bits for offset, 12 for size */ ++ tmp = be32_to_cpup((__be32 *) buf); ++ mlxsw_i2c->cmd.mb_off_in = tmp & ++ GENMASK(MLXSW_I2C_MBOX_OFFSET_BITS - 1, 0); ++ mlxsw_i2c->cmd.mb_size_in = (tmp & GENMASK(31, ++ MLXSW_I2C_MBOX_OFFSET_BITS)) >> ++ MLXSW_I2C_MBOX_OFFSET_BITS; ++ ++ tmp = be32_to_cpup((__be32 *) (buf + MLXSW_I2C_ADDR_WIDTH)); ++ mlxsw_i2c->cmd.mb_off_out = tmp & ++ GENMASK(MLXSW_I2C_MBOX_OFFSET_BITS - 1, 0); ++ mlxsw_i2c->cmd.mb_size_out = (tmp & GENMASK(31, ++ MLXSW_I2C_MBOX_OFFSET_BITS)) >> ++ MLXSW_I2C_MBOX_OFFSET_BITS; ++} ++ ++/* Routine obtains register size from mail box buffer. */ ++static inline int mlxsw_i2c_get_reg_size(u8 *in_mbox) ++{ ++ u16 tmp = be16_to_cpup((__be16 *) (in_mbox + MLXSW_I2C_TLV_HDR_SIZE)); ++ ++ return (tmp & 0x7ff) * 4 + MLXSW_I2C_TLV_HDR_SIZE; ++} ++ ++/* Routine sets I2C device internal offset in the transaction buffer. */ ++static inline void mlxsw_i2c_set_slave_addr(u8 *buf, u32 off) ++{ ++ __be32 *val = (__be32 *) buf; ++ ++ *val = htonl(off); ++} ++ ++/* Routine waits until go bit is cleared. */ ++static int mlxsw_i2c_wait_go_bit(struct i2c_client *client, ++ struct mlxsw_i2c *mlxsw_i2c, u8 *p_status) ++{ ++ u8 addr_buf[MLXSW_I2C_ADDR_BUF_SIZE]; ++ u8 buf[MLXSW_I2C_READ_SEMA_SIZE]; ++ int len = MLXSW_I2C_READ_SEMA_SIZE; ++ struct i2c_msg read_sema[] = ++ MLXSW_I2C_READ_MSG(client, addr_buf, buf, len); ++ bool wait_done = false; ++ unsigned long end; ++ int i = 0, err; ++ ++ mlxsw_i2c_set_slave_addr(addr_buf, MLXSW_I2C_CIR2_OFF_STATUS); ++ ++ end = jiffies + msecs_to_jiffies(MLXSW_I2C_TIMEOUT_MSECS); ++ do { ++ u32 ctrl; ++ ++ err = i2c_transfer(client->adapter, read_sema, ++ ARRAY_SIZE(read_sema)); ++ ++ ctrl = be32_to_cpu(*(__be32 *) buf); ++ if (err == ARRAY_SIZE(read_sema)) { ++ if (!(ctrl & MLXSW_I2C_GO_BIT)) { ++ wait_done = true; ++ *p_status = ctrl >> ++ MLXSW_I2C_CIR_CTRL_STATUS_SHIFT; ++ break; ++ } ++ } ++ cond_resched(); ++ } while ((time_before(jiffies, end)) || (i++ < MLXSW_I2C_RETRY)); ++ ++ if (wait_done) { ++ if (*p_status) ++ err = -EIO; ++ } else { ++ return -ETIMEDOUT; ++ } ++ ++ return err > 0 ? 0 : err; ++} ++ ++/* Routine posts a command to ASIC though mail box. */ ++static int mlxsw_i2c_write_cmd(struct i2c_client *client, ++ struct mlxsw_i2c *mlxsw_i2c, ++ int immediate) ++{ ++ __be32 push_cmd_buf[MLXSW_I2C_PUSH_CMD_SIZE / 4] = { ++ 0, cpu_to_be32(MLXSW_I2C_PUSH_IMM_CMD) ++ }; ++ __be32 prep_cmd_buf[MLXSW_I2C_PREP_SIZE / 4] = { ++ 0, 0, 0, 0, 0, 0, ++ cpu_to_be32(client->adapter->nr & 0xffff), ++ cpu_to_be32(MLXSW_I2C_SET_IMM_CMD) ++ }; ++ struct i2c_msg push_cmd = ++ MLXSW_I2C_WRITE_MSG(client, push_cmd_buf, ++ MLXSW_I2C_PUSH_CMD_SIZE); ++ struct i2c_msg prep_cmd = ++ MLXSW_I2C_WRITE_MSG(client, prep_cmd_buf, MLXSW_I2C_PREP_SIZE); ++ int err; ++ ++ if (!immediate) { ++ push_cmd_buf[1] = cpu_to_be32(MLXSW_I2C_PUSH_CMD); ++ prep_cmd_buf[7] = cpu_to_be32(MLXSW_I2C_SET_CMD); ++ } ++ mlxsw_i2c_set_slave_addr((u8 *)prep_cmd_buf, ++ MLXSW_I2C_CIR2_BASE); ++ mlxsw_i2c_set_slave_addr((u8 *)push_cmd_buf, ++ MLXSW_I2C_CIR2_OFF_STATUS); ++ ++ /* Prepare Command Interface Register for transaction */ ++ err = i2c_transfer(client->adapter, &prep_cmd, 1); ++ if (err < 0) ++ return err; ++ else if (err != 1) ++ return -EIO; ++ ++ /* Write out Command Interface Register GO bit to push transaction */ ++ err = i2c_transfer(client->adapter, &push_cmd, 1); ++ if (err < 0) ++ return err; ++ else if (err != 1) ++ return -EIO; ++ ++ return 0; ++} ++ ++/* Routine obtains mail box offsets from ASIC register space. */ ++static int mlxsw_i2c_get_mbox(struct i2c_client *client, ++ struct mlxsw_i2c *mlxsw_i2c) ++{ ++ u8 addr_buf[MLXSW_I2C_ADDR_BUF_SIZE]; ++ u8 buf[MLXSW_I2C_MBOX_SIZE]; ++ struct i2c_msg mbox_cmd[] = ++ MLXSW_I2C_READ_MSG(client, addr_buf, buf, MLXSW_I2C_MBOX_SIZE); ++ int err; ++ ++ /* Read mail boxes offsets. */ ++ mlxsw_i2c_set_slave_addr(addr_buf, MLXSW_I2C_CIR2_BASE); ++ err = i2c_transfer(client->adapter, mbox_cmd, 2); ++ if (err != 2) { ++ dev_err(&client->dev, "Could not obtain mail boxes\n"); ++ if (!err) ++ return -EIO; ++ else ++ return err; ++ } ++ ++ /* Convert mail boxes. */ ++ mlxsw_i2c_convert_mbox(mlxsw_i2c, &buf[MLXSW_I2C_MBOX_OUT_PARAM_OFF]); ++ ++ return err; ++} ++ ++/* Routine sends I2C write transaction to ASIC device. */ ++static int ++mlxsw_i2c_write(struct device *dev, size_t in_mbox_size, u8 *in_mbox, int num, ++ u8 *p_status) ++{ ++ struct i2c_client *client = to_i2c_client(dev); ++ struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); ++ unsigned long timeout = msecs_to_jiffies(MLXSW_I2C_TIMEOUT_MSECS); ++ u8 tran_buf[MLXSW_I2C_MAX_BUFF_SIZE + MLXSW_I2C_ADDR_BUF_SIZE]; ++ int off = mlxsw_i2c->cmd.mb_off_in, chunk_size, i, j; ++ unsigned long end; ++ struct i2c_msg write_tran = ++ MLXSW_I2C_WRITE_MSG(client, tran_buf, MLXSW_I2C_PUSH_CMD_SIZE); ++ int err; ++ ++ for (i = 0; i < num; i++) { ++ chunk_size = (in_mbox_size > MLXSW_I2C_BLK_MAX) ? ++ MLXSW_I2C_BLK_MAX : in_mbox_size; ++ write_tran.len = MLXSW_I2C_ADDR_WIDTH + chunk_size; ++ mlxsw_i2c_set_slave_addr(tran_buf, off); ++ memcpy(&tran_buf[MLXSW_I2C_ADDR_BUF_SIZE], in_mbox + ++ MLXSW_I2C_BLK_MAX * i, chunk_size); ++ ++ j = 0; ++ end = jiffies + timeout; ++ do { ++ err = i2c_transfer(client->adapter, &write_tran, 1); ++ if (err == 1) ++ break; ++ ++ cond_resched(); ++ } while ((time_before(jiffies, end)) || ++ (j++ < MLXSW_I2C_RETRY)); ++ ++ if (err != 1) { ++ if (!err) ++ err = -EIO; ++ return err; ++ } ++ ++ off += chunk_size; ++ in_mbox_size -= chunk_size; ++ } ++ ++ /* Prepare and write out Command Interface Register for transaction. */ ++ err = mlxsw_i2c_write_cmd(client, mlxsw_i2c, 0); ++ if (err) { ++ dev_err(&client->dev, "Could not start transaction"); ++ return -EIO; ++ } ++ ++ /* Wait until go bit is cleared. */ ++ err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, p_status); ++ if (err) { ++ dev_err(&client->dev, "HW semaphore is not released"); ++ return err; ++ } ++ ++ /* Validate transaction completion status. */ ++ if (*p_status) { ++ dev_err(&client->dev, "Bad transaction completion status %x\n", ++ *p_status); ++ return -EIO; ++ } ++ ++ return 0; ++} ++ ++/* Routine executes I2C command. */ ++static int ++mlxsw_i2c_cmd(struct device *dev, size_t in_mbox_size, u8 *in_mbox, ++ size_t out_mbox_size, u8 *out_mbox, u8 *status) ++{ ++ struct i2c_client *client = to_i2c_client(dev); ++ struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); ++ unsigned long timeout = msecs_to_jiffies(MLXSW_I2C_TIMEOUT_MSECS); ++ u8 tran_buf[MLXSW_I2C_ADDR_BUF_SIZE]; ++ int num, chunk_size, reg_size, i, j; ++ int off = mlxsw_i2c->cmd.mb_off_out; ++ unsigned long end; ++ struct i2c_msg read_tran[] = ++ MLXSW_I2C_READ_MSG(client, tran_buf, NULL, 0); ++ int err; ++ ++ WARN_ON(in_mbox_size % sizeof(u32) || out_mbox_size % sizeof(u32)); ++ ++ reg_size = mlxsw_i2c_get_reg_size(in_mbox); ++ num = reg_size / MLXSW_I2C_BLK_MAX; ++ if (reg_size % MLXSW_I2C_BLK_MAX) ++ num++; ++ ++ if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) { ++ dev_err(&client->dev, "Could not acquire lock"); ++ return -EINVAL; ++ } ++ ++ err = mlxsw_i2c_write(dev, reg_size, in_mbox, num, status); ++ if (err) ++ goto cmd_fail; ++ ++ /* No out mailbox is case of write transaction. */ ++ if (!out_mbox) { ++ mutex_unlock(&mlxsw_i2c->cmd.lock); ++ return 0; ++ } ++ ++ /* Send read transaction to get output mailbox content. */ ++ read_tran[1].buf = out_mbox; ++ for (i = 0; i < num; i++) { ++ chunk_size = (reg_size > MLXSW_I2C_BLK_MAX) ? ++ MLXSW_I2C_BLK_MAX : reg_size; ++ read_tran[1].len = chunk_size; ++ mlxsw_i2c_set_slave_addr(tran_buf, off); ++ ++ j = 0; ++ end = jiffies + timeout; ++ do { ++ err = i2c_transfer(client->adapter, read_tran, ++ ARRAY_SIZE(read_tran)); ++ if (err == ARRAY_SIZE(read_tran)) ++ break; ++ ++ cond_resched(); ++ } while ((time_before(jiffies, end)) || ++ (j++ < MLXSW_I2C_RETRY)); ++ ++ if (err != ARRAY_SIZE(read_tran)) { ++ if (!err) ++ err = -EIO; ++ ++ goto cmd_fail; ++ } ++ ++ off += chunk_size; ++ reg_size -= chunk_size; ++ read_tran[1].buf += chunk_size; ++ } ++ ++ mutex_unlock(&mlxsw_i2c->cmd.lock); ++ ++ return 0; ++ ++cmd_fail: ++ mutex_unlock(&mlxsw_i2c->cmd.lock); ++ return err; ++} ++ ++static int mlxsw_i2c_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod, ++ u32 in_mod, bool out_mbox_direct, ++ char *in_mbox, size_t in_mbox_size, ++ char *out_mbox, size_t out_mbox_size, ++ u8 *status) ++{ ++ struct mlxsw_i2c *mlxsw_i2c = bus_priv; ++ ++ return mlxsw_i2c_cmd(mlxsw_i2c->dev, in_mbox_size, in_mbox, ++ out_mbox_size, out_mbox, status); ++} ++ ++static bool mlxsw_i2c_skb_transmit_busy(void *bus_priv, ++ const struct mlxsw_tx_info *tx_info) ++{ ++ return false; ++} ++ ++static int mlxsw_i2c_skb_transmit(void *bus_priv, struct sk_buff *skb, ++ const struct mlxsw_tx_info *tx_info) ++{ ++ return 0; ++} ++ ++static int ++mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_config_profile *profile, ++ struct mlxsw_resources *resources) ++{ ++ struct mlxsw_i2c *mlxsw_i2c = bus_priv; ++ ++ mlxsw_i2c->core = mlxsw_core; ++ ++ return 0; ++} ++ ++static void mlxsw_i2c_fini(void *bus_priv) ++{ ++ struct mlxsw_i2c *mlxsw_i2c = bus_priv; ++ ++ mlxsw_i2c->core = NULL; ++} ++ ++static const struct mlxsw_bus mlxsw_i2c_bus = { ++ .kind = "i2c", ++ .init = mlxsw_i2c_init, ++ .fini = mlxsw_i2c_fini, ++ .skb_transmit_busy = mlxsw_i2c_skb_transmit_busy, ++ .skb_transmit = mlxsw_i2c_skb_transmit, ++ .cmd_exec = mlxsw_i2c_cmd_exec, ++}; ++ ++static int mlxsw_i2c_probe(struct i2c_client *client, ++ const struct i2c_device_id *id) ++{ ++ struct mlxsw_i2c *mlxsw_i2c; ++ u8 status; ++ int err; ++ ++ mlxsw_i2c = devm_kzalloc(&client->dev, sizeof(*mlxsw_i2c), GFP_KERNEL); ++ if (!mlxsw_i2c) ++ return -ENOMEM; ++ ++ i2c_set_clientdata(client, mlxsw_i2c); ++ mutex_init(&mlxsw_i2c->cmd.lock); ++ ++ /* In order to use mailboxes through the i2c, special area is reserved ++ * on the i2c address space that can be used for input and output ++ * mailboxes. Such mailboxes are called local mailboxes. When using a ++ * local mailbox, software should specify 0 as the Input/Output ++ * parameters. The location of the Local Mailbox addresses on the i2c ++ * space can be retrieved through the QUERY_FW command. ++ * For this purpose QUERY_FW is to be issued with opcode modifier equal ++ * 0x01. For such command the output parameter is an immediate value. ++ * Here QUERY_FW command is invoked for ASIC probing and for getting ++ * local mailboxes addresses from immedate output parameters. ++ */ ++ ++ /* Prepare and write out Command Interface Register for transaction */ ++ err = mlxsw_i2c_write_cmd(client, mlxsw_i2c, 1); ++ if (err) { ++ dev_err(&client->dev, "Could not start transaction"); ++ goto errout; ++ } ++ ++ /* Wait until go bit is cleared. */ ++ err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, &status); ++ if (err) { ++ dev_err(&client->dev, "HW semaphore is not released"); ++ goto errout; ++ } ++ ++ /* Validate transaction completion status. */ ++ if (status) { ++ dev_err(&client->dev, "Bad transaction completion status %x\n", ++ status); ++ err = -EIO; ++ goto errout; ++ } ++ ++ /* Get mailbox offsets. */ ++ err = mlxsw_i2c_get_mbox(client, mlxsw_i2c); ++ if (err < 0) { ++ dev_err(&client->dev, "Fail to get mailboxes\n"); ++ goto errout; ++ } ++ ++ dev_info(&client->dev, "%s mb size=%x off=0x%08x out mb size=%x off=0x%08x\n", ++ id->name, mlxsw_i2c->cmd.mb_size_in, ++ mlxsw_i2c->cmd.mb_off_in, mlxsw_i2c->cmd.mb_size_out, ++ mlxsw_i2c->cmd.mb_off_out); ++ ++ /* Register device bus. */ ++ mlxsw_i2c->bus_info.device_kind = id->name; ++ mlxsw_i2c->bus_info.device_name = client->name; ++ mlxsw_i2c->bus_info.dev = &client->dev; ++ mlxsw_i2c->dev = &client->dev; ++ ++ err = mlxsw_core_bus_device_register(&mlxsw_i2c->bus_info, ++ &mlxsw_i2c_bus, mlxsw_i2c); ++ if (err) { ++ dev_err(&client->dev, "Fail to register core bus\n"); ++ return err; ++ } ++ ++ return 0; ++ ++errout: ++ i2c_set_clientdata(client, NULL); ++ ++ return err; ++} ++ ++static int mlxsw_i2c_remove(struct i2c_client *client) ++{ ++ struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); ++ ++ mlxsw_core_bus_device_unregister(mlxsw_i2c->core); ++ mutex_destroy(&mlxsw_i2c->cmd.lock); ++ ++ return 0; ++} ++ ++int mlxsw_i2c_driver_register(struct i2c_driver *i2c_driver) ++{ ++ i2c_driver->probe = mlxsw_i2c_probe; ++ i2c_driver->remove = mlxsw_i2c_remove; ++ return i2c_add_driver(i2c_driver); ++} ++EXPORT_SYMBOL(mlxsw_i2c_driver_register); ++ ++void mlxsw_i2c_driver_unregister(struct i2c_driver *i2c_driver) ++{ ++ i2c_del_driver(i2c_driver); ++} ++EXPORT_SYMBOL(mlxsw_i2c_driver_unregister); ++ ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox switch I2C interface driver"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/i2c.h b/drivers/net/ethernet/mellanox/mlxsw/i2c.h +--- a/drivers/net/ethernet/mellanox/mlxsw/i2c.h 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.h 2017-11-09 12:03:09.944785064 +0000 +@@ -0,0 +1,60 @@ ++/* ++ * drivers/net/ethernet/mellanox/mlxsw/i2c.h ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef _MLXSW_I2C_H ++#define _MLXSW_I2C_H ++ ++#include ++ ++#if IS_ENABLED(CONFIG_MLXSW_I2C) ++ ++int mlxsw_i2c_driver_register(struct i2c_driver *i2c_driver); ++void mlxsw_i2c_driver_unregister(struct i2c_driver *i2c_driver); ++ ++#else ++ ++static inline int ++mlxsw_i2c_driver_register(struct i2c_driver *i2c_driver) ++{ ++ return -ENODEV; ++} ++ ++static inline void ++mlxsw_i2c_driver_unregister(struct i2c_driver *i2c_driver) ++{ ++} ++ ++#endif ++ ++#endif +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c 2017-11-09 12:03:23.332785242 +0000 +@@ -0,0 +1,97 @@ ++/* ++ * drivers/net/ethernet/mellanox/mlxsw/minimal.c ++ * Copyright (c) 2016 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "core.h" ++#include "i2c.h" ++ ++static const char mlxsw_minimal_driver_name[] = "mlxsw_minimal"; ++ ++static const struct mlxsw_config_profile mlxsw_minimal_config_profile; ++ ++static struct mlxsw_driver mlxsw_minimal_driver = { ++ .kind = mlxsw_minimal_driver_name, ++ .priv_size = 1, ++ .profile = &mlxsw_minimal_config_profile, ++}; ++ ++static const struct i2c_device_id mlxsw_minimal_i2c_id[] = { ++ { "mlxsw_minimal", 0}, ++ { }, ++}; ++ ++static struct i2c_driver mlxsw_minimal_i2c_driver = { ++ .driver.name = "mlxsw_minimal", ++ .class = I2C_CLASS_HWMON, ++ .id_table = mlxsw_minimal_i2c_id, ++}; ++ ++static int __init mlxsw_minimal_module_init(void) ++{ ++ int err; ++ ++ err = mlxsw_core_driver_register(&mlxsw_minimal_driver); ++ if (err) ++ return err; ++ ++ err = mlxsw_i2c_driver_register(&mlxsw_minimal_i2c_driver); ++ if (err) ++ goto err_i2c_driver_register; ++ ++ return 0; ++ ++err_i2c_driver_register: ++ mlxsw_core_driver_unregister(&mlxsw_minimal_driver); ++ ++ return err; ++} ++ ++static void __exit mlxsw_minimal_module_exit(void) ++{ ++ mlxsw_i2c_driver_unregister(&mlxsw_minimal_i2c_driver); ++ mlxsw_core_driver_unregister(&mlxsw_minimal_driver); ++} ++ ++module_init(mlxsw_minimal_module_init); ++module_exit(mlxsw_minimal_module_exit); ++ ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox minimal driver"); ++MODULE_DEVICE_TABLE(i2c, mlxsw_minimal_i2c_id); +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c +--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c 2017-11-09 13:03:45.824833341 +0000 +@@ -1836,6 +1836,7 @@ + .skb_transmit_busy = mlxsw_pci_skb_transmit_busy, + .skb_transmit = mlxsw_pci_skb_transmit, + .cmd_exec = mlxsw_pci_cmd_exec, ++ .features = MLXSW_BUS_F_TXRX, + }; + + static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci, +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c b/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c +--- a/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c 2017-11-09 13:04:52.192834223 +0000 +@@ -0,0 +1,379 @@ ++/* ++ * drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c ++ * Copyright (c) 2017 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2017 Vadim Pasternak ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the names of the copyright holders nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * Alternatively, this software may be distributed under the terms of the ++ * GNU General Public License ("GPL") version 2 as published by the Free ++ * Software Foundation. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ++ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "core.h" ++ ++#define MLXSW_QSFP_I2C_ADDR 0x50 ++#define MLXSW_QSFP_PAGE_NUM 5 ++#define MLXSW_QSFP_PAGE_SIZE 128 ++#define MLXSW_QSFP_SUB_PAGE_NUM 3 ++#define MLXSW_QSFP_SUB_PAGE_SIZE 48 ++#define MLXSW_QSFP_LAST_SUB_PAGE_SIZE 32 ++#define MLXSW_QSFP_MAX_NUM 64 ++#define MLXSW_QSFP_MIN_REQ_LEN 4 ++#define MLXSW_QSFP_STATUS_VALID_TIME (120 * HZ) ++#define MLXSW_QSFP_MAX_CPLD_NUM 1 ++ ++static const u8 mlxsw_qsfp_page_number[] = { 0xa0, 0x00, 0x01, 0x02, 0x03 }; ++static const u16 mlxsw_qsfp_page_shift[] = { 0x00, 0x80, 0x80, 0x80, 0x80 }; ++ ++/** ++ * Mellanox device Management Cable Info Access Register buffer for reading ++ * QSFP EEPROM info is limited by 48 bytes. In case full page is to be read ++ * (128 bytes), such request will be implemented by three transactions of size ++ * 48, 48, 32. ++ */ ++static const u16 mlxsw_qsfp_sub_page_size[] = { ++ MLXSW_QSFP_SUB_PAGE_SIZE, ++ MLXSW_QSFP_SUB_PAGE_SIZE, ++ MLXSW_QSFP_LAST_SUB_PAGE_SIZE ++}; ++ ++struct mlxsw_qsfp_module { ++ unsigned long last_updated; ++ u8 cache_status; ++}; ++ ++struct mlxsw_qsfp { ++ struct mlxsw_core *core; ++ const struct mlxsw_bus_info *bus_info; ++ struct attribute *attrs[MLXSW_QSFP_MAX_NUM + 1]; ++ struct device_attribute *dev_attrs; ++ struct bin_attribute *eeprom; ++ struct bin_attribute **eeprom_attr_list; ++ struct mlxsw_qsfp_module modules[MLXSW_QSFP_MAX_NUM]; ++ u8 module_ind[MLXSW_QSFP_MAX_NUM]; ++ u8 module_count; ++ struct attribute *cpld_attrs[MLXSW_QSFP_MAX_CPLD_NUM + 1]; ++ struct device_attribute *cpld_dev_attrs; ++}; ++ ++static int ++mlxsw_qsfp_query_module_eeprom(struct mlxsw_qsfp *mlxsw_qsfp, u8 index, ++ loff_t off, size_t count, int page, char *buf) ++{ ++ char eeprom_tmp[MLXSW_QSFP_PAGE_SIZE]; ++ char mcia_pl[MLXSW_REG_MCIA_LEN]; ++ int status; ++ int err; ++ ++ mlxsw_reg_mcia_pack(mcia_pl, index, 0, page, off, count, ++ MLXSW_QSFP_I2C_ADDR); ++ ++ err = mlxsw_reg_query(mlxsw_qsfp->core, MLXSW_REG(mcia), mcia_pl); ++ if (err) ++ return err; ++ ++ status = mlxsw_reg_mcia_status_get(mcia_pl); ++ if (status) ++ return -EIO; ++ ++ mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp); ++ memcpy(buf, eeprom_tmp, count); ++ ++ return 0; ++} ++ ++static int ++mlxsw_qsfp_get_module_eeprom(struct mlxsw_qsfp *mlxsw_qsfp, u8 index, ++ char *buf, loff_t off, size_t count) ++{ ++ int page_ind, page, page_off, subpage, offset, size, res = 0; ++ int err; ++ ++ if (!count) ++ return -EINVAL; ++ ++ memset(buf, 0, count); ++ size = count; ++ while (res < count) { ++ page_ind = off / MLXSW_QSFP_PAGE_SIZE; ++ page_off = off % MLXSW_QSFP_PAGE_SIZE; ++ page = mlxsw_qsfp_page_number[page_ind]; ++ offset = mlxsw_qsfp_page_shift[page_ind] + page_off; ++ subpage = page_off / MLXSW_QSFP_SUB_PAGE_SIZE; ++ size = min_t(u16, size, mlxsw_qsfp_sub_page_size[subpage]); ++ err = mlxsw_qsfp_query_module_eeprom(mlxsw_qsfp, index, offset, ++ size, page, buf + res); ++ if (err) { ++ dev_err(mlxsw_qsfp->bus_info->dev, "Eeprom query failed\n"); ++ return err; ++ } ++ off += size; ++ res += size; ++ size = count - size; ++ } ++ ++ return res; ++} ++ ++static ssize_t mlxsw_qsfp_bin_read(struct file *filp, struct kobject *kobj, ++ struct bin_attribute *attr, char *buf, ++ loff_t off, size_t count) ++{ ++ struct mlxsw_qsfp *mlxsw_qsfp = dev_get_platdata(container_of(kobj, ++ struct device, kobj)); ++ u8 *module_ind = attr->private; ++ size_t size; ++ ++ size = mlxsw_qsfp->eeprom[*module_ind].size; ++ ++ if (off > size) ++ return -ESPIPE; ++ else if (off == size) ++ return 0; ++ else if ((off + count) > size) ++ count = size - off; ++ ++ return mlxsw_qsfp_get_module_eeprom(mlxsw_qsfp, *module_ind, buf, off, ++ count); ++} ++ ++static ssize_t ++mlxsw_qsfp_status_show(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ struct mlxsw_qsfp *mlxsw_qsfp = dev_get_platdata(dev); ++ char mcia_pl[MLXSW_REG_MCIA_LEN]; ++ int status; ++ u32 i; ++ int err; ++ ++ for (i = 0; i < mlxsw_qsfp->module_count; i++) { ++ if ((mlxsw_qsfp->dev_attrs + i) == attr) ++ break; ++ } ++ if (i == mlxsw_qsfp->module_count) ++ return -EINVAL; ++ ++ if (time_before(jiffies, mlxsw_qsfp->modules[i].last_updated + ++ MLXSW_QSFP_STATUS_VALID_TIME)) ++ return sprintf(buf, "%u\n", ++ mlxsw_qsfp->modules[i].cache_status); ++ ++ mlxsw_reg_mcia_pack(mcia_pl, i, 0, 0, 0, MLXSW_QSFP_MIN_REQ_LEN, ++ MLXSW_QSFP_I2C_ADDR); ++ err = mlxsw_reg_query(mlxsw_qsfp->core, MLXSW_REG(mcia), mcia_pl); ++ if (err) ++ return err; ++ ++ status = mlxsw_reg_mcia_status_get(mcia_pl); ++ mlxsw_qsfp->modules[i].cache_status = !status; ++ mlxsw_qsfp->modules[i].last_updated = jiffies; ++ ++ return sprintf(buf, "%u\n", !status); ++} ++ ++static ssize_t ++mlxsw_qsfp_cpld_show(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ struct mlxsw_qsfp *mlxsw_qsfp = dev_get_platdata(dev); ++ char msci_pl[MLXSW_REG_MSCI_LEN]; ++ u32 version, i; ++ int err; ++ ++ for (i = 0; i < MLXSW_QSFP_MAX_CPLD_NUM; i++) { ++ if ((mlxsw_qsfp->cpld_dev_attrs + i) == attr) ++ break; ++ } ++ if (i == MLXSW_QSFP_MAX_CPLD_NUM) ++ return -EINVAL; ++ ++ mlxsw_reg_msci_pack(msci_pl, i); ++ err = mlxsw_reg_query(mlxsw_qsfp->core, MLXSW_REG(msci), msci_pl); ++ if (err) ++ return err; ++ ++ version = mlxsw_reg_msci_version_get(msci_pl); ++ ++ return sprintf(buf, "%u\n", version); ++} ++ ++int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, ++ const struct mlxsw_bus_info *mlxsw_bus_info, ++ struct mlxsw_qsfp **p_qsfp) ++{ ++ struct device_attribute *dev_attr, *cpld_dev_attr; ++ char pmlp_pl[MLXSW_REG_PMLP_LEN]; ++ struct mlxsw_qsfp *mlxsw_qsfp; ++ struct bin_attribute *eeprom; ++ int i, count; ++ u8 width; ++ int err; ++ ++ if (!strcmp(mlxsw_bus_info->device_kind, "i2c")) ++ return 0; ++ ++ mlxsw_qsfp = devm_kzalloc(mlxsw_bus_info->dev, sizeof(*mlxsw_qsfp), ++ GFP_KERNEL); ++ if (!mlxsw_qsfp) ++ return -ENOMEM; ++ ++ mlxsw_qsfp->core = mlxsw_core; ++ mlxsw_qsfp->bus_info = mlxsw_bus_info; ++ mlxsw_bus_info->dev->platform_data = mlxsw_qsfp; ++ ++ for (i = 1; i <= MLXSW_QSFP_MAX_NUM; i++) { ++ mlxsw_reg_pmlp_pack(pmlp_pl, i); ++ err = mlxsw_reg_query(mlxsw_qsfp->core, MLXSW_REG(pmlp), ++ pmlp_pl); ++ if (err) ++ return err; ++ width = mlxsw_reg_pmlp_width_get(pmlp_pl); ++ if (!width) ++ continue; ++ mlxsw_qsfp->module_count++; ++ } ++ ++ count = mlxsw_qsfp->module_count + 1; ++ mlxsw_qsfp->eeprom = devm_kzalloc(mlxsw_bus_info->dev, ++ mlxsw_qsfp->module_count * ++ sizeof(*mlxsw_qsfp->eeprom), ++ GFP_KERNEL); ++ if (!mlxsw_qsfp->eeprom) ++ return -ENOMEM; ++ ++ mlxsw_qsfp->eeprom_attr_list = devm_kzalloc(mlxsw_bus_info->dev, ++ count * ++ sizeof(mlxsw_qsfp->eeprom), ++ GFP_KERNEL); ++ if (!mlxsw_qsfp->eeprom_attr_list) ++ return -ENOMEM; ++ ++ mlxsw_qsfp->dev_attrs = devm_kzalloc(mlxsw_bus_info->dev, count * ++ sizeof(*mlxsw_qsfp->dev_attrs), ++ GFP_KERNEL); ++ if (!mlxsw_qsfp->dev_attrs) ++ return -ENOMEM; ++ ++ mlxsw_qsfp->cpld_dev_attrs = devm_kzalloc(mlxsw_bus_info->dev, ++ MLXSW_QSFP_MAX_CPLD_NUM * ++ sizeof(*mlxsw_qsfp->cpld_dev_attrs), ++ GFP_KERNEL); ++ if (!mlxsw_qsfp->cpld_dev_attrs) ++ return -ENOMEM; ++ ++ eeprom = mlxsw_qsfp->eeprom; ++ dev_attr = mlxsw_qsfp->dev_attrs; ++ for (i = 0; i < mlxsw_qsfp->module_count; i++, eeprom++, dev_attr++) { ++ dev_attr->show = mlxsw_qsfp_status_show; ++ dev_attr->attr.mode = 0444; ++ dev_attr->attr.name = devm_kasprintf(mlxsw_bus_info->dev, ++ GFP_KERNEL, ++ "qsfp%d_status", i + 1); ++ mlxsw_qsfp->attrs[i] = &dev_attr->attr; ++ sysfs_attr_init(&dev_attr->attr); ++ err = sysfs_create_file(&mlxsw_bus_info->dev->kobj, ++ mlxsw_qsfp->attrs[i]); ++ if (err) ++ goto err_create_file; ++ ++ sysfs_bin_attr_init(eeprom); ++ eeprom->attr.name = devm_kasprintf(mlxsw_bus_info->dev, ++ GFP_KERNEL, "qsfp%d", ++ i + 1); ++ eeprom->attr.mode = 0444; ++ eeprom->read = mlxsw_qsfp_bin_read; ++ eeprom->size = MLXSW_QSFP_PAGE_NUM * MLXSW_QSFP_PAGE_SIZE; ++ mlxsw_qsfp->module_ind[i] = i; ++ eeprom->private = &mlxsw_qsfp->module_ind[i]; ++ mlxsw_qsfp->eeprom_attr_list[i] = eeprom; ++ err = sysfs_create_bin_file(&mlxsw_bus_info->dev->kobj, ++ eeprom); ++ if (err) ++ goto err_create_bin_file; ++ } ++ ++ cpld_dev_attr = mlxsw_qsfp->cpld_dev_attrs; ++ for (i = 0; i < MLXSW_QSFP_MAX_CPLD_NUM; i++, cpld_dev_attr++) { ++ cpld_dev_attr->show = mlxsw_qsfp_cpld_show; ++ cpld_dev_attr->attr.mode = 0444; ++ cpld_dev_attr->attr.name = devm_kasprintf(mlxsw_bus_info->dev, ++ GFP_KERNEL, ++ "cpld%d_version", i + 1); ++ mlxsw_qsfp->cpld_attrs[i] = &cpld_dev_attr->attr; ++ sysfs_attr_init(&cpld_dev_attr->attr); ++ err = sysfs_create_file(&mlxsw_bus_info->dev->kobj, ++ mlxsw_qsfp->cpld_attrs[i]); ++ if (err) ++ goto err_create_cpld_file; ++ } ++ ++ *p_qsfp = mlxsw_qsfp; ++ ++ return 0; ++ ++err_create_cpld_file: ++ sysfs_remove_file(&mlxsw_bus_info->dev->kobj, ++ mlxsw_qsfp->cpld_attrs[i--]); ++ i = mlxsw_qsfp->module_count; ++err_create_bin_file: ++ sysfs_remove_file(&mlxsw_bus_info->dev->kobj, ++ mlxsw_qsfp->attrs[i--]); ++err_create_file: ++ while (--i > 0) { ++ sysfs_remove_bin_file(&mlxsw_bus_info->dev->kobj, ++ mlxsw_qsfp->eeprom_attr_list[i]); ++ sysfs_remove_file(&mlxsw_bus_info->dev->kobj, ++ mlxsw_qsfp->attrs[i]); ++ } ++ ++ return err; ++} ++ ++void mlxsw_qsfp_fini(struct mlxsw_qsfp *mlxsw_qsfp) ++{ ++ int i; ++ ++ if (!strcmp(mlxsw_qsfp->bus_info->device_kind, "i2c")) ++ return; ++ ++ for (i = mlxsw_qsfp->module_count - 1; i >= 0; i--) { ++ sysfs_remove_bin_file(&mlxsw_qsfp->bus_info->dev->kobj, ++ mlxsw_qsfp->eeprom_attr_list[i]); ++ sysfs_remove_file(&mlxsw_qsfp->bus_info->dev->kobj, ++ mlxsw_qsfp->attrs[i]); ++ } ++} ++ ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox switch QSFP sysfs driver"); +diff -Nur a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h 2017-05-25 13:45:05.000000000 +0000 ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h 2017-11-09 13:05:10.576834467 +0000 +@@ -50,6 +50,12 @@ + u16 len; /* In u8 */ + }; + ++#define MLXSW_REG_DEFINE(_name, _id, _len) \ ++static const struct mlxsw_reg_info mlxsw_reg_##_name = { \ ++ .id = _id, \ ++ .len = _len, \ ++} ++ + #define MLXSW_REG(type) (&mlxsw_reg_##type) + #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len + #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len) +@@ -4466,7 +4472,7 @@ + */ + MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 6); + +-#define MLXSW_MFCR_TACHOS_MAX 10 ++#define MLXSW_MFCR_TACHOS_MAX 12 + + /* reg_mfcr_tacho_active + * Indicates which of the tachometer is active (bit per tachometer). +@@ -4564,6 +4570,54 @@ + mlxsw_reg_mfsm_tacho_set(payload, tacho); + } + ++/* MFSL - Management Fan Speed Limit Register ++ * ------------------------------------------ ++ * The Fan Speed Limit register is used to configure the fan speed ++ * event / interrupt notification mechanism. Fan speed threshold are ++ * defined for both under-speed and over-speed. ++ */ ++#define MLXSW_REG_MFSL_ID 0x9004 ++#define MLXSW_REG_MFSL_LEN 0x0C ++ ++MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN); ++ ++/* reg_mfsl_tacho ++ * Fan tachometer index. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4); ++ ++/* reg_mfsl_tach_min ++ * Tachometer minimum value (minimum RPM). ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16); ++ ++/* reg_mfsl_tach_max ++ * Tachometer maximum value (maximum RPM). ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16); ++ ++static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho, ++ u16 tach_min, u16 tach_max) ++{ ++ MLXSW_REG_ZERO(mfsl, payload); ++ mlxsw_reg_mfsl_tacho_set(payload, tacho); ++ mlxsw_reg_mfsl_tach_min_set(payload, tach_min); ++ mlxsw_reg_mfsl_tach_max_set(payload, tach_max); ++} ++ ++static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho, ++ u16 *p_tach_min, u16 *p_tach_max) ++{ ++ if (p_tach_min) ++ *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload); ++ ++ if (p_tach_max) ++ *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload); ++} ++ + /* MTCAP - Management Temperature Capabilities + * ------------------------------------------- + * This register exposes the capabilities of the device and +@@ -4635,6 +4689,29 @@ + */ + MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16); + ++/* reg_mtmp_tee ++ * Temperature Event Enable. ++ * 0 - Do not generate event ++ * 1 - Generate event ++ * 2 - Generate single event ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2); ++ ++#define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */ ++ ++/* reg_mtmp_temperature_threshold_hi ++ * High threshold for Temperature Warning Event. In 0.125 Celsius. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16); ++ ++/* reg_mtmp_temperature_threshold_lo ++ * Low threshold for Temperature Warning Event. In 0.125 Celsius. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16); ++ + #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8 + + /* reg_mtmp_sensor_name +@@ -4651,6 +4728,8 @@ + mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index); + mlxsw_reg_mtmp_mte_set(payload, max_temp_enable); + mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset); ++ mlxsw_reg_mtmp_temperature_threshold_hi_set(payload, ++ MLXSW_REG_MTMP_THRESH_HI); + } + + static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp, +@@ -4671,6 +4750,81 @@ + mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name); + } + ++/* MCIA - Management Cable Info Access ++ * ----------------------------------- ++ * MCIA register is used to access the SFP+ and QSFP connector's EPROM. ++ */ ++ ++#define MLXSW_REG_MCIA_ID 0x9014 ++#define MLXSW_REG_MCIA_LEN 0x40 ++ ++MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN); ++ ++/* reg_mcia_l ++ * Lock bit. Setting this bit will lock the access to the specific ++ * cable. Used for updating a full page in a cable EPROM. Any access ++ * other then subsequence writes will fail while the port is locked. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1); ++ ++/* reg_mcia_module ++ * Module number. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8); ++ ++/* reg_mcia_status ++ * Module status. ++ * Access: RO ++ */ ++MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8); ++ ++/* reg_mcia_i2c_device_address ++ * I2C device address. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8); ++ ++/* reg_mcia_page_number ++ * Page number. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8); ++ ++/* reg_mcia_device_address ++ * Device address. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16); ++ ++/* reg_mcia_size ++ * Number of bytes to read/write (up to 48 bytes). ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16); ++ ++#define MLXSW_SP_REG_MCIA_EEPROM_SIZE 48 ++ ++/* reg_mcia_eeprom ++ * Bytes to read/write. ++ * Access: RW ++ */ ++MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_SP_REG_MCIA_EEPROM_SIZE); ++ ++static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock, ++ u8 page_number, u16 device_addr, ++ u8 size, u8 i2c_device_addr) ++{ ++ MLXSW_REG_ZERO(mcia, payload); ++ mlxsw_reg_mcia_module_set(payload, module); ++ mlxsw_reg_mcia_l_set(payload, lock); ++ mlxsw_reg_mcia_page_number_set(payload, page_number); ++ mlxsw_reg_mcia_device_address_set(payload, device_addr); ++ mlxsw_reg_mcia_size_set(payload, size); ++ mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr); ++} ++ + /* MPAT - Monitoring Port Analyzer Table + * ------------------------------------- + * MPAT Register is used to query and configure the Switch PortAnalyzer Table. +@@ -4788,6 +4942,43 @@ + mlxsw_reg_mpar_pa_id_set(payload, pa_id); + } + ++/* MSCI - Management System CPLD Information Register ++ * --------------------------------------------------- ++ * This register allows querying for the System CPLD(s) information. ++ */ ++#define MLXSW_REG_MSCI_ID 0x902A ++#define MLXSW_REG_MSCI_LEN 0x10 ++ ++static const struct mlxsw_reg_info mlxsw_reg_msci = { ++ .id = MLXSW_REG_MSCI_ID, ++ .len = MLXSW_REG_MSCI_LEN, ++}; ++ ++/* reg_msci_index ++ * Index to access. ++ * Access: Index ++ */ ++MLXSW_ITEM32(reg, msci, index, 0x00, 0, 4); ++ ++/* reg_msci_version ++ * CPLD version. ++ * Access: R0 ++ */ ++MLXSW_ITEM32(reg, msci, version, 0x04, 0, 32); ++ ++static inline void ++mlxsw_reg_msci_pack(char *payload, u8 index) ++{ ++ MLXSW_REG_ZERO(msci, payload); ++ mlxsw_reg_msci_index_set(payload, index); ++} ++ ++static inline void ++mlxsw_reg_msci_unpack(char *payload, u16 *p_version) ++{ ++ *p_version = mlxsw_reg_msci_version_get(payload); ++} ++ + /* MLCR - Management LED Control Register + * -------------------------------------- + * Controls the system LEDs. diff --git a/packages/base/any/kernels/4.9-lts/patches/0007-hwmon-pmbus-Add-support-for-Intel-VID-protocol-VR13.patch b/packages/base/any/kernels/4.9-lts/patches/0007-hwmon-pmbus-Add-support-for-Intel-VID-protocol-VR13.patch new file mode 100644 index 00000000..f0a9bde8 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0007-hwmon-pmbus-Add-support-for-Intel-VID-protocol-VR13.patch @@ -0,0 +1,30 @@ +Linux backport patch. Includes following commits: +a4dffccb72a7fa46bb0d7f29e607375387e09956 + + +diff -Nur a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h +--- a/drivers/hwmon/pmbus/pmbus.h 2017-11-09 16:25:22.760993964 +0000 ++++ b/drivers/hwmon/pmbus/pmbus.h 2017-11-09 16:26:02.568994492 +0000 +@@ -341,7 +341,7 @@ + #define PMBUS_HAVE_STATUS_VMON BIT(19) + + enum pmbus_data_format { linear = 0, direct, vid }; +-enum vrm_version { vr11 = 0, vr12 }; ++enum vrm_version { vr11 = 0, vr12, vr13 }; + + struct pmbus_driver_info { + int pages; /* Total number of pages */ +diff -Nur a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c +--- a/drivers/hwmon/pmbus/pmbus_core.c 2017-11-09 16:25:22.760993964 +0000 ++++ b/drivers/hwmon/pmbus/pmbus_core.c 2017-11-09 16:26:02.568994492 +0000 +@@ -531,6 +531,10 @@ + if (val >= 0x01) + rv = 250 + (val - 1) * 5; + break; ++ case vr13: ++ if (val >= 0x01) ++ rv = 500 + (val - 1) * 10; ++ break; + } + return rv; + } diff --git a/packages/base/any/kernels/4.9-lts/patches/0008-hwmon-pmbus-Add-support-for-Texas-Instruments-tps536.patch b/packages/base/any/kernels/4.9-lts/patches/0008-hwmon-pmbus-Add-support-for-Texas-Instruments-tps536.patch new file mode 100644 index 00000000..f95e2769 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0008-hwmon-pmbus-Add-support-for-Texas-Instruments-tps536.patch @@ -0,0 +1,151 @@ +Linux backport patch. Includes following commits: +f7caf758e26ab84b2b9def9ec68235c85d645597 + + +diff -Nur a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig +--- a/drivers/hwmon/pmbus/Kconfig 2017-11-09 16:34:05.269000902 +0000 ++++ b/drivers/hwmon/pmbus/Kconfig 2017-11-09 16:35:49.701002288 +0000 +@@ -125,6 +125,15 @@ + This driver can also be built as a module. If so, the module will + be called tps40422. + ++config SENSORS_TPS53679 ++ tristate "TI TPS53679" ++ help ++ If you say yes here you get hardware monitoring support for TI ++ TPS53679. ++ ++ This driver can also be built as a module. If so, the module will ++ be called tps53679. ++ + config SENSORS_UCD9000 + tristate "TI UCD90120, UCD90124, UCD90160, UCD9090, UCD90910" + default n +diff -Nur a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile +--- a/drivers/hwmon/pmbus/Makefile 2017-11-09 16:34:05.269000902 +0000 ++++ b/drivers/hwmon/pmbus/Makefile 2017-11-09 16:35:49.701002288 +0000 +@@ -13,6 +13,7 @@ + obj-$(CONFIG_SENSORS_MAX34440) += max34440.o + obj-$(CONFIG_SENSORS_MAX8688) += max8688.o + obj-$(CONFIG_SENSORS_TPS40422) += tps40422.o ++obj-$(CONFIG_SENSORS_TPS53679) += tps53679.o + obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o + obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o + obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o +diff -Nur a/drivers/hwmon/pmbus/tps53679.c b/drivers/hwmon/pmbus/tps53679.c +--- a/drivers/hwmon/pmbus/tps53679.c 1970-01-01 00:00:00.000000000 +0000 ++++ b/drivers/hwmon/pmbus/tps53679.c 2017-11-09 16:35:49.701002288 +0000 +@@ -0,0 +1,113 @@ ++/* ++ * Hardware monitoring driver for Texas Instruments TPS53679 ++ * ++ * Copyright (c) 2017 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2017 Vadim Pasternak ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include "pmbus.h" ++ ++#define TPS53679_PROT_VR12_5MV 0x01 /* VR12.0 mode, 5-mV DAC */ ++#define TPS53679_PROT_VR12_5_10MV 0x02 /* VR12.5 mode, 10-mV DAC */ ++#define TPS53679_PROT_VR13_10MV 0x04 /* VR13.0 mode, 10-mV DAC */ ++#define TPS53679_PROT_IMVP8_5MV 0x05 /* IMVP8 mode, 5-mV DAC */ ++#define TPS53679_PROT_VR13_5MV 0x07 /* VR13.0 mode, 5-mV DAC */ ++#define TPS53679_PAGE_NUM 2 ++ ++static int tps53679_identify(struct i2c_client *client, ++ struct pmbus_driver_info *info) ++{ ++ u8 vout_params; ++ int ret; ++ ++ /* Read the register with VOUT scaling value.*/ ++ ret = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); ++ if (ret < 0) ++ return ret; ++ ++ vout_params = ret & GENMASK(4, 0); ++ ++ switch (vout_params) { ++ case TPS53679_PROT_VR13_10MV: ++ case TPS53679_PROT_VR12_5_10MV: ++ info->vrm_version = vr13; ++ break; ++ case TPS53679_PROT_VR13_5MV: ++ case TPS53679_PROT_VR12_5MV: ++ case TPS53679_PROT_IMVP8_5MV: ++ info->vrm_version = vr12; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static struct pmbus_driver_info tps53679_info = { ++ .pages = TPS53679_PAGE_NUM, ++ .format[PSC_VOLTAGE_IN] = linear, ++ .format[PSC_VOLTAGE_OUT] = vid, ++ .format[PSC_TEMPERATURE] = linear, ++ .format[PSC_CURRENT_OUT] = linear, ++ .format[PSC_POWER] = linear, ++ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | ++ PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | ++ PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | ++ PMBUS_HAVE_POUT, ++ .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | ++ PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | ++ PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | ++ PMBUS_HAVE_POUT, ++ .identify = tps53679_identify, ++}; ++ ++static int tps53679_probe(struct i2c_client *client, ++ const struct i2c_device_id *id) ++{ ++ return pmbus_do_probe(client, id, &tps53679_info); ++} ++ ++static const struct i2c_device_id tps53679_id[] = { ++ {"tps53679", 0}, ++ {} ++}; ++ ++MODULE_DEVICE_TABLE(i2c, tps53679_id); ++ ++static const struct of_device_id tps53679_of_match[] = { ++ {.compatible = "ti,tps53679"}, ++ {} ++}; ++MODULE_DEVICE_TABLE(of, tps53679_of_match); ++ ++static struct i2c_driver tps53679_driver = { ++ .driver = { ++ .name = "tps53679", ++ .of_match_table = of_match_ptr(tps53679_of_match), ++ }, ++ .probe = tps53679_probe, ++ .remove = pmbus_do_remove, ++ .id_table = tps53679_id, ++}; ++ ++module_i2c_driver(tps53679_driver); ++ ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("PMBus driver for Texas Instruments TPS53679"); ++MODULE_LICENSE("GPL"); diff --git a/packages/base/any/kernels/4.9-lts/patches/series b/packages/base/any/kernels/4.9-lts/patches/series index e26a164c..b16099f0 100644 --- a/packages/base/any/kernels/4.9-lts/patches/series +++ b/packages/base/any/kernels/4.9-lts/patches/series @@ -1 +1,9 @@ driver-support-intel-igb-bcm5461-phy.patch +0001-i2c-mlxcpld-add-master-driver-for-Mellanox-systems.patch +0002-i2c-mux-mlxcpld-add-driver-for-Mellanox-systems.patch +0003-platform-mellanox-Introduce-Mellanox-hardware-platfo.patch +0004-platform-x86-Introduce-support-for-Mellanox-hotplug-.patch +0005-leds-add-driver-for-support-Mellanox-regmap-LEDs-for.patch +0006-Mellanox-switch-drivers-changes.patch +0007-hwmon-pmbus-Add-support-for-Intel-VID-protocol-VR13.patch +0008-hwmon-pmbus-Add-support-for-Texas-Instruments-tps536.patch diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c index 04f52be5..b6e6e8ad 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c @@ -43,6 +43,12 @@ #define LED_MODE_BLUE_BLINK "blue_blink" #define LED_MODE_AUTO "cpld_control" +#define LED_BLINK_PERIOD "100" +#define LED_ON "1" +#define LED_OFF "0" +#define LED_BLINK_PERIOD_LEN 3 +#define LED_MODE_LEN 1 + #define VALIDATE(_id) \ do { \ if(!ONLP_OID_IS_LED(_id)) { \ @@ -94,6 +100,20 @@ led_light_mode_map_t led_map[] = { {LED_UID, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, }; +typedef struct led_colors { + enum onlp_led_id id; + const char* color1; + const char* color2; +} led_colors_t; + +static led_colors_t led_colors_map[] = { + {LED_SYSTEM, "green", "red"}, + {LED_FAN, "green", "red"}, + {LED_PSU1, "green", "red"}, + {LED_PSU2, "green", "red"}, + {LED_UID, "blue", NULL}, +}; + static char file_names[][10] = /* must map with onlp_led_id */ { "reserved", @@ -176,6 +196,57 @@ static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_l return LED_MODE_OFF; } +static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id = ONLP_OID_ID_GET(id); + char color[10]={0}; + int blinking = 0; + + switch (mode) { + case ONLP_LED_MODE_RED_BLINKING: + strcpy(color, "red"); + blinking = 1; + break; + case ONLP_LED_MODE_GREEN_BLINKING: + strcpy(color, "green"); + blinking = 1; + break; + case ONLP_LED_MODE_BLUE_BLINKING: + strcpy(color, "blue"); + blinking = 1; + break; + case ONLP_LED_MODE_YELLOW_BLINKING: + strcpy(color, "yellow"); + blinking = 1; + break; + case ONLP_LED_MODE_RED: + strcpy(color, "red"); + break; + case ONLP_LED_MODE_GREEN: + strcpy(color, "green"); + break; + case ONLP_LED_MODE_BLUE: + strcpy(color, "blue"); + break; + case ONLP_LED_MODE_YELLOW: + strcpy(color, "yellow"); + break; + default: + return ONLP_STATUS_E_PARAM; + } + + if (blinking) { + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_off", prefix_path, file_names[local_id], color); + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_on", prefix_path, file_names[local_id], color); + } + onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, + "%s%s_%s", prefix_path, file_names[local_id], color); + + return ONLP_STATUS_OK; +} + /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -183,7 +254,7 @@ int onlp_ledi_init(void) { /* - * TODO setting UI LED to off when it will be supported + * ONLPD calls it too early before all BSP insfrastructure is set */ return ONLP_STATUS_OK; @@ -203,6 +274,15 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) *info = linfo[ONLP_OID_ID_GET(id)]; /* Get LED mode */ + if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + char* cmd = aim_fstrdup("%s%s_state", prefix_path, file_names[local_id]); + if(system(cmd) != 0) { + aim_free(cmd); + return ONLP_STATUS_E_INTERNAL; + } + aim_free(cmd); + } + if (onlp_file_read(data, sizeof(data), &len, "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; @@ -233,7 +313,19 @@ onlp_ledi_set(onlp_oid_t id, int on_or_off) VALIDATE(id); if (!on_or_off) { + if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + else { + int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); + for (i = 0; i < nsize; i++) + { + if (id == led_colors_map[i].id) + break; + } + if (led_colors_map[i].color1) + onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, + "%s%s_%s", prefix_path, file_names[id], led_colors_map[i].color1); + } } return ONLP_STATUS_E_UNSUPPORTED; @@ -249,14 +341,23 @@ int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { int local_id; + char* driver_led_mode; + int nbytes; VALIDATE(id); + if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { local_id = ONLP_OID_ID_GET(id); - - if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, + driver_led_mode = onlp_to_driver_led_mode(local_id, mode); + nbytes = strnlen(driver_led_mode, driver_value_len); + if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; + } + } else { + if (led_set_mode(id, mode) != 0) { + return ONLP_STATUS_E_INTERNAL; + } } return ONLP_STATUS_OK; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c index 07b40173..5c7d11f4 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c @@ -27,9 +27,37 @@ #include #include #include +#include +#include +#include #include #include #include #include "platform_lib.h" -/* Nothing on this platform */ +int +onlp_get_kernel_ver() +{ + struct utsname buff; + char ver[4]; + char *p; + int i = 0; + + if (uname(&buff) != 0) + return ONLP_STATUS_E_INTERNAL; + + p = buff.release; + + while (*p) { + if (isdigit(*p)) { + ver[i] = strtol(p, &p, 10); + i++; + if (i >= 3) + break; + } else { + p++; + } + } + + return KERNEL_VERSION(ver[0], ver[1], ver[2]); +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h index e364842e..357bf8c4 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h @@ -41,6 +41,10 @@ #define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" #define IDPROM_PATH "/bsp/eeprom/%s%d_info" +#ifndef KERNEL_VERSION +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#endif + /* LED related data */ enum onlp_led_id @@ -62,5 +66,6 @@ typedef enum psu_type { psu_type_t get_psu_type(int id, char* modelname, int modelname_len); int onlp_fani_get_min_rpm(int id); +int onlp_get_kernel_ver(void); #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c index 8bfc5357..e371e303 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c @@ -135,7 +135,6 @@ 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); const char psu_model[]=PSU_MODEL; @@ -156,14 +155,14 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) if (val != PSU_CABLE_PRESENT) { info->status |= ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; + } + else { + info->status &= ~ONLP_PSU_STATUS_UNPLUGGED; } - info->status |= ONLP_PSU_STATUS_PRESENT; + _psu_info_get(info); - ret = _psu_info_get(info); - - return ret; + return ONLP_STATUS_OK; } int diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c index 6b799584..95050cc0 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c @@ -47,13 +47,23 @@ msn2100_sfp_node_read_int(char *node_path, int *value) int data_len = 0, ret = 0; char buf[SFP_SYSFS_VALUE_LEN] = {0}; *value = -1; + char sfp_present_status[16]; + char sfp_not_present_status[16]; + + if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + strcpy(sfp_present_status, "1"); + strcpy(sfp_not_present_status, "0"); + } else { + strcpy(sfp_present_status, "good"); + strcpy(sfp_not_present_status, "not_connected"); + } ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path); if (ret == 0) { - if (!strncmp(buf, SFP_PRESENT_STATUS, strlen(SFP_PRESENT_STATUS))) { + if (!strncmp(buf, sfp_present_status, strlen(sfp_present_status))) { *value = 1; - } else if (!strncmp(buf, SFP_NOT_PRESENT_STATUS, strlen(SFP_NOT_PRESENT_STATUS))) { + } else if (!strncmp(buf, sfp_not_present_status, strlen(sfp_not_present_status))) { *value = 0; } } @@ -64,7 +74,10 @@ msn2100_sfp_node_read_int(char *node_path, int *value) static char* msn2100_sfp_get_port_path(int port, char *node_name) { + if (node_name) sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); + else + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); return sfp_node_path; } @@ -136,7 +149,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = msn2100_sfp_get_port_path(port, ""); + char* path = msn2100_sfp_get_port_path(port, NULL); /* * Read the SFP eeprom into data[] @@ -194,12 +207,14 @@ onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) int fd; int nrd; - if (!path) + if (!path){ return ONLP_STATUS_E_MISSING; + } fd = open(path, O_RDONLY); - if (fd < 0) + if (fd < 0) { return ONLP_STATUS_E_MISSING; + } lseek(fd, addr, SEEK_SET); nrd = read(fd, &data, 2); diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c index d294613d..c2c4a420 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c @@ -126,13 +126,13 @@ onlp_sysi_onie_info_get(onlp_onie_info_t* onie) int onlp_sysi_platform_manage_leds(void) { - int fan_number; - onlp_led_mode_t mode; + int fan_number, psu_number; + onlp_led_mode_t mode, system_mode; int min_fan_speed; - enum onlp_led_id fan_led_id = LED_FAN; + enum onlp_led_id psu_led_id[2] = { LED_PSU1, LED_PSU2 }; + int fan_problem = 0; + int psu_problem = 0; - /* after reboot, status LED should blink green, SW set to solid green */ - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), ONLP_LED_MODE_GREEN); /* * FAN Indicators * @@ -142,7 +142,6 @@ onlp_sysi_platform_manage_leds(void) * */ mode = ONLP_LED_MODE_GREEN; - for( fan_number = 1; fan_number<= CHASSIS_FAN_COUNT; fan_number+=2) { /* each 2 fans had same led_fan */ @@ -150,9 +149,11 @@ onlp_sysi_platform_manage_leds(void) /* check fans */ if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if(fi.status & ONLP_FAN_STATUS_FAILED) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else { @@ -160,6 +161,7 @@ onlp_sysi_platform_manage_leds(void) if( fi.rpm < min_fan_speed) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } } /* check fan i+1 */ @@ -168,6 +170,7 @@ onlp_sysi_platform_manage_leds(void) } else if(fi.status & ONLP_FAN_STATUS_FAILED) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else { @@ -175,10 +178,35 @@ onlp_sysi_platform_manage_leds(void) if( fi.rpm < min_fan_speed) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } } } - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id), mode); + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_FAN), mode); + + for (psu_number = 1; psu_number <= CHASSIS_PSU_COUNT; psu_number++) + { + onlp_psu_info_t pi; + mode = ONLP_LED_MODE_GREEN; + if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { + mode = ONLP_LED_MODE_RED; + psu_problem = 1; + } + /* Fixed system, PSU always in. Check only cable plugged. */ + else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + mode = ONLP_LED_MODE_RED; + psu_problem = 1; + } + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, psu_led_id[(psu_number-1)]), mode); + } + + /* Set System status LED green if no problem in FANs or PSUs */ + if (fan_problem || psu_problem) + system_mode = ONLP_LED_MODE_RED; + else + system_mode = ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_SYSTEM), system_mode); return ONLP_STATUS_OK; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/platform-config/r0/src/lib/x86-64-mlnx-msn2100-r0.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/platform-config/r0/src/lib/x86-64-mlnx-msn2100-r0.yml index 6cf8f529..75935335 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/platform-config/r0/src/lib/x86-64-mlnx-msn2100-r0.yml +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/platform-config/r0/src/lib/x86-64-mlnx-msn2100-r0.yml @@ -18,7 +18,7 @@ x86-64-mlnx-msn2100-r0: --stop=1 kernel: - <<: *kernel-3-16 + <<: *kernel-4-9 args: >- nopat diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c index 22228e5b..e0f07471 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c @@ -244,6 +244,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[(int)fru_index].status); OPEN_READ_FILE(fullpath, r_data, nbytes, len); if (atoi(r_data) != FAN_STATUS_OK) { + info->status &= ~ONLP_FAN_STATUS_PRESENT; return ONLP_STATUS_OK; } info->status |= ONLP_FAN_STATUS_PRESENT; @@ -303,6 +304,7 @@ _onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[local_id].status); OPEN_READ_FILE(fullpath, r_data, nbytes, len); if (atoi(r_data) != FAN_STATUS_OK) { + info->status &= ~ONLP_FAN_STATUS_PRESENT; return ONLP_STATUS_OK; } info->status |= ONLP_FAN_STATUS_PRESENT; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c index f903c899..74386ff0 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c @@ -43,6 +43,12 @@ #define LED_MODE_BLUE_BLINK "blue_blink" #define LED_MODE_AUTO "cpld_control" +#define LED_BLINK_PERIOD "100" +#define LED_ON "1" +#define LED_OFF "0" +#define LED_BLINK_PERIOD_LEN 3 +#define LED_MODE_LEN 1 + #define VALIDATE(_id) \ do { \ if(!ONLP_OID_IS_LED(_id)) { \ @@ -103,6 +109,21 @@ led_light_mode_map_t led_map[] = { {LED_PSU, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} }; +typedef struct led_colors { + enum onlp_led_id id; + const char* color1; + const char* color2; +} led_colors_t; + +static led_colors_t led_colors_map[] = { + {LED_SYSTEM, "green", "red"}, + {LED_FAN1, "green", "red"}, + {LED_FAN2, "green", "red"}, + {LED_FAN3, "green", "red"}, + {LED_FAN4, "green", "red"}, + {LED_PSU, "green", "red"}, +}; + static char file_names[][10] = /* must map with onlp_led_id */ { "reserved", @@ -192,6 +213,57 @@ static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_l return LED_MODE_OFF; } +static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id = ONLP_OID_ID_GET(id); + char color[10]={0}; + int blinking = 0; + + switch (mode) { + case ONLP_LED_MODE_RED_BLINKING: + strcpy(color, "red"); + blinking = 1; + break; + case ONLP_LED_MODE_GREEN_BLINKING: + strcpy(color, "green"); + blinking = 1; + break; + case ONLP_LED_MODE_BLUE_BLINKING: + strcpy(color, "blue"); + blinking = 1; + break; + case ONLP_LED_MODE_YELLOW_BLINKING: + strcpy(color, "yellow"); + blinking = 1; + break; + case ONLP_LED_MODE_RED: + strcpy(color, "red"); + break; + case ONLP_LED_MODE_GREEN: + strcpy(color, "green"); + break; + case ONLP_LED_MODE_BLUE: + strcpy(color, "blue"); + break; + case ONLP_LED_MODE_YELLOW: + strcpy(color, "yellow"); + break; + default: + return ONLP_STATUS_E_PARAM; + } + + if (blinking) { + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_off", prefix_path, file_names[local_id], color); + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_on", prefix_path, file_names[local_id], color); + } + onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, + "%s%s_%s", prefix_path, file_names[local_id], color); + + return ONLP_STATUS_OK; +} + /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -199,7 +271,7 @@ int onlp_ledi_init(void) { /* - * TODO setting UI LED to off when it will be supported on MSN2410 + * ONLPD calls it too early before all BSP insfrastructure is set */ return ONLP_STATUS_OK; @@ -219,6 +291,15 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) *info = linfo[ONLP_OID_ID_GET(id)]; /* Get LED mode */ + if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + char* cmd = aim_fstrdup("%s%s_state", prefix_path, file_names[local_id]); + if(system(cmd) != 0) { + aim_free(cmd); + return ONLP_STATUS_E_INTERNAL; + } + aim_free(cmd); + } + if (onlp_file_read(data, sizeof(data), &len, "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; @@ -249,7 +330,19 @@ onlp_ledi_set(onlp_oid_t id, int on_or_off) VALIDATE(id); if (!on_or_off) { + if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + else { + int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); + for (i = 0; i < nsize; i++) + { + if (id == led_colors_map[i].id) + break; + } + if (led_colors_map[i].color1) + onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, + "%s%s_%s", prefix_path, file_names[id], led_colors_map[i].color1); + } } return ONLP_STATUS_E_UNSUPPORTED; @@ -265,15 +358,23 @@ int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { int local_id; + char* driver_led_mode; + int nbytes; VALIDATE(id); + if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { local_id = ONLP_OID_ID_GET(id); - - if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, - "%s%s", prefix_path, file_names[local_id]) != 0) - { + driver_led_mode = onlp_to_driver_led_mode(local_id, mode); + nbytes = strnlen(driver_led_mode, driver_value_len); + if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, + "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; + } + } else { + if (led_set_mode(id, mode) != 0) { + return ONLP_STATUS_E_INTERNAL; + } } return ONLP_STATUS_OK; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c index 5ee85a2a..5035bc48 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -77,3 +80,30 @@ psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_i return ONLP_STATUS_OK; } + +int +onlp_get_kernel_ver() +{ + struct utsname buff; + char ver[4]; + char *p; + int i = 0; + + if (uname(&buff) != 0) + return ONLP_STATUS_E_INTERNAL; + + p = buff.release; + + while (*p) { + if (isdigit(*p)) { + ver[i] = strtol(p, &p, 10); + i++; + if (i >= 3) + break; + } else { + p++; + } + } + + return KERNEL_VERSION(ver[0], ver[1], ver[2]); +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h index 3992e357..80b9faa8 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h @@ -42,6 +42,10 @@ #define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" #define IDPROM_PATH "/bsp/eeprom/%s%d_info" +#ifndef KERNEL_VERSION +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#endif + /* LED related data */ enum onlp_led_id @@ -67,5 +71,6 @@ int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info); int onlp_fani_get_min_rpm(int id); +int onlp_get_kernel_ver(void); #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c index ff734bdc..f5555b60 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c @@ -174,6 +174,8 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) info->status |= ONLP_PSU_STATUS_UNPLUGGED; return ONLP_STATUS_OK; } + else + info->status |= ONLP_PSU_STATUS_PRESENT; /* Get the cable preset state */ if (psu_module_info_get(index, "pwr_status", &val) != 0) { @@ -185,8 +187,6 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) return ONLP_STATUS_OK; } - info->status |= ONLP_PSU_STATUS_PRESENT; - ret = _psu_info_get(info); return ret; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c index bc65322a..e2c3f56d 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c @@ -47,13 +47,23 @@ msn2410_sfp_node_read_int(char *node_path, int *value) int data_len = 0, ret = 0; char buf[SFP_SYSFS_VALUE_LEN] = {0}; *value = -1; + char sfp_present_status[16]; + char sfp_not_present_status[16]; + + if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + strcpy(sfp_present_status, "1"); + strcpy(sfp_not_present_status, "0"); + } else { + strcpy(sfp_present_status, "good"); + strcpy(sfp_not_present_status, "not_connected"); + } ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path); if (ret == 0) { - if (!strncmp(buf, SFP_PRESENT_STATUS, strlen(SFP_PRESENT_STATUS))) { + if (!strncmp(buf, sfp_present_status, strlen(sfp_present_status))) { *value = 1; - } else if (!strncmp(buf, SFP_NOT_PRESENT_STATUS, strlen(SFP_NOT_PRESENT_STATUS))) { + } else if (!strncmp(buf, sfp_not_present_status, strlen(sfp_not_present_status))) { *value = 0; } } @@ -64,7 +74,10 @@ msn2410_sfp_node_read_int(char *node_path, int *value) static char* msn2410_sfp_get_port_path(int port, char *node_name) { + if (node_name) sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); + else + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); return sfp_node_path; } @@ -139,7 +152,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = msn2410_sfp_get_port_path(port, ""); + char* path = msn2410_sfp_get_port_path(port, NULL); /* * Read the SFP eeprom into data[] diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c index 11b3b1b6..0e9f2549 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c @@ -136,13 +136,13 @@ onlp_sysi_onie_info_get(onlp_onie_info_t* onie) int onlp_sysi_platform_manage_leds(void) { - int fan_number; - onlp_led_mode_t mode; + int fan_number, psu_number; + onlp_led_mode_t mode, system_mode; int min_fan_speed; enum onlp_led_id fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 }; + int fan_problem = 0; + int psu_problem = 0; - /* after reboot, status LED should blink green, SW set to solid green */ - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), ONLP_LED_MODE_GREEN); /* * FAN Indicators * @@ -159,13 +159,16 @@ onlp_sysi_platform_manage_leds(void) mode = ONLP_LED_MODE_GREEN; if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } - else if( (fi.status & 0x1) == 0) { + else if( (fi.status & ONLP_FAN_STATUS_PRESENT) == 0) { /* Not present */ mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if(fi.status & ONLP_FAN_STATUS_FAILED) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else { @@ -173,18 +176,22 @@ onlp_sysi_platform_manage_leds(void) if( fi.rpm < min_fan_speed) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } } /* check fan i+1 */ if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if( (fi.status & 0x1) == 0) { /* Not present */ mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if(fi.status & ONLP_FAN_STATUS_FAILED) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else { @@ -192,10 +199,41 @@ onlp_sysi_platform_manage_leds(void) if( fi.rpm < min_fan_speed) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } } onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode); } + + for (psu_number = 1; psu_number <= CHASSIS_PSU_COUNT; psu_number++) + { + onlp_psu_info_t pi; + if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { + psu_problem = 1; + } + else if((pi.status & ONLP_PSU_STATUS_PRESENT) == 0) { + /* Not present */ + psu_problem = 1; + } + else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + psu_problem = 1; + } + } + + if (psu_problem) + mode = ONLP_LED_MODE_RED; + else + mode = ONLP_LED_MODE_GREEN; + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_PSU), mode); + + /* Set System status LED green if no problem in FANs or PSUs */ + if (fan_problem || psu_problem) + system_mode = ONLP_LED_MODE_RED; + else + system_mode = ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), system_mode); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/platform-config/r0/src/lib/x86-64-mlnx-msn2410-r0.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/platform-config/r0/src/lib/x86-64-mlnx-msn2410-r0.yml index 88a54b31..9062aa13 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/platform-config/r0/src/lib/x86-64-mlnx-msn2410-r0.yml +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/platform-config/r0/src/lib/x86-64-mlnx-msn2410-r0.yml @@ -18,7 +18,7 @@ x86-64-mlnx-msn2410-r0: --stop=1 kernel: - <<: *kernel-3-16 + <<: *kernel-4-9 args: >- nopat diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c index eebd3d09..9abef68f 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c @@ -176,7 +176,8 @@ _onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) local_id /= 2; } - rv = onlp_file_read(data, sizeof(data), &len, IDPROM_PATH, "fan", local_id); + rv = onlp_file_read(data, sizeof(data), &len, + IDPROM_PATH, "fan", local_id); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -243,6 +244,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[(int)fru_index].status); OPEN_READ_FILE(fullpath, r_data, nbytes, len); if (atoi(r_data) != FAN_STATUS_OK) { + info->status &= ~ONLP_FAN_STATUS_PRESENT; return ONLP_STATUS_OK; } info->status |= ONLP_FAN_STATUS_PRESENT; @@ -302,6 +304,7 @@ _onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[local_id].status); OPEN_READ_FILE(fullpath, r_data, nbytes, len); if (atoi(r_data) != FAN_STATUS_OK) { + info->status &= ~ONLP_FAN_STATUS_PRESENT; return ONLP_STATUS_OK; } info->status |= ONLP_FAN_STATUS_PRESENT; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c index dc96956a..74386ff0 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c @@ -43,6 +43,12 @@ #define LED_MODE_BLUE_BLINK "blue_blink" #define LED_MODE_AUTO "cpld_control" +#define LED_BLINK_PERIOD "100" +#define LED_ON "1" +#define LED_OFF "0" +#define LED_BLINK_PERIOD_LEN 3 +#define LED_MODE_LEN 1 + #define VALIDATE(_id) \ do { \ if(!ONLP_OID_IS_LED(_id)) { \ @@ -103,6 +109,21 @@ led_light_mode_map_t led_map[] = { {LED_PSU, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} }; +typedef struct led_colors { + enum onlp_led_id id; + const char* color1; + const char* color2; +} led_colors_t; + +static led_colors_t led_colors_map[] = { + {LED_SYSTEM, "green", "red"}, + {LED_FAN1, "green", "red"}, + {LED_FAN2, "green", "red"}, + {LED_FAN3, "green", "red"}, + {LED_FAN4, "green", "red"}, + {LED_PSU, "green", "red"}, +}; + static char file_names[][10] = /* must map with onlp_led_id */ { "reserved", @@ -192,6 +213,57 @@ static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_l return LED_MODE_OFF; } +static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id = ONLP_OID_ID_GET(id); + char color[10]={0}; + int blinking = 0; + + switch (mode) { + case ONLP_LED_MODE_RED_BLINKING: + strcpy(color, "red"); + blinking = 1; + break; + case ONLP_LED_MODE_GREEN_BLINKING: + strcpy(color, "green"); + blinking = 1; + break; + case ONLP_LED_MODE_BLUE_BLINKING: + strcpy(color, "blue"); + blinking = 1; + break; + case ONLP_LED_MODE_YELLOW_BLINKING: + strcpy(color, "yellow"); + blinking = 1; + break; + case ONLP_LED_MODE_RED: + strcpy(color, "red"); + break; + case ONLP_LED_MODE_GREEN: + strcpy(color, "green"); + break; + case ONLP_LED_MODE_BLUE: + strcpy(color, "blue"); + break; + case ONLP_LED_MODE_YELLOW: + strcpy(color, "yellow"); + break; + default: + return ONLP_STATUS_E_PARAM; + } + + if (blinking) { + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_off", prefix_path, file_names[local_id], color); + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_on", prefix_path, file_names[local_id], color); + } + onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, + "%s%s_%s", prefix_path, file_names[local_id], color); + + return ONLP_STATUS_OK; +} + /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -199,7 +271,7 @@ int onlp_ledi_init(void) { /* - * TODO setting UI LED to off when it will be supported on SN2700 + * ONLPD calls it too early before all BSP insfrastructure is set */ return ONLP_STATUS_OK; @@ -219,6 +291,15 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) *info = linfo[ONLP_OID_ID_GET(id)]; /* Get LED mode */ + if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + char* cmd = aim_fstrdup("%s%s_state", prefix_path, file_names[local_id]); + if(system(cmd) != 0) { + aim_free(cmd); + return ONLP_STATUS_E_INTERNAL; + } + aim_free(cmd); + } + if (onlp_file_read(data, sizeof(data), &len, "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; @@ -249,7 +330,19 @@ onlp_ledi_set(onlp_oid_t id, int on_or_off) VALIDATE(id); if (!on_or_off) { + if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + else { + int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); + for (i = 0; i < nsize; i++) + { + if (id == led_colors_map[i].id) + break; + } + if (led_colors_map[i].color1) + onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, + "%s%s_%s", prefix_path, file_names[id], led_colors_map[i].color1); + } } return ONLP_STATUS_E_UNSUPPORTED; @@ -265,15 +358,23 @@ int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { int local_id; + char* driver_led_mode; + int nbytes; VALIDATE(id); + if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { local_id = ONLP_OID_ID_GET(id); - - if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, - "%s%s", prefix_path, file_names[local_id]) != 0) - { + driver_led_mode = onlp_to_driver_led_mode(local_id, mode); + nbytes = strnlen(driver_led_mode, driver_value_len); + if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, + "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; + } + } else { + if (led_set_mode(id, mode) != 0) { + return ONLP_STATUS_E_INTERNAL; + } } return ONLP_STATUS_OK; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c index 5ee85a2a..5035bc48 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -77,3 +80,30 @@ psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_i return ONLP_STATUS_OK; } + +int +onlp_get_kernel_ver() +{ + struct utsname buff; + char ver[4]; + char *p; + int i = 0; + + if (uname(&buff) != 0) + return ONLP_STATUS_E_INTERNAL; + + p = buff.release; + + while (*p) { + if (isdigit(*p)) { + ver[i] = strtol(p, &p, 10); + i++; + if (i >= 3) + break; + } else { + p++; + } + } + + return KERNEL_VERSION(ver[0], ver[1], ver[2]); +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h index c5b368c0..66581253 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h @@ -42,6 +42,10 @@ #define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" #define IDPROM_PATH "/bsp/eeprom/%s%d_info" +#ifndef KERNEL_VERSION +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#endif + /* LED related data */ enum onlp_led_id @@ -67,5 +71,6 @@ int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info); int onlp_fani_get_min_rpm(int id); +int onlp_get_kernel_ver(void); #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c index ff734bdc..f5555b60 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c @@ -174,6 +174,8 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) info->status |= ONLP_PSU_STATUS_UNPLUGGED; return ONLP_STATUS_OK; } + else + info->status |= ONLP_PSU_STATUS_PRESENT; /* Get the cable preset state */ if (psu_module_info_get(index, "pwr_status", &val) != 0) { @@ -185,8 +187,6 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) return ONLP_STATUS_OK; } - info->status |= ONLP_PSU_STATUS_PRESENT; - ret = _psu_info_get(info); return ret; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c index ad5b5fa7..65cd8893 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c @@ -47,13 +47,23 @@ sn2700_sfp_node_read_int(char *node_path, int *value) int data_len = 0, ret = 0; char buf[SFP_SYSFS_VALUE_LEN] = {0}; *value = -1; + char sfp_present_status[16]; + char sfp_not_present_status[16]; + + if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + strcpy(sfp_present_status, "1"); + strcpy(sfp_not_present_status, "0"); + } else { + strcpy(sfp_present_status, "good"); + strcpy(sfp_not_present_status, "not_connected"); + } ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path); if (ret == 0) { - if (!strncmp(buf, SFP_PRESENT_STATUS, strlen(SFP_PRESENT_STATUS))) { + if (!strncmp(buf, sfp_present_status, strlen(sfp_present_status))) { *value = 1; - } else if (!strncmp(buf, SFP_NOT_PRESENT_STATUS, strlen(SFP_NOT_PRESENT_STATUS))) { + } else if (!strncmp(buf, sfp_not_present_status, strlen(sfp_not_present_status))) { *value = 0; } } @@ -64,7 +74,10 @@ sn2700_sfp_node_read_int(char *node_path, int *value) static char* sn2700_sfp_get_port_path(int port, char *node_name) { + if (node_name) sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); + else + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); return sfp_node_path; } @@ -139,7 +152,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = sn2700_sfp_get_port_path(port, ""); + char* path = sn2700_sfp_get_port_path(port, NULL); /* * Read the SFP eeprom into data[] @@ -197,12 +210,14 @@ onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) int fd; int nrd; - if (!path) + if (!path){ return ONLP_STATUS_E_MISSING; + } fd = open(path, O_RDONLY); - if (fd < 0) + if (fd < 0) { return ONLP_STATUS_E_MISSING; + } lseek(fd, addr, SEEK_SET); nrd = read(fd, &data, 2); diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c index af615b8c..7b267507 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c @@ -48,7 +48,6 @@ #define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld" #define NUM_OF_CPLD 3 - static char arr_cplddev_name[NUM_OF_CPLD][30] = { "cpld_brd_version", @@ -137,13 +136,13 @@ onlp_sysi_onie_info_get(onlp_onie_info_t* onie) int onlp_sysi_platform_manage_leds(void) { - int fan_number; - onlp_led_mode_t mode; + int fan_number, psu_number; + onlp_led_mode_t mode, system_mode; int min_fan_speed; enum onlp_led_id fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 }; + int fan_problem = 0; + int psu_problem = 0; - /* after reboot, status LED should blink green, SW set to solid green */ - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), ONLP_LED_MODE_GREEN); /* * FAN Indicators * @@ -160,13 +159,16 @@ onlp_sysi_platform_manage_leds(void) mode = ONLP_LED_MODE_GREEN; if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } - else if( (fi.status & 0x1) == 0) { + else if( (fi.status & ONLP_FAN_STATUS_PRESENT) == 0) { /* Not present */ mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if(fi.status & ONLP_FAN_STATUS_FAILED) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else { @@ -174,18 +176,22 @@ onlp_sysi_platform_manage_leds(void) if( fi.rpm < min_fan_speed) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } } /* check fan i+1 */ if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if( (fi.status & 0x1) == 0) { /* Not present */ mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else if(fi.status & ONLP_FAN_STATUS_FAILED) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } else { @@ -193,10 +199,41 @@ onlp_sysi_platform_manage_leds(void) if( fi.rpm < min_fan_speed) { mode = ONLP_LED_MODE_RED; + fan_problem = 1; } } onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode); } + + for (psu_number = 1; psu_number <= CHASSIS_PSU_COUNT; psu_number++) + { + onlp_psu_info_t pi; + if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { + psu_problem = 1; + } + else if((pi.status & ONLP_PSU_STATUS_PRESENT) == 0) { + /* Not present */ + psu_problem = 1; + } + else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + psu_problem = 1; + } + } + + if (psu_problem) + mode = ONLP_LED_MODE_RED; + else + mode = ONLP_LED_MODE_GREEN; + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_PSU), mode); + + /* Set System status LED green if no problem in FANs or PSUs */ + if (fan_problem || psu_problem) + system_mode = ONLP_LED_MODE_RED; + else + system_mode = ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), system_mode); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/platform-config/r0/src/lib/x86-64-mlnx-msn2700-r0.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/platform-config/r0/src/lib/x86-64-mlnx-msn2700-r0.yml index ebe3cb48..39827dba 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/platform-config/r0/src/lib/x86-64-mlnx-msn2700-r0.yml +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/platform-config/r0/src/lib/x86-64-mlnx-msn2700-r0.yml @@ -18,7 +18,7 @@ x86-64-mlnx-msn2700-r0: --stop=1 kernel: - <<: *kernel-3-16 + <<: *kernel-4-9 args: >- nopat From 5551c3111ab6906cef3ac725dc180995224c2a6b Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 15 Nov 2017 16:33:30 +0800 Subject: [PATCH 065/244] [as7712-32x] Enhance SFP driver to support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as7712-32x-sfp.c | 1137 +++++++++++------ .../x86_64_accton_as7712_32x_r0/__init__.py | 64 +- 2 files changed, 751 insertions(+), 450 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c index 202d85a0..3ae35978 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c @@ -48,11 +48,10 @@ #define EEPROM_SIZE 256 /* 256 byte eeprom */ #define BIT_INDEX(i) (1ULL << (i)) #define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) #define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 #define SFF8024_DEVICE_ID_SFP 0x3 @@ -60,27 +59,73 @@ #define SFF8024_DEVICE_ID_QSFP_PLUS 0xD #define SFF8024_DEVICE_ID_QSFP28 0x11 -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - #define SFF8436_RX_LOS_ADDR 3 #define SFF8436_TX_FAULT_ADDR 4 #define SFF8436_TX_DISABLE_ADDR 86 +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); enum sfp_sysfs_attributes { PRESENT, @@ -108,14 +153,13 @@ enum sfp_sysfs_attributes { /* SFP/QSFP common attributes for sysfs */ static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); /* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); @@ -130,7 +174,6 @@ static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); static struct attribute *qsfp_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, &sensor_dev_attr_sfp_rx_los.dev_attr.attr, @@ -151,92 +194,56 @@ static struct attribute *qsfp_attributes[] = { NULL }; -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - /* Platform dependent +++ */ #define CPLD_PORT_TO_FRONT_PORT(port) (port+1) enum port_numbers { -as7712_32x_sfp1, as7712_32x_sfp2, as7712_32x_sfp3, as7712_32x_sfp4, as7712_32x_sfp5, as7712_32x_sfp6, as7712_32x_sfp7, as7712_32x_sfp8, -as7712_32x_sfp9, as7712_32x_sfp10, as7712_32x_sfp11, as7712_32x_sfp12, as7712_32x_sfp13, as7712_32x_sfp14, as7712_32x_sfp15, as7712_32x_sfp16, -as7712_32x_sfp17, as7712_32x_sfp18, as7712_32x_sfp19, as7712_32x_sfp20, as7712_32x_sfp21, as7712_32x_sfp22, as7712_32x_sfp23, as7712_32x_sfp24, -as7712_32x_sfp25, as7712_32x_sfp26, as7712_32x_sfp27, as7712_32x_sfp28, as7712_32x_sfp29, as7712_32x_sfp30, as7712_32x_sfp31, as7712_32x_sfp32 +as7712_32x_port1, as7712_32x_port2, as7712_32x_port3, as7712_32x_port4, as7712_32x_port5, as7712_32x_port6, as7712_32x_port7, as7712_32x_port8, +as7712_32x_port9, as7712_32x_port10, as7712_32x_port11, as7712_32x_port12, as7712_32x_port13, as7712_32x_port14, as7712_32x_port15, as7712_32x_port16, +as7712_32x_port17, as7712_32x_port18, as7712_32x_port19, as7712_32x_port20, as7712_32x_port21, as7712_32x_port22, as7712_32x_port23, as7712_32x_port24, +as7712_32x_port25, as7712_32x_port26, as7712_32x_port27, as7712_32x_port28, as7712_32x_port29, as7712_32x_port30, as7712_32x_port31, as7712_32x_port32 }; #define I2C_DEV_ID(x) { #x, x} static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7712_32x_sfp1), -I2C_DEV_ID(as7712_32x_sfp2), -I2C_DEV_ID(as7712_32x_sfp3), -I2C_DEV_ID(as7712_32x_sfp4), -I2C_DEV_ID(as7712_32x_sfp5), -I2C_DEV_ID(as7712_32x_sfp6), -I2C_DEV_ID(as7712_32x_sfp7), -I2C_DEV_ID(as7712_32x_sfp8), -I2C_DEV_ID(as7712_32x_sfp9), -I2C_DEV_ID(as7712_32x_sfp10), -I2C_DEV_ID(as7712_32x_sfp11), -I2C_DEV_ID(as7712_32x_sfp12), -I2C_DEV_ID(as7712_32x_sfp13), -I2C_DEV_ID(as7712_32x_sfp14), -I2C_DEV_ID(as7712_32x_sfp15), -I2C_DEV_ID(as7712_32x_sfp16), -I2C_DEV_ID(as7712_32x_sfp17), -I2C_DEV_ID(as7712_32x_sfp18), -I2C_DEV_ID(as7712_32x_sfp19), -I2C_DEV_ID(as7712_32x_sfp20), -I2C_DEV_ID(as7712_32x_sfp21), -I2C_DEV_ID(as7712_32x_sfp22), -I2C_DEV_ID(as7712_32x_sfp23), -I2C_DEV_ID(as7712_32x_sfp24), -I2C_DEV_ID(as7712_32x_sfp25), -I2C_DEV_ID(as7712_32x_sfp26), -I2C_DEV_ID(as7712_32x_sfp27), -I2C_DEV_ID(as7712_32x_sfp28), -I2C_DEV_ID(as7712_32x_sfp29), -I2C_DEV_ID(as7712_32x_sfp30), -I2C_DEV_ID(as7712_32x_sfp31), -I2C_DEV_ID(as7712_32x_sfp32), +I2C_DEV_ID(as7712_32x_port1), +I2C_DEV_ID(as7712_32x_port2), +I2C_DEV_ID(as7712_32x_port3), +I2C_DEV_ID(as7712_32x_port4), +I2C_DEV_ID(as7712_32x_port5), +I2C_DEV_ID(as7712_32x_port6), +I2C_DEV_ID(as7712_32x_port7), +I2C_DEV_ID(as7712_32x_port8), +I2C_DEV_ID(as7712_32x_port9), +I2C_DEV_ID(as7712_32x_port10), +I2C_DEV_ID(as7712_32x_port11), +I2C_DEV_ID(as7712_32x_port12), +I2C_DEV_ID(as7712_32x_port13), +I2C_DEV_ID(as7712_32x_port14), +I2C_DEV_ID(as7712_32x_port15), +I2C_DEV_ID(as7712_32x_port16), +I2C_DEV_ID(as7712_32x_port17), +I2C_DEV_ID(as7712_32x_port18), +I2C_DEV_ID(as7712_32x_port19), +I2C_DEV_ID(as7712_32x_port20), +I2C_DEV_ID(as7712_32x_port21), +I2C_DEV_ID(as7712_32x_port22), +I2C_DEV_ID(as7712_32x_port23), +I2C_DEV_ID(as7712_32x_port24), +I2C_DEV_ID(as7712_32x_port25), +I2C_DEV_ID(as7712_32x_port26), +I2C_DEV_ID(as7712_32x_port27), +I2C_DEV_ID(as7712_32x_port28), +I2C_DEV_ID(as7712_32x_port29), +I2C_DEV_ID(as7712_32x_port30), +I2C_DEV_ID(as7712_32x_port31), +I2C_DEV_ID(as7712_32x_port32), { /* LIST END */ } }; MODULE_DEVICE_TABLE(i2c, sfp_device_id); /* Platform dependent --- */ -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - enum driver_type_e { DRIVER_TYPE_SFP_MSA, DRIVER_TYPE_SFP_DDM, @@ -251,24 +258,6 @@ struct eeprom_data { struct bin_attribute bin; /* eeprom data */ }; -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - struct qsfp_data { char valid; /* !=0 if registers are valid */ unsigned long last_updated; /* In jiffies */ @@ -276,7 +265,6 @@ struct qsfp_data { /* index 0 => tx_fail 1 => tx_disable 2 => rx_loss */ - u8 device_id; struct eeprom_data eeprom; }; @@ -285,16 +273,22 @@ struct sfp_port_data { struct mutex update_lock; enum driver_type_e driver_type; int port; /* CPLD port index */ - oom_driver_port_type_t port_type; u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; struct qsfp_data *qsfp; struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif }; +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf) { @@ -335,26 +329,8 @@ exit: return (status < 0) ? ERR_PTR(status) : data; } -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - return NULL; -} - /* Platform dependent --- */ -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - return 0; -} - static int sfp_is_port_present(struct i2c_client *client, int port) { struct sfp_port_data *data = i2c_get_clientdata(client); @@ -406,92 +382,6 @@ static ssize_t show_present(struct device *dev, struct device_attribute *da, } /* Platform dependent --- */ -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -654,82 +544,6 @@ static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute * return count; } -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, int data_len) { @@ -780,6 +594,7 @@ static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const cha } +#if (MULTIPAGE_SUPPORT == 0) static ssize_t sfp_port_write(struct sfp_port_data *data, const char *buf, loff_t off, size_t count) { @@ -814,7 +629,7 @@ static ssize_t sfp_port_write(struct sfp_port_data *data, mutex_unlock(&data->update_lock); return retval; } - +#endif static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -835,7 +650,11 @@ static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, return -ENODEV; } +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else return sfp_port_write(data, buf, off, count); +#endif } static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, @@ -898,6 +717,495 @@ abort: #endif } +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else static ssize_t sfp_port_read(struct sfp_port_data *data, char *buf, loff_t off, size_t count) { @@ -935,6 +1243,7 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, return retval; } +#endif static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -943,8 +1252,8 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, int present; struct sfp_port_data *data; DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); if (IS_ERR_VALUE(present)) { return present; @@ -955,10 +1264,18 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, return -ENODEV; } +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else return sfp_port_read(data, buf, off, count); +#endif } +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif { int err; @@ -967,7 +1284,11 @@ static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eep eeprom->attr.mode = S_IWUSR | S_IRUGO; eeprom->read = sfp_bin_read; eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else eeprom->size = EEPROM_SIZE; +#endif /* Create eeprom file */ err = sysfs_create_bin_file(kobj, eeprom); @@ -984,10 +1305,8 @@ static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute * return 0; } -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; +#if (MULTIPAGE_SUPPORT == 0) static int sfp_i2c_check_functionality(struct i2c_client *client) { #if USE_I2C_BLOCK_READ @@ -996,96 +1315,8 @@ static int sfp_i2c_check_functionality(struct i2c_client *client) return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); #endif } +#endif -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} static const struct attribute_group qsfp_group = { .attrs = qsfp_attributes, @@ -1097,10 +1328,12 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev int status; struct qsfp_data *qsfp; +#if (MULTIPAGE_SUPPORT == 0) if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } +#endif qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); if (!qsfp) { @@ -1115,7 +1348,11 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev } /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif if (status) { goto exit_remove; } @@ -1138,44 +1375,108 @@ exit: static int sfp_device_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { + int ret = 0; struct sfp_port_data *data = NULL; + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as7712_32x_port1 || dev_id->driver_data > as7712_32x_port32) { + return -ENXIO; + } + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); if (!data) { return -ENOMEM; } +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + i2c_set_clientdata(client, data); mutex_init(&data->update_lock); data->port = dev_id->driver_data; data->client = client; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; } /* Platform dependent --- */ -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) { sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); sysfs_remove_group(&client->dev.kobj, &qsfp_group); @@ -1185,18 +1486,18 @@ static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) static int sfp_device_remove(struct i2c_client *client) { + int ret = 0; struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); } - return 0; + kfree(data); + return ret; } /* Addresses scanned diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py index e460484f..32ced71b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py @@ -57,38 +57,38 @@ class OnlPlatform_x86_64_accton_as7712_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 self.new_i2c_devices([ - ('as7712_32x_sfp9', 0x50, 18), - ('as7712_32x_sfp10', 0x50, 19), - ('as7712_32x_sfp11', 0x50, 20), - ('as7712_32x_sfp12', 0x50, 21), - ('as7712_32x_sfp1', 0x50, 22), - ('as7712_32x_sfp2', 0x50, 23), - ('as7712_32x_sfp3', 0x50, 24), - ('as7712_32x_sfp4', 0x50, 25), - ('as7712_32x_sfp6', 0x50, 26), - ('as7712_32x_sfp5', 0x50, 27), - ('as7712_32x_sfp8', 0x50, 28), - ('as7712_32x_sfp7', 0x50, 29), - ('as7712_32x_sfp13', 0x50, 30), - ('as7712_32x_sfp14', 0x50, 31), - ('as7712_32x_sfp15', 0x50, 32), - ('as7712_32x_sfp16', 0x50, 33), - ('as7712_32x_sfp17', 0x50, 34), - ('as7712_32x_sfp18', 0x50, 35), - ('as7712_32x_sfp19', 0x50, 36), - ('as7712_32x_sfp20', 0x50, 37), - ('as7712_32x_sfp25', 0x50, 38), - ('as7712_32x_sfp26', 0x50, 39), - ('as7712_32x_sfp27', 0x50, 40), - ('as7712_32x_sfp28', 0x50, 41), - ('as7712_32x_sfp29', 0x50, 42), - ('as7712_32x_sfp30', 0x50, 43), - ('as7712_32x_sfp31', 0x50, 44), - ('as7712_32x_sfp32', 0x50, 45), - ('as7712_32x_sfp21', 0x50, 46), - ('as7712_32x_sfp22', 0x50, 47), - ('as7712_32x_sfp23', 0x50, 48), - ('as7712_32x_sfp24', 0x50, 49), + ('as7712_32x_port9', 0x50, 18), + ('as7712_32x_port10', 0x50, 19), + ('as7712_32x_port11', 0x50, 20), + ('as7712_32x_port12', 0x50, 21), + ('as7712_32x_port1', 0x50, 22), + ('as7712_32x_port2', 0x50, 23), + ('as7712_32x_port3', 0x50, 24), + ('as7712_32x_port4', 0x50, 25), + ('as7712_32x_port6', 0x50, 26), + ('as7712_32x_port5', 0x50, 27), + ('as7712_32x_port8', 0x50, 28), + ('as7712_32x_port7', 0x50, 29), + ('as7712_32x_port13', 0x50, 30), + ('as7712_32x_port14', 0x50, 31), + ('as7712_32x_port15', 0x50, 32), + ('as7712_32x_port16', 0x50, 33), + ('as7712_32x_port17', 0x50, 34), + ('as7712_32x_port18', 0x50, 35), + ('as7712_32x_port19', 0x50, 36), + ('as7712_32x_port20', 0x50, 37), + ('as7712_32x_port25', 0x50, 38), + ('as7712_32x_port26', 0x50, 39), + ('as7712_32x_port27', 0x50, 40), + ('as7712_32x_port28', 0x50, 41), + ('as7712_32x_port29', 0x50, 42), + ('as7712_32x_port30', 0x50, 43), + ('as7712_32x_port31', 0x50, 44), + ('as7712_32x_port32', 0x50, 45), + ('as7712_32x_port21', 0x50, 46), + ('as7712_32x_port22', 0x50, 47), + ('as7712_32x_port23', 0x50, 48), + ('as7712_32x_port24', 0x50, 49), ]) self.new_i2c_device('24c02', 0x57, 1) From c9400fb628c5699b2d9b940bf7f578ae24164381 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 15 Nov 2017 16:42:35 +0800 Subject: [PATCH 066/244] [as7716-32x] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as7716-32x-sfp.c | 1653 ++++++++++++++--- .../x86_64_accton_as7716_32x_r0/__init__.py | 64 +- 2 files changed, 1447 insertions(+), 270 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c index 432e9b7d..e4926c1f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c @@ -1,8 +1,7 @@ /* - * An hwmon driver for accton as7716_32x sfp + * SFP driver for accton as7716 sfp * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang + * Copyright (C) Brandon Chuang * * Based on ad7414.c * Copyright 2006 Stefan Roese , DENX Software Engineering @@ -31,326 +30,1504 @@ #include #include #include +#include -#define BIT_INDEX(i) (1UL << (i)) +#define DRIVER_NAME "as7716_32x_sfp" /* Platform dependent */ +#define DEBUG_MODE 0 -/* Addresses scanned +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* Each client has this additional data +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -struct as7716_32x_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u32 is_present; /* present status */ -}; +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif -static struct as7716_32x_sfp_data *as7716_32x_sfp_update_device(struct device *dev); static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da,char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -enum as7716_32x_sfp_sysfs_attributes { - SFP_PORT_NUMBER, - SFP_IS_PRESENT, - SFP_IS_PRESENT_ALL, - SFP_EEPROM +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL }; -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, SFP_IS_PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); -static struct attribute *as7716_32x_sfp_attributes[] = { +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, NULL }; +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +as7716_32x_port1, as7716_32x_port2, as7716_32x_port3, as7716_32x_port4, as7716_32x_port5, as7716_32x_port6, as7716_32x_port7, as7716_32x_port8, +as7716_32x_port9, as7716_32x_port10, as7716_32x_port11, as7716_32x_port12, as7716_32x_port13, as7716_32x_port14, as7716_32x_port15, as7716_32x_port16, +as7716_32x_port17, as7716_32x_port18, as7716_32x_port19, as7716_32x_port20, as7716_32x_port21, as7716_32x_port22, as7716_32x_port23, as7716_32x_port24, +as7716_32x_port25, as7716_32x_port26, as7716_32x_port27, as7716_32x_port28, as7716_32x_port29, as7716_32x_port30, as7716_32x_port31, as7716_32x_port32 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as7716_32x_port1), +I2C_DEV_ID(as7716_32x_port2), +I2C_DEV_ID(as7716_32x_port3), +I2C_DEV_ID(as7716_32x_port4), +I2C_DEV_ID(as7716_32x_port5), +I2C_DEV_ID(as7716_32x_port6), +I2C_DEV_ID(as7716_32x_port7), +I2C_DEV_ID(as7716_32x_port8), +I2C_DEV_ID(as7716_32x_port9), +I2C_DEV_ID(as7716_32x_port10), +I2C_DEV_ID(as7716_32x_port11), +I2C_DEV_ID(as7716_32x_port12), +I2C_DEV_ID(as7716_32x_port13), +I2C_DEV_ID(as7716_32x_port14), +I2C_DEV_ID(as7716_32x_port15), +I2C_DEV_ID(as7716_32x_port16), +I2C_DEV_ID(as7716_32x_port17), +I2C_DEV_ID(as7716_32x_port18), +I2C_DEV_ID(as7716_32x_port19), +I2C_DEV_ID(as7716_32x_port20), +I2C_DEV_ID(as7716_32x_port21), +I2C_DEV_ID(as7716_32x_port22), +I2C_DEV_ID(as7716_32x_port23), +I2C_DEV_ID(as7716_32x_port24), +I2C_DEV_ID(as7716_32x_port25), +I2C_DEV_ID(as7716_32x_port26), +I2C_DEV_ID(as7716_32x_port27), +I2C_DEV_ID(as7716_32x_port28), +I2C_DEV_ID(as7716_32x_port29), +I2C_DEV_ID(as7716_32x_port30), +I2C_DEV_ID(as7716_32x_port31), +I2C_DEV_ID(as7716_32x_port32), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf) { struct i2c_client *client = to_i2c_client(dev); - struct as7716_32x_sfp_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->port+1); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); } -/* Error-check the CPLD read results. */ -#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ -do { \ - _rv = (_read_expr); \ - if(_rv < 0) { \ - return sprintf(_buf, "READ ERROR\n"); \ - } \ - if(_invert) { \ - _rv = ~_rv; \ - } \ - _rv &= 0xFF; \ -} while(0) +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0; + int status = -1; + u8 regs[] = {0x30, 0x31, 0x32, 0x33}; + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 1~32 */ + data->present = 0; + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = accton_i2c_cpld_read(0x60, regs[i]); + + if (status < 0) { + DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); + data->present |= (u64)status << (i*8); + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ static ssize_t show_present(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); - if(attr->index == SFP_IS_PRESENT_ALL) { - int values[4]; - /* - * Report the SFP_PRESENCE status for all ports. - */ - - /* SFP_PRESENT Ports 1-8 */ - VALIDATED_READ(buf, values[0], accton_i2c_cpld_read(0x60, 0x30), 1); - /* SFP_PRESENT Ports 9-16 */ - VALIDATED_READ(buf, values[1], accton_i2c_cpld_read(0x60, 0x31), 1); - /* SFP_PRESENT Ports 17-24 */ - VALIDATED_READ(buf, values[2], accton_i2c_cpld_read(0x60, 0x32), 1); - /* SFP_PRESENT Ports 25-32 */ - VALIDATED_READ(buf, values[3], accton_i2c_cpld_read(0x60, 0x33), 1); - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); - } - else { /* SFP_IS_PRESENT */ - struct as7716_32x_sfp_data *data = as7716_32x_sfp_update_device(dev); - - if (!data->valid) { - return -EIO; + if (PRESENT_ALL == attr->index) { + int i; + u8 values[4] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); } - - return sprintf(buf, "%d\n", data->is_present); + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3]); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d\n", present); } } +/* Platform dependent --- */ -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf) { - struct as7716_32x_sfp_data *data = as7716_32x_sfp_update_device(dev); + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); - if (!data->valid) { - return 0; + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; } - if (!data->is_present) { - return 0; + if (present == 0) { + /* port is not present */ + return -ENXIO; } - memcpy(buf, data->eeprom, sizeof(data->eeprom)); + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } - return sizeof(data->eeprom); + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); } -static const struct attribute_group as7716_32x_sfp_group = { - .attrs = as7716_32x_sfp_attributes, +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, }; -static int as7716_32x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) { - struct as7716_32x_sfp_data *data; int status; + struct qsfp_data *qsfp; - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } +#endif - data = kzalloc(sizeof(struct as7716_32x_sfp_data), GFP_KERNEL); - if (!data) { + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { status = -ENOMEM; goto exit; } - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "chip found\n"); - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7716_32x_sfp_group); + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); if (status) { goto exit_free; } - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { goto exit_remove; } - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); return 0; exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7716_32x_sfp_group); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); exit_free: - kfree(data); + kfree(qsfp); exit: return status; } -static int as7716_32x_sfp_remove(struct i2c_client *client) +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) { - struct as7716_32x_sfp_data *data = i2c_get_clientdata(client); + int ret = 0; + struct sfp_port_data *data = NULL; - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7716_32x_sfp_group); - kfree(data); - - return 0; -} - -enum port_numbers { -as7716_32x_sfp1, as7716_32x_sfp2, as7716_32x_sfp3, as7716_32x_sfp4, -as7716_32x_sfp5, as7716_32x_sfp6, as7716_32x_sfp7, as7716_32x_sfp8, -as7716_32x_sfp9, as7716_32x_sfp10,as7716_32x_sfp11,as7716_32x_sfp12, -as7716_32x_sfp13,as7716_32x_sfp14,as7716_32x_sfp15,as7716_32x_sfp16, -as7716_32x_sfp17,as7716_32x_sfp18,as7716_32x_sfp19,as7716_32x_sfp20, -as7716_32x_sfp21,as7716_32x_sfp22,as7716_32x_sfp23,as7716_32x_sfp24, -as7716_32x_sfp25,as7716_32x_sfp26,as7716_32x_sfp27,as7716_32x_sfp28, -as7716_32x_sfp29,as7716_32x_sfp30,as7716_32x_sfp31,as7716_32x_sfp32 -}; - -static const struct i2c_device_id as7716_32x_sfp_id[] = { -{ "as7716_32x_sfp1", as7716_32x_sfp1 }, { "as7716_32x_sfp2", as7716_32x_sfp2 }, -{ "as7716_32x_sfp3", as7716_32x_sfp3 }, { "as7716_32x_sfp4", as7716_32x_sfp4 }, -{ "as7716_32x_sfp5", as7716_32x_sfp5 }, { "as7716_32x_sfp6", as7716_32x_sfp6 }, -{ "as7716_32x_sfp7", as7716_32x_sfp7 }, { "as7716_32x_sfp8", as7716_32x_sfp8 }, -{ "as7716_32x_sfp9", as7716_32x_sfp9 }, { "as7716_32x_sfp10", as7716_32x_sfp10 }, -{ "as7716_32x_sfp11", as7716_32x_sfp11 }, { "as7716_32x_sfp12", as7716_32x_sfp12 }, -{ "as7716_32x_sfp13", as7716_32x_sfp13 }, { "as7716_32x_sfp14", as7716_32x_sfp14 }, -{ "as7716_32x_sfp15", as7716_32x_sfp15 }, { "as7716_32x_sfp16", as7716_32x_sfp16 }, -{ "as7716_32x_sfp17", as7716_32x_sfp17 }, { "as7716_32x_sfp18", as7716_32x_sfp18 }, -{ "as7716_32x_sfp19", as7716_32x_sfp19 }, { "as7716_32x_sfp20", as7716_32x_sfp20 }, -{ "as7716_32x_sfp21", as7716_32x_sfp21 }, { "as7716_32x_sfp22", as7716_32x_sfp22 }, -{ "as7716_32x_sfp23", as7716_32x_sfp23 }, { "as7716_32x_sfp24", as7716_32x_sfp24 }, -{ "as7716_32x_sfp25", as7716_32x_sfp25 }, { "as7716_32x_sfp26", as7716_32x_sfp26 }, -{ "as7716_32x_sfp27", as7716_32x_sfp27 }, { "as7716_32x_sfp28", as7716_32x_sfp28 }, -{ "as7716_32x_sfp29", as7716_32x_sfp29 }, { "as7716_32x_sfp30", as7716_32x_sfp30 }, -{ "as7716_32x_sfp31", as7716_32x_sfp31 }, { "as7716_32x_sfp32", as7716_32x_sfp32 }, -{} -}; -MODULE_DEVICE_TABLE(i2c, as7716_32x_sfp_id); - -static struct i2c_driver as7716_32x_sfp_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as7716_32x_sfp", - }, - .probe = as7716_32x_sfp_probe, - .remove = as7716_32x_sfp_remove, - .id_table = as7716_32x_sfp_id, - .address_list = normal_i2c, -}; - -static int as7716_32x_sfp_read_block(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - result = 0; - -abort: - return result; -} - -static struct as7716_32x_sfp_data *as7716_32x_sfp_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7716_32x_sfp_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status = -1; - int i = 0; - u8 cpld_reg = 0x30 + (data->port/8); - - data->valid = 0; - - /* Read present status of the specified port number */ - data->is_present = 0; - status = accton_i2c_cpld_read(0x60, cpld_reg); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x60) reg(0x%x) err %d\n", cpld_reg, status); - goto exit; - } - - data->is_present = (status & (1 << (data->port % 8))) ? 0 : 1; - - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if (data->is_present) { - /* read eeprom */ - for (i = 0; i < sizeof(data->eeprom)/I2C_SMBUS_BLOCK_MAX; i++) { - status = as7716_32x_sfp_read_block(client, i*I2C_SMBUS_BLOCK_MAX, - data->eeprom+(i*I2C_SMBUS_BLOCK_MAX), - I2C_SMBUS_BLOCK_MAX); - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", data->port); - goto exit; - } - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} - -static int __init as7716_32x_sfp_init(void) -{ - extern int platform_accton_as7716_32x(void); - if (!platform_accton_as7716_32x()) { + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { return -ENODEV; } - return i2c_add_driver(&as7716_32x_sfp_driver); + if (dev_id->driver_data < as7716_32x_port1 || dev_id->driver_data > as7716_32x_port32) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; } -static void __exit as7716_32x_sfp_exit(void) +static int sfp_device_remove(struct i2c_client *client) { - i2c_del_driver(&as7716_32x_sfp_driver); + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif + + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as7716_32x_sfp driver"); MODULE_LICENSE("GPL"); -module_init(as7716_32x_sfp_init); -module_exit(as7716_32x_sfp_exit); +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py index df5a257a..ae270587 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py @@ -52,38 +52,38 @@ class OnlPlatform_x86_64_accton_as7716_32x_r0(OnlPlatformAccton, ('pca9548', 0x75, 2), # initialize QSFP port 1-32 - ('as7716_32x_sfp9', 0x50, 25), - ('as7716_32x_sfp10', 0x50, 26), - ('as7716_32x_sfp11', 0x50, 27), - ('as7716_32x_sfp12', 0x50, 28), - ('as7716_32x_sfp1', 0x50, 29), - ('as7716_32x_sfp2', 0x50, 30), - ('as7716_32x_sfp3', 0x50, 31), - ('as7716_32x_sfp4', 0x50, 32), - ('as7716_32x_sfp6', 0x50, 33), - ('as7716_32x_sfp5', 0x50, 34), - ('as7716_32x_sfp8', 0x50, 35), - ('as7716_32x_sfp7', 0x50, 36), - ('as7716_32x_sfp13', 0x50, 37), - ('as7716_32x_sfp14', 0x50, 38), - ('as7716_32x_sfp15', 0x50, 39), - ('as7716_32x_sfp16', 0x50, 40), - ('as7716_32x_sfp17', 0x50, 41), - ('as7716_32x_sfp18', 0x50, 42), - ('as7716_32x_sfp19', 0x50, 43), - ('as7716_32x_sfp20', 0x50, 44), - ('as7716_32x_sfp25', 0x50, 45), - ('as7716_32x_sfp26', 0x50, 46), - ('as7716_32x_sfp27', 0x50, 47), - ('as7716_32x_sfp28', 0x50, 48), - ('as7716_32x_sfp29', 0x50, 49), - ('as7716_32x_sfp30', 0x50, 50), - ('as7716_32x_sfp31', 0x50, 51), - ('as7716_32x_sfp32', 0x50, 52), - ('as7716_32x_sfp21', 0x50, 53), - ('as7716_32x_sfp22', 0x50, 54), - ('as7716_32x_sfp23', 0x50, 55), - ('as7716_32x_sfp24', 0x50, 56), + ('as7716_32x_port9', 0x50, 25), + ('as7716_32x_port10', 0x50, 26), + ('as7716_32x_port11', 0x50, 27), + ('as7716_32x_port12', 0x50, 28), + ('as7716_32x_port1', 0x50, 29), + ('as7716_32x_port2', 0x50, 30), + ('as7716_32x_port3', 0x50, 31), + ('as7716_32x_port4', 0x50, 32), + ('as7716_32x_port6', 0x50, 33), + ('as7716_32x_port5', 0x50, 34), + ('as7716_32x_port8', 0x50, 35), + ('as7716_32x_port7', 0x50, 36), + ('as7716_32x_port13', 0x50, 37), + ('as7716_32x_port14', 0x50, 38), + ('as7716_32x_port15', 0x50, 39), + ('as7716_32x_port16', 0x50, 40), + ('as7716_32x_port17', 0x50, 41), + ('as7716_32x_port18', 0x50, 42), + ('as7716_32x_port19', 0x50, 43), + ('as7716_32x_port20', 0x50, 44), + ('as7716_32x_port25', 0x50, 45), + ('as7716_32x_port26', 0x50, 46), + ('as7716_32x_port27', 0x50, 47), + ('as7716_32x_port28', 0x50, 48), + ('as7716_32x_port29', 0x50, 49), + ('as7716_32x_port30', 0x50, 50), + ('as7716_32x_port31', 0x50, 51), + ('as7716_32x_port32', 0x50, 52), + ('as7716_32x_port21', 0x50, 53), + ('as7716_32x_port22', 0x50, 54), + ('as7716_32x_port23', 0x50, 55), + ('as7716_32x_port24', 0x50, 56), ('24c02', 0x56, 0), ]) From 8c1dbf1d482d1b70a0b85e0f2f046ba731e37968 Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Wed, 15 Nov 2017 11:23:48 -0800 Subject: [PATCH 067/244] SFP28 CR type and length fix --- packages/base/any/onlp/src/sff/module/inc/sff/8472.h | 1 - packages/base/any/onlp/src/sff/module/src/sff.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/8472.h b/packages/base/any/onlp/src/sff/module/inc/sff/8472.h index 6b7a1161..20b52d70 100644 --- a/packages/base/any/onlp/src/sff/module/inc/sff/8472.h +++ b/packages/base/any/onlp/src/sff/module/inc/sff/8472.h @@ -968,7 +968,6 @@ _sff8472_media_sfp28_cr(const uint8_t* idprom) /* module should be sfp */ if (!SFF8472_MODULE_SFP(idprom)) return 0; - if (idprom[2] != SFF8472_CONN_NOSEP) return 0; if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) == 0) return 0; if (idprom[12] == 0xFF) return 1; diff --git a/packages/base/any/onlp/src/sff/module/src/sff.c b/packages/base/any/onlp/src/sff/module/src/sff.c index bb916944..281c4450 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff.c +++ b/packages/base/any/onlp/src/sff/module/src/sff.c @@ -472,6 +472,7 @@ sff_eeprom_parse_standard__(sff_eeprom_t* se, uint8_t* eeprom) se->info.length = se->eeprom[146]; break; case SFF_SFP_TYPE_SFP: + case SFF_SFP_TYPE_SFP28: se->info.length = se->eeprom[18]; break; default: From b43c7aa7e3e1218152e9bf1278400b3289c653af Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 15 Nov 2017 20:48:13 +0000 Subject: [PATCH 068/244] Add unit tests for additional 25G CR cables. --- .../base/any/onlp/src/sff/module/src/sff_db.c | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/packages/base/any/onlp/src/sff/module/src/sff_db.c b/packages/base/any/onlp/src/sff/module/src/sff_db.c index 095aecdb..15f69fbf 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_db.c +++ b/packages/base/any/onlp/src/sff/module/src/sff_db.c @@ -34,6 +34,8 @@ #define SFF_25G_BASE_SR_PROPERTIES \ SFF_SFP_TYPE_SFP28, "SFP28", SFF_MODULE_TYPE_25G_BASE_SR, "25GBASE-SR", SFF_MEDIA_TYPE_FIBER, "Fiber",SFF_MODULE_CAPS_F_25G +#define SFF_25G_BASE_CR_PROPERTIES \ + SFF_SFP_TYPE_SFP28, "SFP28", SFF_MODULE_TYPE_25G_BASE_CR, "25GBASE-CR", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_25G #define SFF_40G_BASE_SR4_PROPERTIES \ SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_SR4, "40GBASE-SR4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_40G @@ -1655,6 +1657,122 @@ static sff_db_entry_t sff_database__[] = }, }, }, + { + { + .eeprom = { + 0x03, 0x04, 0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0d, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x43, 0x43, 0x47, 0x46, 0x2d, 0x43, + 0x31, 0x30, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x00, 0x00, 0x17, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x37, 0x31, 0x34, 0x31, 0x30, 0x34, 0x35, 0x55, + 0x47, 0x56, 0x20, 0x20, 0x31, 0x37, 0x30, 0x34, 0x30, 0x38, 0x20, 0x20, 0x00, 0x00, 0x08, 0x83, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + }, + .info = { + "Amphenol ", + "NDCCGF-C104 ", + "APF17141045UGV ", + SFF_25G_BASE_CR_PROPERTIES, + 1, + } , + }, + }, + { + { + .eeprom = { + 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0b, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x43, 0x43, 0x47, 0x46, 0x2d, 0x48, + 0x33, 0x30, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xaf, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x34, 0x35, 0x33, 0x30, 0x31, 0x33, 0x33, + 0x50, 0x31, 0x20, 0x20, 0x31, 0x36, 0x31, 0x31, 0x31, 0x36, 0x20, 0x20, 0x00, 0x00, 0x08, 0x41, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .info = { + "Amphenol ", + "NDCCGF-H301 ", + "APF164530133P1 ", + SFF_25G_BASE_CR_PROPERTIES, + 1, + } , + }, + }, + { + { + .eeprom = { + 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0b, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x51, 0x47, 0x46, 0x2d, 0x48, + 0x33, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xbf, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x35, 0x30, 0x33, 0x30, 0x33, 0x31, 0x4c, + 0x50, 0x44, 0x20, 0x20, 0x31, 0x36, 0x31, 0x32, 0x31, 0x37, 0x20, 0x20, 0x00, 0x00, 0x08, 0x6b, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .info = { + "Amphenol ", + "NDAQGF-H303 ", + "APF16503031LPD ", + SFF_25G_BASE_CR_PROPERTIES, + 3, + }, + }, + }, + { + { + .eeprom = { + 0x03, 0x04, 0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x51, 0x47, 0x46, 0x2d, 0x30, + 0x30, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x32, 0x35, 0x30, 0x30, 0x33, 0x31, 0x4b, + 0x43, 0x55, 0x20, 0x20, 0x31, 0x36, 0x30, 0x36, 0x32, 0x35, 0x20, 0x20, 0x00, 0x00, 0x08, 0x6f, + 0x44, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + }, + .info = { + "Amphenol ", + "NDAQGF-0003 ", + "APF16250031KCU ", + SFF_25G_BASE_CR_PROPERTIES, + 3, + }, + }, + }, { { .eeprom = { From c507789122975ae4138f07f02f7bc7bcf2d89963 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 16 Nov 2017 11:28:58 +0800 Subject: [PATCH 069/244] [as5812-54t] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as5812-54t-sfp.c | 1668 ++++++++++++++--- .../x86_64_accton_as5812_54t_r0/__init__.py | 12 +- 2 files changed, 1432 insertions(+), 248 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c index 88bf552d..0f1b7aac 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c @@ -1,8 +1,7 @@ /* - * An hwmon driver for accton as5812_54t sfp + * SFP driver for accton as5812_54t sfp * - * Copyright (C) 2015 Accton Technology Corporation. - * Brandon Chuang + * Copyright (C) Brandon Chuang * * Based on ad7414.c * Copyright 2006 Stefan Roese , DENX Software Engineering @@ -31,288 +30,1473 @@ #include #include #include +#include -#define QSFP_PORT_START_INDEX 49 -#define BIT_INDEX(i) (1ULL << (i)) +#define DRIVER_NAME "as5812_54t_sfp" -/* Addresses scanned +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* Each client has this additional data +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -struct as5812_54t_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u8 status; /* bit0:port49, bit1:port50 and so on */ -}; +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif -static struct as5812_54t_sfp_data *as5812_54t_sfp_update_device(struct device *dev, int update_eeprom); static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); -enum as5812_54t_sfp_sysfs_attributes { - SFP_IS_PRESENT, - SFP_PORT_NUMBER, - SFP_EEPROM, - SFP_IS_PRESENT_ALL, +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL }; -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_status, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_status,NULL, SFP_IS_PRESENT_ALL); +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); -static struct attribute *as5812_54t_sfp_attributes[] = { - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - NULL +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL }; -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54t_sfp_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n",data->port); -} - -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as5812_54t_sfp_data *data = as5812_54t_sfp_update_device(dev, 0); - - if (attr->index == SFP_IS_PRESENT) { - u8 val; - - val = (data->status & BIT_INDEX(data->port - QSFP_PORT_START_INDEX)) ? 0 : 1; - return sprintf(buf, "%d", val); - } - else { /* SFP_IS_PRESENT_ALL */ - return sprintf(buf, "%.2x\n", ~data->status); - } -} - -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct as5812_54t_sfp_data *data = as5812_54t_sfp_update_device(dev, 1); - - if (!data->valid) { - return 0; - } - - if ((data->status & BIT_INDEX(data->port - QSFP_PORT_START_INDEX)) != 0) { - return 0; - } - - memcpy(buf, data->eeprom, sizeof(data->eeprom)); - - return sizeof(data->eeprom); -} - -static const struct attribute_group as5812_54t_sfp_group = { - .attrs = as5812_54t_sfp_attributes, -}; - -static int as5812_54t_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as5812_54t_sfp_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as5812_54t_sfp_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5812_54t_sfp_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as5812_54t_sfp_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as5812_54t_sfp_remove(struct i2c_client *client) -{ - struct as5812_54t_sfp_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as5812_54t_sfp_group); - kfree(data); - - return 0; -} +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+49) enum port_numbers { -as5812_54t_qsfp49 = 49, -as5812_54t_qsfp50, -as5812_54t_qsfp51, -as5812_54t_qsfp52, -as5812_54t_qsfp53, -as5812_54t_qsfp54 +as5812_54t_port49, +as5812_54t_port50, +as5812_54t_port51, +as5812_54t_port52, +as5812_54t_port53, +as5812_54t_port54 }; -static const struct i2c_device_id as5812_54t_sfp_id[] = { -{ "as5812_54t_qsfp49", as5812_54t_qsfp49 }, { "as5812_54t_qsfp50", as5812_54t_qsfp50 }, -{ "as5812_54t_qsfp51", as5812_54t_qsfp51 }, { "as5812_54t_qsfp52", as5812_54t_qsfp52 }, -{ "as5812_54t_qsfp53", as5812_54t_qsfp53 }, { "as5812_54t_qsfp54", as5812_54t_qsfp54 }, -{} -}; -MODULE_DEVICE_TABLE(i2c, as5812_54t_sfp_id); +#define I2C_DEV_ID(x) { #x, x} -static struct i2c_driver as5812_54t_sfp_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as5812_54t_sfp", - }, - .probe = as5812_54t_sfp_probe, - .remove = as5812_54t_sfp_remove, - .id_table = as5812_54t_sfp_id, - .address_list = normal_i2c, +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as5812_54t_port49), +I2C_DEV_ID(as5812_54t_port50), +I2C_DEV_ID(as5812_54t_port51), +I2C_DEV_ID(as5812_54t_port52), +I2C_DEV_ID(as5812_54t_port53), +I2C_DEV_ID(as5812_54t_port54), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP }; -static int as5812_54t_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data) +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) { - int result = i2c_smbus_read_byte_data(client, command); - - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } - - *data = (u8)result; - result = 0; - -abort: - return result; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); } -static struct as5812_54t_sfp_data *as5812_54t_sfp_update_device(struct device *dev, int update_eeprom) +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) { - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54t_sfp_data *data = i2c_get_clientdata(client); + struct sfp_port_data *data = i2c_get_clientdata(client); + int status = -1; - mutex_lock(&data->update_lock); + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid || update_eeprom) { - int status = -1; - int i = 0; - - data->valid = 0; - //dev_dbg(&client->dev, "Starting as5812_54t sfp status update\n"); - data->status = 0xFF; - - /* - * Bring QSFPs out of reset, - * This is a temporary fix until the QSFP+_MOD_RST register - * can be exposed through the driver. - */ - accton_i2c_cpld_write(0x60, 0x23, 0x3F); - - /* Read present status of port 49-54(QSFP port) */ - status = accton_i2c_cpld_read(0x60, 0x22); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x60) reg(0x22) err %d\n", status); - } - else { - data->status = status & 0x3F; /* (u32)status */ - } - - if (update_eeprom) { - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if ((data->status & BIT_INDEX(data->port - QSFP_PORT_START_INDEX)) == 0) { - /* read eeprom */ - for (i = 0; i < sizeof(data->eeprom); i++) { - status = as5812_54t_sfp_read_byte(client, i, data->eeprom + i); - - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", - data->port); - goto exit; - } - } - } - } - - data->valid = 1; - data->last_updated = jiffies; + /* Read present status of port 49~54 */ + data->present = 0; + + status = accton_i2c_cpld_read(0x60, 0x22); + if (status < 0) { + DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); + goto exit; } + + data->present |= (u64)status; + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + /* Return values 49 -> 54 in order */ + return sprintf(buf, "%.2x\n", (unsigned int)~data->present); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; exit: - mutex_unlock(&data->update_lock); - - return data; + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; } -static int __init as5812_54t_sfp_init(void) +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) { - extern int platform_accton_as5812_54t(void); - if (!platform_accton_as5812_54t()) { + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ return -ENODEV; } - return i2c_add_driver(&as5812_54t_sfp_driver); +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif } -static void __exit as5812_54t_sfp_exit(void) +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) { - i2c_del_driver(&as5812_54t_sfp_driver); +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + /* + * Bring QSFPs out of reset, + * This is a temporary fix until the QSFP+_MOD_RST register + * can be exposed through the driver. + */ + accton_i2c_cpld_write(0x60, 0x23, 0x3F); + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as5812_54t_port49 || dev_id->driver_data > as5812_54t_port54) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif + + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5812_54t_sfp driver"); MODULE_LICENSE("GPL"); -module_init(as5812_54t_sfp_init); -module_exit(as5812_54t_sfp_exit); +module_init(sfp_init); +module_exit(sfp_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py index a8976b92..2326fb41 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py @@ -23,12 +23,12 @@ class OnlPlatform_x86_64_accton_as5812_54t_r0(OnlPlatformAccton, self.new_i2c_device('pca9548', 0x71, 0) # Initialize QSFP devices - self.new_i2c_device('as5812_54t_qsfp49', 0x50, 4) - self.new_i2c_device('as5812_54t_qsfp50', 0x50, 6) - self.new_i2c_device('as5812_54t_qsfp51', 0x50, 3) - self.new_i2c_device('as5812_54t_qsfp52', 0x50, 5) - self.new_i2c_device('as5812_54t_qsfp53', 0x50, 7) - self.new_i2c_device('as5812_54t_qsfp54', 0x50, 2) + self.new_i2c_device('as5812_54t_port49', 0x50, 4) + self.new_i2c_device('as5812_54t_port50', 0x50, 6) + self.new_i2c_device('as5812_54t_port51', 0x50, 3) + self.new_i2c_device('as5812_54t_port52', 0x50, 5) + self.new_i2c_device('as5812_54t_port53', 0x50, 7) + self.new_i2c_device('as5812_54t_port54', 0x50, 2) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From 00f7a696322332d9bdf4b85c0060bac823583745 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 16 Nov 2017 11:44:39 +0800 Subject: [PATCH 070/244] [as6712-32x] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as6712-32x-sfp.c | 1727 ++++++++++++++--- .../x86_64_accton_as6712_32x_r0/__init__.py | 2 +- 2 files changed, 1442 insertions(+), 287 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c index bb064b46..7f580a89 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c @@ -1,7 +1,7 @@ /* - * An hwmon driver for accton as6712_32x sfp + * SFP driver for accton as6712_32x sfp * - * Copyright (C) 2014 Accton Technology Corporation. + * Copyright (C) Brandon Chuang * * Based on ad7414.c * Copyright 2006 Stefan Roese , DENX Software Engineering @@ -30,348 +30,1503 @@ #include #include #include +#include -#define BIT_INDEX(i) (1ULL << (i)) +#define DRIVER_NAME "as6712_32x_sfp" -/* Addresses scanned +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* Each client has this additional data +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -struct as6712_32x_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u64 is_present; /* present status */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int as6712_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL }; -static struct as6712_32x_sfp_data *as6712_32x_sfp_update_device(struct device *dev, int update_eeprom); -static ssize_t show_present(struct device *dev, struct device_attribute *da,char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +as6712_32x_port1, as6712_32x_port2, as6712_32x_port3, as6712_32x_port4, as6712_32x_port5, as6712_32x_port6, as6712_32x_port7, as6712_32x_port8, +as6712_32x_port9, as6712_32x_port10, as6712_32x_port11, as6712_32x_port12, as6712_32x_port13, as6712_32x_port14, as6712_32x_port15, as6712_32x_port16, +as6712_32x_port17, as6712_32x_port18, as6712_32x_port19, as6712_32x_port20, as6712_32x_port21, as6712_32x_port22, as6712_32x_port23, as6712_32x_port24, +as6712_32x_port25, as6712_32x_port26, as6712_32x_port27, as6712_32x_port28, as6712_32x_port29, as6712_32x_port30, as6712_32x_port31, as6712_32x_port32 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as6712_32x_port1), +I2C_DEV_ID(as6712_32x_port2), +I2C_DEV_ID(as6712_32x_port3), +I2C_DEV_ID(as6712_32x_port4), +I2C_DEV_ID(as6712_32x_port5), +I2C_DEV_ID(as6712_32x_port6), +I2C_DEV_ID(as6712_32x_port7), +I2C_DEV_ID(as6712_32x_port8), +I2C_DEV_ID(as6712_32x_port9), +I2C_DEV_ID(as6712_32x_port10), +I2C_DEV_ID(as6712_32x_port11), +I2C_DEV_ID(as6712_32x_port12), +I2C_DEV_ID(as6712_32x_port13), +I2C_DEV_ID(as6712_32x_port14), +I2C_DEV_ID(as6712_32x_port15), +I2C_DEV_ID(as6712_32x_port16), +I2C_DEV_ID(as6712_32x_port17), +I2C_DEV_ID(as6712_32x_port18), +I2C_DEV_ID(as6712_32x_port19), +I2C_DEV_ID(as6712_32x_port20), +I2C_DEV_ID(as6712_32x_port21), +I2C_DEV_ID(as6712_32x_port22), +I2C_DEV_ID(as6712_32x_port23), +I2C_DEV_ID(as6712_32x_port24), +I2C_DEV_ID(as6712_32x_port25), +I2C_DEV_ID(as6712_32x_port26), +I2C_DEV_ID(as6712_32x_port27), +I2C_DEV_ID(as6712_32x_port28), +I2C_DEV_ID(as6712_32x_port29), +I2C_DEV_ID(as6712_32x_port30), +I2C_DEV_ID(as6712_32x_port31), +I2C_DEV_ID(as6712_32x_port32), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf); -static int as6712_32x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data); -extern int as6712_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as6712_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); -//extern int accton_i2c_cpld_mux_get_index(int adap_index); - -enum as6712_32x_sfp_sysfs_attributes { - SFP_IS_PRESENT, - SFP_EEPROM, - SFP_PORT_NUMBER, - SFP_IS_PRESENT_ALL -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, SFP_IS_PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); - -static struct attribute *as6712_32x_sfp_attributes[] = { - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - NULL -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) + char *buf) { - struct i2c_client *client = to_i2c_client(dev); - struct as6712_32x_sfp_data *data = i2c_get_clientdata(client); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0, j = 0; + int status = -1; - return sprintf(buf, "%d\n", data->port+1); + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 1~32 */ + data->present = 0; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + status = as6712_32x_i2c_cpld_read(0x62+i*2, 0xA+j); + + if (status < 0) { + DEBUG_PRINT("cpld(0x%x) reg(0x%x) err %d", 0x62+i*2, 0xA+j, status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); + data->present |= (u64)status << ((i*16) + (j*8)); + } + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; } -/* Error-check the CPLD read results. */ -#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ -do { \ - _rv = (_read_expr); \ - if(_rv < 0) { \ - return sprintf(_buf, "READ ERROR\n"); \ - } \ - if(_invert) { \ - _rv = ~_rv; \ - } \ - _rv &= 0xFF; \ -} while(0) +/* Platform dependent --- */ -static ssize_t show_present(struct device *dev, struct device_attribute *da, - char *buf) +static int sfp_is_port_present(struct i2c_client *client, int port) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct sfp_port_data *data = i2c_get_clientdata(client); - if(attr->index == SFP_IS_PRESENT_ALL) { - int values[4]; - /* - * Report the SFP_PRESENCE status for all ports. - */ + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } - /* SFP_PRESENT Ports 1-8 */ - VALIDATED_READ(buf, values[0], as6712_32x_i2c_cpld_read(0x62, 0xA), 1); - /* SFP_PRESENT Ports 9-16 */ - VALIDATED_READ(buf, values[1], as6712_32x_i2c_cpld_read(0x62, 0xB), 1); - /* SFP_PRESENT Ports 17-24 */ - VALIDATED_READ(buf, values[2], as6712_32x_i2c_cpld_read(0x64, 0xA), 1); - /* SFP_PRESENT Ports 25-32 */ - VALIDATED_READ(buf, values[3], as6712_32x_i2c_cpld_read(0x64, 0xB), 1); + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + int i; + u8 values[4] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } /* Return values 1 -> 32 in order */ return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); - } - else { /* SFP_IS_PRESENT */ - u8 val; - struct as6712_32x_sfp_data *data = as6712_32x_sfp_update_device(dev, 0); + values[0], values[1], values[2], + values[3]); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); - if (!data->valid) { - return -EIO; - } + if (IS_ERR_VALUE(present)) { + return present; + } - val = (data->is_present & BIT_INDEX(data->port)) ? 0 : 1; - return sprintf(buf, "%d", val); - } + /* PRESENT */ + return sprintf(buf, "%d", present); + } } - -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, - char *buf) +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) { - struct as6712_32x_sfp_data *data = as6712_32x_sfp_update_device(dev, 1); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - if (!data->valid) { - return 0; - } + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } - if ((data->is_present & BIT_INDEX(data->port)) != 0) { - return 0; - } + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - memcpy(buf, data->eeprom, sizeof(data->eeprom)); + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); - return sizeof(data->eeprom); -} + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } -static const struct attribute_group as6712_32x_sfp_group = { - .attrs = as6712_32x_sfp_attributes, -}; + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } -static int as6712_32x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as6712_32x_sfp_data *data; - int status; + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; - extern int platform_accton_as6712_32x(void); - if(!platform_accton_as6712_32x()) { - return -ENODEV; - } - - if (!i2c_check_functionality(client->adapter, /*I2C_FUNC_SMBUS_BYTE_DATA | */I2C_FUNC_SMBUS_WORD_DATA)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as6712_32x_sfp_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as6712_32x_sfp_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as6712_32x_sfp_group); -exit_free: - kfree(data); exit: - - return status; + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; } -static int as6712_32x_sfp_remove(struct i2c_client *client) +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) { - struct as6712_32x_sfp_data *data = i2c_get_clientdata(client); + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as6712_32x_sfp_group); - kfree(data); - - return 0; + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); } -enum port_numbers { -as6712_32x_sfp1, as6712_32x_sfp2, as6712_32x_sfp3, as6712_32x_sfp4, -as6712_32x_sfp5, as6712_32x_sfp6, as6712_32x_sfp7, as6712_32x_sfp8, -as6712_32x_sfp9, as6712_32x_sfp10, as6712_32x_sfp11,as6712_32x_sfp12, -as6712_32x_sfp13, as6712_32x_sfp14, as6712_32x_sfp15,as6712_32x_sfp16, -as6712_32x_sfp17, as6712_32x_sfp18, as6712_32x_sfp19,as6712_32x_sfp20, -as6712_32x_sfp21, as6712_32x_sfp22, as6712_32x_sfp23,as6712_32x_sfp24, -as6712_32x_sfp25, as6712_32x_sfp26, as6712_32x_sfp27,as6712_32x_sfp28, -as6712_32x_sfp29, as6712_32x_sfp30, as6712_32x_sfp31,as6712_32x_sfp32 -}; - -static const struct i2c_device_id as6712_32x_sfp_id[] = { -{ "as6712_32x_sfp1", as6712_32x_sfp1 }, { "as6712_32x_sfp2", as6712_32x_sfp2 }, -{ "as6712_32x_sfp3", as6712_32x_sfp3 }, { "as6712_32x_sfp4", as6712_32x_sfp4 }, -{ "as6712_32x_sfp5", as6712_32x_sfp5 }, { "as6712_32x_sfp6", as6712_32x_sfp6 }, -{ "as6712_32x_sfp7", as6712_32x_sfp7 }, { "as6712_32x_sfp8", as6712_32x_sfp8 }, -{ "as6712_32x_sfp9", as6712_32x_sfp9 }, { "as6712_32x_sfp10", as6712_32x_sfp10 }, -{ "as6712_32x_sfp11", as6712_32x_sfp11 }, { "as6712_32x_sfp12", as6712_32x_sfp12 }, -{ "as6712_32x_sfp13", as6712_32x_sfp13 }, { "as6712_32x_sfp14", as6712_32x_sfp14 }, -{ "as6712_32x_sfp15", as6712_32x_sfp15 }, { "as6712_32x_sfp16", as6712_32x_sfp16 }, -{ "as6712_32x_sfp17", as6712_32x_sfp17 }, { "as6712_32x_sfp18", as6712_32x_sfp18 }, -{ "as6712_32x_sfp19", as6712_32x_sfp19 }, { "as6712_32x_sfp20", as6712_32x_sfp20 }, -{ "as6712_32x_sfp21", as6712_32x_sfp21 }, { "as6712_32x_sfp22", as6712_32x_sfp22 }, -{ "as6712_32x_sfp23", as6712_32x_sfp23 }, { "as6712_32x_sfp24", as6712_32x_sfp24 }, -{ "as6712_32x_sfp25", as6712_32x_sfp25 }, { "as6712_32x_sfp26", as6712_32x_sfp26 }, -{ "as6712_32x_sfp27", as6712_32x_sfp27 }, { "as6712_32x_sfp28", as6712_32x_sfp28 }, -{ "as6712_32x_sfp29", as6712_32x_sfp29 }, { "as6712_32x_sfp30", as6712_32x_sfp30 }, -{ "as6712_32x_sfp31", as6712_32x_sfp31 }, { "as6712_32x_sfp32", as6712_32x_sfp32 }, -{} -}; -MODULE_DEVICE_TABLE(i2c, as6712_32x_sfp_id); - - -static struct i2c_driver as6712_32x_sfp_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as6712_32x_sfp", - }, - .probe = as6712_32x_sfp_probe, - .remove = as6712_32x_sfp_remove, - .id_table = as6712_32x_sfp_id, - .address_list = normal_i2c, -}; - -#if 0 -static int as6712_32x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data) +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { - int result = i2c_smbus_read_byte_data(client, command); + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } - *data = (u8)result; - result = 0; - -abort: - return result; + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; } #endif -static int as6712_32x_sfp_read_word(struct i2c_client *client, u8 command, u16 *data) +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) { - int result = i2c_smbus_read_word_data(client, command); + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } - *data = (u16)result; - result = 0; + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; abort: - return result; + return status; +#endif } -#define ALWAYS_UPDATE 1 - -static struct as6712_32x_sfp_data *as6712_32x_sfp_update_device(struct device *dev, int update_eeprom) +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) { - struct i2c_client *client = to_i2c_client(dev); - struct as6712_32x_sfp_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); + unsigned page = 0; - if (ALWAYS_UPDATE || time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status = -1; - int i = 0, j = 0; + *client = port_data->client; - data->valid = 0; - - /* Read present status of port 1~32 */ - data->is_present = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - status = as6712_32x_i2c_cpld_read(0x62+i*2, 0xA+j); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x62+i*2, 0xA+j, status); - goto exit; - } - - data->is_present |= (u64)status << ((i*16) + (j*8)); - } - } + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; - if (update_eeprom) { - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - /* Check if the port is present */ - if ((data->is_present & BIT_INDEX(data->port)) == 0) { - /* read eeprom */ - u16 eeprom_data; - for (i = 0; i < (sizeof(data->eeprom) / 2); i++) { - status = as6712_32x_sfp_read_word(client, i*2, &eeprom_data); - - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", data->port); - goto exit; - } - - data->eeprom[i*2] = eeprom_data & 0xff; - data->eeprom[i*2 + 1] = eeprom_data >> 8; - } - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; + return page; /* note also returning client and offset */ } -module_i2c_driver(as6712_32x_sfp_driver); +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as6712_32x_port1 || dev_id->driver_data > as6712_32x_port32) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif + + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as6712_32x_sfp driver"); MODULE_LICENSE("GPL"); +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py index 5158019d..54bc68dc 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py @@ -25,7 +25,7 @@ class OnlPlatform_x86_64_accton_as6712_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 for port in range(1, 33): - self.new_i2c_device('as6712_32x_sfp%d' % port, + self.new_i2c_device('as6712_32x_port%d' % port, 0x50, port+1) From 2f51304113f8f416712dd288523ffb1d16284b2f Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 16 Nov 2017 11:48:13 +0800 Subject: [PATCH 071/244] [as6812-32x] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as6812-32x-sfp.c | 1656 ++++++++++++++--- .../x86_64_accton_as6812_32x_r0/__init__.py | 2 +- 2 files changed, 1409 insertions(+), 249 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c index 023e949b..362d87db 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c @@ -1,8 +1,7 @@ /* - * An hwmon driver for accton as6812_32x sfp + * SFP driver for accton as6812_32x sfp * - * Copyright (C) 2015 Accton Technology Corporation. - * Brandon Chuang + * Copyright (C) Brandon Chuang * * Based on ad7414.c * Copyright 2006 Stefan Roese , DENX Software Engineering @@ -14,7 +13,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -31,342 +30,1503 @@ #include #include #include +#include -#define BIT_INDEX(i) (1ULL << (i)) +#define DRIVER_NAME "as6812_32x_sfp" -/* Addresses scanned +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* Each client has this additional data +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -struct as6812_32x_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u64 is_present; /* present status */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int as6812_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL }; -static struct as6812_32x_sfp_data *as6812_32x_sfp_update_device(struct device *dev, int update_eeprom); -static ssize_t show_present(struct device *dev, struct device_attribute *da,char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf); -static int as6812_32x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data); -extern int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); -//extern int accton_i2c_cpld_mux_get_index(int adap_index); +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); -enum as6812_32x_sfp_sysfs_attributes { - SFP_IS_PRESENT, - SFP_EEPROM, - SFP_PORT_NUMBER, - SFP_IS_PRESENT_ALL -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, SFP_IS_PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); - -static struct attribute *as6812_32x_sfp_attributes[] = { - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, NULL }; +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +as6812_32x_port1, as6812_32x_port2, as6812_32x_port3, as6812_32x_port4, as6812_32x_port5, as6812_32x_port6, as6812_32x_port7, as6812_32x_port8, +as6812_32x_port9, as6812_32x_port10, as6812_32x_port11, as6812_32x_port12, as6812_32x_port13, as6812_32x_port14, as6812_32x_port15, as6812_32x_port16, +as6812_32x_port17, as6812_32x_port18, as6812_32x_port19, as6812_32x_port20, as6812_32x_port21, as6812_32x_port22, as6812_32x_port23, as6812_32x_port24, +as6812_32x_port25, as6812_32x_port26, as6812_32x_port27, as6812_32x_port28, as6812_32x_port29, as6812_32x_port30, as6812_32x_port31, as6812_32x_port32 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as6812_32x_port1), +I2C_DEV_ID(as6812_32x_port2), +I2C_DEV_ID(as6812_32x_port3), +I2C_DEV_ID(as6812_32x_port4), +I2C_DEV_ID(as6812_32x_port5), +I2C_DEV_ID(as6812_32x_port6), +I2C_DEV_ID(as6812_32x_port7), +I2C_DEV_ID(as6812_32x_port8), +I2C_DEV_ID(as6812_32x_port9), +I2C_DEV_ID(as6812_32x_port10), +I2C_DEV_ID(as6812_32x_port11), +I2C_DEV_ID(as6812_32x_port12), +I2C_DEV_ID(as6812_32x_port13), +I2C_DEV_ID(as6812_32x_port14), +I2C_DEV_ID(as6812_32x_port15), +I2C_DEV_ID(as6812_32x_port16), +I2C_DEV_ID(as6812_32x_port17), +I2C_DEV_ID(as6812_32x_port18), +I2C_DEV_ID(as6812_32x_port19), +I2C_DEV_ID(as6812_32x_port20), +I2C_DEV_ID(as6812_32x_port21), +I2C_DEV_ID(as6812_32x_port22), +I2C_DEV_ID(as6812_32x_port23), +I2C_DEV_ID(as6812_32x_port24), +I2C_DEV_ID(as6812_32x_port25), +I2C_DEV_ID(as6812_32x_port26), +I2C_DEV_ID(as6812_32x_port27), +I2C_DEV_ID(as6812_32x_port28), +I2C_DEV_ID(as6812_32x_port29), +I2C_DEV_ID(as6812_32x_port30), +I2C_DEV_ID(as6812_32x_port31), +I2C_DEV_ID(as6812_32x_port32), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf) { struct i2c_client *client = to_i2c_client(dev); - struct as6812_32x_sfp_data *data = i2c_get_clientdata(client); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0, j = 0; + int status = -1; - return sprintf(buf, "%d\n", data->port+1); + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 1~32 */ + data->present = 0; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + status = as6812_32x_i2c_cpld_read(0x62+i*2, 0xA+j); + + if (status < 0) { + DEBUG_PRINT("cpld(0x%x) reg(0x%x) err %d", 0x62+i*2, 0xA+j, status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); + data->present |= (u64)status << ((i*16) + (j*8)); + } + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; } -/* Error-check the CPLD read results. */ -#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ -do { \ - _rv = (_read_expr); \ - if(_rv < 0) { \ - return sprintf(_buf, "READ ERROR\n"); \ - } \ - if(_invert) { \ - _rv = ~_rv; \ - } \ - _rv &= 0xFF; \ -} while(0) +/* Platform dependent --- */ +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ static ssize_t show_present(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); - if(attr->index == SFP_IS_PRESENT_ALL) { - int values[4]; - /* - * Report the SFP_PRESENCE status for all ports. - */ - - /* SFP_PRESENT Ports 1-8 */ - VALIDATED_READ(buf, values[0], as6812_32x_i2c_cpld_read(0x62, 0xA), 1); - /* SFP_PRESENT Ports 9-16 */ - VALIDATED_READ(buf, values[1], as6812_32x_i2c_cpld_read(0x62, 0xB), 1); - /* SFP_PRESENT Ports 17-24 */ - VALIDATED_READ(buf, values[2], as6812_32x_i2c_cpld_read(0x64, 0xA), 1); - /* SFP_PRESENT Ports 25-32 */ - VALIDATED_READ(buf, values[3], as6812_32x_i2c_cpld_read(0x64, 0xB), 1); - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); - } - else { /* SFP_IS_PRESENT */ - u8 val; - struct as6812_32x_sfp_data *data = as6812_32x_sfp_update_device(dev, 0); - - if (!data->valid) { - return -EIO; + if (PRESENT_ALL == attr->index) { + int i; + u8 values[4] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); } - val = (data->is_present & BIT_INDEX(data->port)) ? 0 : 1; - return sprintf(buf, "%d", val); + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3]); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d", present); } } +/* Platform dependent --- */ -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf) { - struct as6812_32x_sfp_data *data = as6812_32x_sfp_update_device(dev, 1); + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); - if (!data->valid) { - return 0; + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; } - if ((data->is_present & BIT_INDEX(data->port)) != 0) { - return 0; + if (present == 0) { + /* port is not present */ + return -ENXIO; } - memcpy(buf, data->eeprom, sizeof(data->eeprom)); + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } - return sizeof(data->eeprom); + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); } -static const struct attribute_group as6812_32x_sfp_group = { - .attrs = as6812_32x_sfp_attributes, +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, }; -static int as6812_32x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) { - struct as6812_32x_sfp_data *data; int status; + struct qsfp_data *qsfp; - if (!i2c_check_functionality(client->adapter, /*I2C_FUNC_SMBUS_BYTE_DATA | */I2C_FUNC_SMBUS_WORD_DATA)) { +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } +#endif - data = kzalloc(sizeof(struct as6812_32x_sfp_data), GFP_KERNEL); - if (!data) { + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { status = -ENOMEM; goto exit; } - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "chip found\n"); - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as6812_32x_sfp_group); + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); if (status) { goto exit_free; } - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { goto exit_remove; } - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); return 0; exit_remove: - sysfs_remove_group(&client->dev.kobj, &as6812_32x_sfp_group); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); exit_free: - kfree(data); + kfree(qsfp); exit: return status; } -static int as6812_32x_sfp_remove(struct i2c_client *client) +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) { - struct as6812_32x_sfp_data *data = i2c_get_clientdata(client); + int ret = 0; + struct sfp_port_data *data = NULL; - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as6812_32x_sfp_group); + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as6812_32x_port1 || dev_id->driver_data > as6812_32x_port32) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: kfree(data); + return ret; +} +/* Platform dependent --- */ +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); return 0; } -enum port_numbers { -as6812_32x_sfp1, as6812_32x_sfp2, as6812_32x_sfp3, as6812_32x_sfp4, -as6812_32x_sfp5, as6812_32x_sfp6, as6812_32x_sfp7, as6812_32x_sfp8, -as6812_32x_sfp9, as6812_32x_sfp10, as6812_32x_sfp11,as6812_32x_sfp12, -as6812_32x_sfp13, as6812_32x_sfp14, as6812_32x_sfp15,as6812_32x_sfp16, -as6812_32x_sfp17, as6812_32x_sfp18, as6812_32x_sfp19,as6812_32x_sfp20, -as6812_32x_sfp21, as6812_32x_sfp22, as6812_32x_sfp23,as6812_32x_sfp24, -as6812_32x_sfp25, as6812_32x_sfp26, as6812_32x_sfp27,as6812_32x_sfp28, -as6812_32x_sfp29, as6812_32x_sfp30, as6812_32x_sfp31,as6812_32x_sfp32 -}; +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif -static const struct i2c_device_id as6812_32x_sfp_id[] = { -{ "as6812_32x_sfp1", as6812_32x_sfp1 }, { "as6812_32x_sfp2", as6812_32x_sfp2 }, -{ "as6812_32x_sfp3", as6812_32x_sfp3 }, { "as6812_32x_sfp4", as6812_32x_sfp4 }, -{ "as6812_32x_sfp5", as6812_32x_sfp5 }, { "as6812_32x_sfp6", as6812_32x_sfp6 }, -{ "as6812_32x_sfp7", as6812_32x_sfp7 }, { "as6812_32x_sfp8", as6812_32x_sfp8 }, -{ "as6812_32x_sfp9", as6812_32x_sfp9 }, { "as6812_32x_sfp10", as6812_32x_sfp10 }, -{ "as6812_32x_sfp11", as6812_32x_sfp11 }, { "as6812_32x_sfp12", as6812_32x_sfp12 }, -{ "as6812_32x_sfp13", as6812_32x_sfp13 }, { "as6812_32x_sfp14", as6812_32x_sfp14 }, -{ "as6812_32x_sfp15", as6812_32x_sfp15 }, { "as6812_32x_sfp16", as6812_32x_sfp16 }, -{ "as6812_32x_sfp17", as6812_32x_sfp17 }, { "as6812_32x_sfp18", as6812_32x_sfp18 }, -{ "as6812_32x_sfp19", as6812_32x_sfp19 }, { "as6812_32x_sfp20", as6812_32x_sfp20 }, -{ "as6812_32x_sfp21", as6812_32x_sfp21 }, { "as6812_32x_sfp22", as6812_32x_sfp22 }, -{ "as6812_32x_sfp23", as6812_32x_sfp23 }, { "as6812_32x_sfp24", as6812_32x_sfp24 }, -{ "as6812_32x_sfp25", as6812_32x_sfp25 }, { "as6812_32x_sfp26", as6812_32x_sfp26 }, -{ "as6812_32x_sfp27", as6812_32x_sfp27 }, { "as6812_32x_sfp28", as6812_32x_sfp28 }, -{ "as6812_32x_sfp29", as6812_32x_sfp29 }, { "as6812_32x_sfp30", as6812_32x_sfp30 }, -{ "as6812_32x_sfp31", as6812_32x_sfp31 }, { "as6812_32x_sfp32", as6812_32x_sfp32 }, -{} -}; -MODULE_DEVICE_TABLE(i2c, as6812_32x_sfp_id); + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + kfree(data); + return ret; +} -static struct i2c_driver as6812_32x_sfp_driver = { - .class = I2C_CLASS_HWMON, +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { .driver = { - .name = "as6812_32x_sfp", + .name = DRIVER_NAME, }, - .probe = as6812_32x_sfp_probe, - .remove = as6812_32x_sfp_remove, - .id_table = as6812_32x_sfp_id, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, .address_list = normal_i2c, }; -#if 0 -static int as6812_32x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data) +static int __init sfp_init(void) { - int result = i2c_smbus_read_byte_data(client, command); - - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } - - *data = (u8)result; - result = 0; - -abort: - return result; -} -#endif - -static int as6812_32x_sfp_read_word(struct i2c_client *client, u8 command, u16 *data) -{ - int result = i2c_smbus_read_word_data(client, command); - - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } - - *data = (u16)result; - result = 0; - -abort: - return result; + return i2c_add_driver(&sfp_driver); } -#define ALWAYS_UPDATE 1 - -static struct as6812_32x_sfp_data *as6812_32x_sfp_update_device(struct device *dev, int update_eeprom) +static void __exit sfp_exit(void) { - struct i2c_client *client = to_i2c_client(dev); - struct as6812_32x_sfp_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (ALWAYS_UPDATE || time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status = -1; - int i = 0, j = 0; - - data->valid = 0; - - /* Read present status of port 1~32 */ - data->is_present = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - status = as6812_32x_i2c_cpld_read(0x62+i*2, 0xA+j); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x62+i*2, 0xA+j, status); - goto exit; - } - - data->is_present |= (u64)status << ((i*16) + (j*8)); - } - } - - if (update_eeprom) { - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if ((data->is_present & BIT_INDEX(data->port)) == 0) { - /* read eeprom */ - u16 eeprom_data; - for (i = 0; i < (sizeof(data->eeprom) / 2); i++) { - status = as6812_32x_sfp_read_word(client, i*2, &eeprom_data); - - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", data->port); - goto exit; - } - - data->eeprom[i*2] = eeprom_data & 0xff; - data->eeprom[i*2 + 1] = eeprom_data >> 8; - } - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; + i2c_del_driver(&sfp_driver); } -module_i2c_driver(as6812_32x_sfp_driver); - MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as6812_32x_sfp driver"); MODULE_LICENSE("GPL"); + +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py index 66e8f002..43c9b7d8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py @@ -25,7 +25,7 @@ class OnlPlatform_x86_64_accton_as6812_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 for port in range(1, 33): - self.new_i2c_device('as6812_32x_sfp%d' % port, + self.new_i2c_device('as6812_32x_port%d' % port, 0x50, port+1) From 984267259a9180732260b4ad6b9ae555065e8ca8 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 16 Nov 2017 19:38:01 +0000 Subject: [PATCH 072/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index ab1e0396..7d3a194f 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit ab1e0396cb725abba9d57c4d2d28993463a38261 +Subproject commit 7d3a194f7d0b7a144b7773413a3dfb8d24ad1129 From 62d3fc3f465a43c0f826ef41836de2e30462845b Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 16 Nov 2017 19:40:11 +0000 Subject: [PATCH 073/244] Latest --- sm/infra | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/infra b/sm/infra index 2b72b5dc..b4477ce7 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 2b72b5dce5e910f31e855eebbeb41a0e481e35d1 +Subproject commit b4477ce792024e069089c34aca6590be76a0ac4a From 291b2ec27e04a787f1e60330fa23860457683d9a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 17 Nov 2017 09:21:14 -0800 Subject: [PATCH 074/244] Latest --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index a8c72b6c..19a601e7 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit a8c72b6c0553a3547be6be16b41fae2af5b38951 +Subproject commit 19a601e7937fbb514d3abe466e4aacef02418b54 From ea03f2715ac33b228ad0566bd15ca98aefe18153 Mon Sep 17 00:00:00 2001 From: "shaohua.xiong" Date: Tue, 21 Nov 2017 18:33:41 +0800 Subject: [PATCH 075/244] support the platform delta ag6248c --- .../loader-initrd-files/src/bin/swiget | 9 + .../loader-initrd-files/src/bin/swimount | 23 +- .../src/bootmodes/installed | 4 +- .../lib/platform-config-defaults-uboot.yml | 7 + .../src/python/onl/install/BaseInstall.py | 228 +- .../src/python/onl/install/InstallUtils.py | 57 + .../src/python/onl/mounts/__init__.py | 40 +- .../src/python/onl/platform/base.py | 4 + .../3.2-lts/configs/arm-iproc-all/Makefile | 2 +- .../arm-iproc-all/arm-iproc-all.config | 4 +- ...latform-delta-ag6248c-device-drivers.patch | 181 ++ .../configs/arm-iproc-all/patches/series | 1 + packages/platforms/delta/armel/Makefile | 1 + .../delta/armel/arm-delta-ag6248c/Makefile | 1 + .../delta/armel/arm-delta-ag6248c/README.md | 25 + .../arm-delta-ag6248c/.gitignore | 2 + .../arm-delta-ag6248c/Makefile | 1 + .../arm-delta-ag6248c/modules/Makefile | 1 + .../arm-delta-ag6248c/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 2 + .../arm-delta-ag6248c/modules/builds/Makefile | 6 + .../builds/arm-delta-ag6248c-cpld-mux-1.c | 242 +++ .../builds/arm-delta-ag6248c-cpld-mux-2.c | 243 +++ .../arm-delta-ag6248c/onlp/Makefile | 1 + .../arm-delta-ag6248c/onlp/PKG.yml | 1 + .../arm-delta-ag6248c/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 44 + .../builds/lib/libonlp-arm-delta-ag6248c.mk | 10 + .../onlp/builds/onlpdump/Makefile | 45 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/arm-delta-ag6248c-r0.yml | 43 + .../python/arm_delta_ag6248c_r0/__init__.py | 23 + .../src/arm_delta_ag6248c/.gitignore | 2 + .../src/arm_delta_ag6248c/.module | 1 + .../src/arm_delta_ag6248c/Makefile | 28 + .../arm_delta_ag6248c/arm_delta_ag6248c.doxy | 1869 +++++++++++++++++ .../arm_delta_ag6248c/arm_delta_ag6248c.mk | 13 + .../module/auto/arm_delta_ag6248c.yml | 67 + .../src/arm_delta_ag6248c/module/auto/make.mk | 28 + .../inc/arm_delta_ag6248c/arm_delta_ag6248c.x | 34 + .../arm_delta_ag6248c_config.h | 162 ++ .../arm_delta_ag6248c/arm_delta_ag6248c_dox.h | 51 + .../arm_delta_ag6248c_porting.h | 132 ++ .../src/arm_delta_ag6248c/module/make.mk | 29 + .../src/arm_delta_ag6248c/module/src/Makefile | 30 + .../module/src/arm_delta_ag6248c_config.c | 101 + .../module/src/arm_delta_ag6248c_enums.c | 30 + .../module/src/arm_delta_ag6248c_int.h | 32 + .../module/src/arm_delta_ag6248c_log.c | 38 + .../module/src/arm_delta_ag6248c_log.h | 32 + .../module/src/arm_delta_ag6248c_module.c | 44 + .../module/src/arm_delta_ag6248c_ucli.c | 82 + .../module/src/arm_delta_i2c.c | 141 ++ .../module/src/arm_delta_i2c.h | 54 + .../src/arm_delta_ag6248c/module/src/fani.c | 463 ++++ .../src/arm_delta_ag6248c/module/src/ledi.c | 352 ++++ .../src/arm_delta_ag6248c/module/src/make.mk | 29 + .../module/src/platform_lib.c | 85 + .../module/src/platform_lib.h | 134 ++ .../src/arm_delta_ag6248c/module/src/psui.c | 380 ++++ .../src/arm_delta_ag6248c/module/src/sfpi.c | 364 ++++ .../src/arm_delta_ag6248c/module/src/sysi.c | 290 +++ .../arm_delta_ag6248c/module/src/thermali.c | 128 ++ .../platforms/delta/armel/modules/Makefile | 1 + .../platforms/delta/armel/modules/PKG.yml | 1 + 67 files changed, 6469 insertions(+), 15 deletions(-) create mode 100644 packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch create mode 100644 packages/platforms/delta/armel/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/README.md create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/make.mk create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c create mode 100644 packages/platforms/delta/armel/modules/Makefile create mode 100644 packages/platforms/delta/armel/modules/PKG.yml diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget index 333674a9..1be874d1 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget @@ -19,6 +19,7 @@ import zipfile import onl.install.InstallUtils MountContext = onl.install.InstallUtils.MountContext BlkidParser = onl.install.InstallUtils.BlkidParser +UbinfoParser = onl.install.InstallUtils.UbinfoParser ProcMountsParser = onl.install.InstallUtils.ProcMountsParser import onl.mounts @@ -247,6 +248,14 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): part = blkid[label] except IndexError: part = None + if part is None: + ubinfo = UbinfoParser(log=self.log) + part = {} + part = ubinfo[label] + device = "/dev/" + part['device'] + "_" + part['Volume ID'] + + return self.blockdevCopy(device, r, dir=mpt) + if part is not None: return self.blockdevCopy(part.device, r, dir=mpt) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swimount b/packages/base/all/initrds/loader-initrd-files/src/bin/swimount index b7ea1879..2741b5bd 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swimount +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swimount @@ -11,6 +11,7 @@ import logging import onl.install.InstallUtils BlkidParser = onl.install.InstallUtils.BlkidParser +UbinfoParser = onl.install.InstallUtils.UbinfoParser import onl.mounts MountContext = onl.install.InstallUtils.MountContext @@ -26,6 +27,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): self.log = log self.blkid = BlkidParser(log=self.log) + self.ubinfo = UbinfoParser(log=self.log) def mount(self, SWI): @@ -125,6 +127,13 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): part = self.blkid[label] except IndexError: part = None + if part is None: + part = {} + part = self.ubinfo[label] + + device = "/dev/" + part['device'] + "_" + part['Volume ID'] + + return self.blockdevMount(device, path, dir=mpt) if part is not None: return self.blockdevMount(part.device, path, dir=mpt) @@ -141,7 +150,12 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): if not os.path.exists(dst): self.log.error("missing SWI: %s", dst) return None - self.check_call(('mount', '-o', 'rw,remount', dst,)) + p = dev.find('ubi') + if p < 0: + self.check_call(('mount', '-o', 'rw,remount', dst,)) + else: + self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', dst,)) + return dst with MountContext(device=dev, log=self.log) as ctx: @@ -154,7 +168,12 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): # move to its proper location as per mtab # XXX perms may not be right here if dir is not None: - self.check_call(('mount', '-o', 'rw,remount', ctx.dir,)) + p = dev.find('ubi') + if p < 0: + self.check_call(('mount', '-o', 'rw,remount', ctx.dir,)) + else: + self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', ctx.dir,)) + self.check_call(('mount', '--move', ctx.dir, dir,)) ctx.mounted = False dst = dir diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed index 00aa3a41..dc0e887b 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed +++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed @@ -15,8 +15,8 @@ if [ ! -d /mnt/onl/data ]; then fi # make sure it's mounted as per mtab.yml -d1=$(stat -f -c '%d' /mnt/onl) -d2=$(stat -f -c '%d' /mnt/onl/data) +d1=$(stat -f -c '%b' /mnt/onl) +d2=$(stat -f -c '%b' /mnt/onl/data) if [ "$d1" -eq "$d2" ]; then msg_error "Unmounted /mnt/onl/data, disk boot cannot continue" exit 200 diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml index 4ad068fb..6b66f8c6 100644 --- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml +++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml @@ -129,6 +129,13 @@ default: - ext2load mmc 0:1 $onl_loadaddr $onl_itb - "bootm $onl_loadaddr#$onl_platform" + #ubifs to boot onl + flash_bootcmds: &flash_bootcmds + - ubi part open + - ubifsmount ONL-BOOT + - ubifsload $loadaddr $onl_itb + - "bootm $onl_loadaddr#$onl_platform" + nos_bootcmds: *ide_bootcmds # Configure the fw_env.config file, diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py index 2ca43c17..50b21638 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py @@ -17,7 +17,7 @@ import imp import fnmatch, glob from InstallUtils import SubprocessMixin -from InstallUtils import MountContext, BlkidParser, PartedParser +from InstallUtils import MountContext, BlkidParser, PartedParser, UbinfoParser from InstallUtils import ProcMountsParser from InstallUtils import GdiskParser from InstallUtils import OnieSubprocess @@ -83,6 +83,7 @@ class Base: # keep track of next partition/next block self.blkidParts = [] + self.ubiParts = [] # current scan of partitions and labels self.partedDevice = None @@ -853,7 +854,203 @@ class GrubInstaller(SubprocessMixin, Base): def shutdown(self): Base.shutdown(self) -class UbootInstaller(SubprocessMixin, Base): +class UBIfsCreater(SubprocessMixin, Base): + + def __init__(self, *args, **kwargs): + Base.__init__(self, *args, **kwargs) + self.log = logging.getLogger("ubinfo -a") + self.device = self.im.getDevice() + self.ubiParts = None + """Set up an UBI file system.""" + + def ubifsinit(self): + UNITS = { + 'GiB' : 1024 * 1024 * 1024, + 'G' : 1000 * 1000 * 1000, + 'MiB' : 1024 * 1024, + 'M' : 1000 * 1000, + 'KiB' : 1024, + 'K' : 1000, + } + try: + code = 0 + if not code: + mtd_num = self.device[-1] + cmd = ('ubiformat', '/dev/mtd' + mtd_num) + self.check_call(cmd, vmode=self.V2) + cmd = ('ubiattach', '-m', mtd_num, '-d', '0', '/dev/ubi_ctrl',) + self.check_call(cmd, vmode=self.V2) + for part in self.im.platformConf['installer']: + label, partData = list(part.items())[0] + if type(partData) == dict: + sz, fmt = partData['='], partData.get('format', 'ubifs') + else: + sz, fmt = partData, 'ubifs' + cnt = None + for ul, ub in UNITS.items(): + if sz.endswith(ul): + cnt = int(sz[:-len(ul)], 10) * ub + break + if cnt is None: + self.log.error("invalid size (no units) for %s: %s",part, sz) + return 1 + label = label.strip() + cmd = ('ubimkvol', '/dev/ubi0', '-N', label, '-s', bytes(cnt),) + self.check_call(cmd, vmode=self.V2) + except Exception: + self.log.exception("cannot create UBI file systemfrom %s",self.device) + + return 0 + + def ubi_mount(self, dir, devpart): + + if devpart is None: + self.log.error("Mount failed.no given mount device part") + return 1 + if dir is None: + self.log.error("Mount failed.no given mount directory") + return 1 + if self.ubiParts is None: + try: + self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a")) + except Exception: + self.log.exception("Mount failed.No UBIfs") + return 1 + try: + dev = self.ubiParts[devpart] + except IndexError as ex: + self.log.error("Mount failed.cannot find %s partition", str(devpart)) + return 1 + self.makedirs(dir) + device = "/dev/" + dev['device'] + "_" + dev['Volume ID'] + if dev['fsType']: + cmd = ('mount', '-t', dev['fsType'], device, dir,) + else: + cmd = ('mount', device, dir,) + code = self.check_call(cmd, vmode=self.V2) + if code: + self.log.error("Mount failed.mount command exect failed") + return 1 + return 0 + + def ubi_unmount(self,dir=None): + + if dir is None: + self.log.error("Unmount failed.no given unmount directory") + return 1 + cmd = ('umount', dir) + code = self.check_call(cmd, vmode=self.V2) + if code: + self.log.error("Unmount failed.umount command exect failed") + return 1 + return 0 + + def ubi_getinfo(self): + try: + self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a")) + except Exception: + self.log.exception("UBI info get failed.No UBIfs") + return 1 + return 0 + + def ubi_installSwi(self): + + files = os.listdir(self.im.installerConf.installer_dir) + self.zf.namelist() + + swis = [x for x in files if x.endswith('.swi')] + + if not swis: + self.log.warn("No ONL Software Image available for ubi installation.") + self.log.warn("Post-install ZTN installation will be required.") + + if len(swis) > 1: + self.log.error("Multiple SWIs found in ubi installer: %s", " ".join(swis)) + return 1 + + base = swis[0] + + self.log.info("Installing ONL Software Image (%s)...", base) + dev = "ONL-IMAGES" + dstDir = "/tmp/ubifs" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + dst = os.path.join(dstDir, base) + self.installerCopy(base, dst) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + def ubi_installLoader(self): + + loaderBasename = None + for c in sysconfig.installer.fit: + if self.installerExists(c): + loaderBasename = c + break + if not loaderBasename: + self.log.error("The platform loader file is missing.") + return 1 + + self.log.info("Installing the ONL loader from %s...", loaderBasename) + dev = "ONL-BOOT" + dstDir = "/tmp/ubiloader" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + dst = os.path.join(dstDir, "%s.itb" % self.im.installerConf.installer_platform) + self.installerCopy(loaderBasename, dst) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + def ubi_installBootConfig(self): + + basename = 'boot-config' + + self.log.info("Installing boot-config to ONL-BOOT partion") + dev = "ONL-BOOT" + dstDir = "/tmp/ubibootcon" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + dst = os.path.join(dstDir, basename) + self.installerCopy(basename, dst, True) + with open(dst) as fd: + buf = fd.read() + ecf = buf.encode('base64', 'strict').strip() + if self.im.grub and self.im.grubEnv is not None: + setattr(self.im.grubEnv, 'boot_config_default', ecf) + if self.im.uboot and self.im.ubootEnv is not None: + setattr(self.im.ubootEnv, 'boot-config-default', ecf) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + def ubi_installOnlConfig(self): + + self.log.info("Installing onl-config to ONL-CONFIG partion") + dev = "ONL-CONFIG" + dstDir = "/tmp/ubionlconfig" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + for f in self.zf.namelist(): + d = 'config/' + if f.startswith(d) and f != d: + dst = os.path.join(dstDir, os.path.basename(f)) + if not os.path.exists(dst): + self.installerCopy(f, dst) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + +class UbootInstaller(SubprocessMixin, UBIfsCreater): class installmeta(Base.installmeta): @@ -874,13 +1071,16 @@ class UbootInstaller(SubprocessMixin, Base): cmds.append("setenv onl_itb %s" % itb) for item in self.platformConf['loader']['setenv']: k, v = list(item.items())[0] - cmds.append("setenv %s %s" % (k, v,)) + device = self.getDevice() + if "mtdblock" in device: + cmds.append("setenv %s %s ${platformargs} ubi.mtd=%s root=/dev/ram ethaddr=$ethaddr" % (k, v, device[-1],)) + else: + cmds.append("setenv %s %s" % (k, v,)) cmds.extend(self.platformConf['loader']['nos_bootcmds']) return "; ".join(cmds) def __init__(self, *args, **kwargs): - Base.__init__(self, *args, **kwargs) - + UBIfsCreater.__init__(self, *args, **kwargs) self.device = self.im.getDevice() self.rawLoaderDevice = None @@ -1014,6 +1214,24 @@ class UbootInstaller(SubprocessMixin, Base): code = self.assertUnmounted() if code: return code + + if "mtdblock" in self.device: + code = self.ubifsinit() + if code: return code + code = self.ubi_getinfo() + if code: return code + code = self.ubi_installSwi() + if code: return code + code = self.ubi_installLoader() + if code: return code + code = self.ubi_installBootConfig() + if code: return code + code = self.ubi_installOnlConfig() + if code: return code + code = self.runPlugins(Plugin.PLUGIN_POSTINSTALL) + if code: return code + code = self.installUbootEnv() + return code code = self.maybeCreateLabel() if code: return code diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index ccb4615e..85fe2c01 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -388,6 +388,63 @@ class BlkidParser(SubprocessMixin): def __len__(self): return len(self.parts) +class UbinfoParser(SubprocessMixin): + + def __init__(self, log=None): + self.log = log or logging.getLogger("ubinfo -a") + self.parse() + + def parse(self): + self.parts = [] + lines = '' + try: + cmd = ('ubinfo', '-a',) + lines = self.check_output(cmd).splitlines() + except Exception as ex: + return self + + dev = None + volId = None + name = None + attrs = {} + for line in lines: + line = line.strip() + + p = line.find(':') + if p < 0: continue + name, value = line[:p], line[p+1:].strip() + if 'Volume ID' in name: + p = value.find('(') + if p < 0: continue + volumeId = value[:p].strip() + attrs['Volume ID'] = volumeId + p = value.find('on') + if p < 0: continue + dev = value[p+2:-1].strip() + attrs['device'] = dev + + if 'Name' in name: + dev = "/dev/" + dev + "_" + volumeId + p = line.find(':') + if p < 0: continue + attrs['Name'] = line[p+1:].strip() + attrs['fsType'] = 'ubifs' + self.parts.append(attrs) + dev = None + volId = None + name = None + attrs = {} + + def __getitem__(self, idxOrName): + if type(idxOrName) == int: + return self.parts[idxOrName] + for part in self.parts: + if part['Name'] == idxOrName: return part + raise IndexError("cannot find partition %s" % repr(idxOrName)) + + def __len__(self): + return len(self.parts) + class ProcMtdEntry: def __init__(self, diff --git a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py index bf591df6..e6d24391 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py @@ -63,7 +63,12 @@ class MountManager(object): self.logger.debug("%s not mounted @ %s. It will be mounted %s" % (device, directory, mode)) try: - cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory) + p = device.find('ubi') + if p < 0: + cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory) + else: + cmd = "mount -o %s -t %s %s %s" % (','.join(mountargs), 'ubifs', device, directory) + self.logger.debug("+ %s" % cmd) subprocess.check_call(cmd, shell=True) except subprocess.CalledProcessError, e: @@ -148,12 +153,39 @@ class OnlMountManager(object): def _discover(k): v = md[k] lbl = v.get('label', k) - + useUbiDev = False try: v['device'] = subprocess.check_output(('blkid', '-L', lbl,)).strip() except subprocess.CalledProcessError: - return False - + useUbiDev = True + if useUbiDev == True: + if k == 'EFI-BOOT': + return False + output = subprocess.check_output("ubinfo -d 0 -N %s" % k, shell=True).splitlines() + volumeId = None + device = None + for line in output: + line = line.strip() + p = line.find(':') + if p < 0: + self.logger.debug("Invaild ubinfo output %s" % line) + + name, value = line[:p], line[p+1:].strip() + if 'Volume ID' in name: + p = value.find('(') + if p < 0: + self.logger.debug("Invalid Volume ID %s" % value) + + volumeId = value[:p].strip() + p = value.find('on') + if p < 0: + self.logger.debug("Invalid ubi devicde %s" % value) + + device = value[p+2:-1].strip() + if 'Name' in name: + v['device'] = "/dev/" + device + "_" + volumeId + + if not os.path.isdir(v['dir']): self.logger.debug("Make directory '%s'...", v['dir']) os.makedirs(v['dir']) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index aed2e0f7..ecd1f1e4 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -474,6 +474,10 @@ class OnlPlatformPortConfig_48x1_4x10(object): PORT_COUNT=52 PORT_CONFIG="48x1 + 4x10" +class OnlPlatformPortConfig_48x1_2x10(object): + PORT_COUNT=50 + PORT_CONFIG="48x1 + 2x10" + class OnlPlatformPortConfig_48x10_4x40(object): PORT_COUNT=52 PORT_CONFIG="48x10 + 4x40" diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile index b16fc9d4..49f02b06 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile @@ -38,6 +38,6 @@ K_COPY_DST := kernel-3.2-lts-arm-iproc-all.bin.gz endif export ARCH=arm -DTS_LIST := accton_as4610_54 +DTS_LIST := accton_as4610_54 delta_ag6248c include $(ONL)/make/kbuild.mk diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config index 4df4b2f3..e70dd3b3 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config @@ -289,6 +289,7 @@ CONFIG_BCM_RAM_START_RESERVED_SIZE=0x200000 # CONFIG_MACH_GH is not set # CONFIG_MACH_DNI_3448P is not set CONFIG_MACH_ACCTON_AS4610_54=y +CONFIG_MACH_DELTA_AG6248C=y # CONFIG_MACH_IPROC_EMULATION is not set # @@ -1938,7 +1939,8 @@ CONFIG_IPROC_QSPI_SINGLE_MODE=y # CONFIG_IPROC_QSPI_DUAL_MODE is not set # CONFIG_IPROC_QSPI_QUAD_MODE is not set CONFIG_IPROC_QSPI_MAX_HZ=62500000 -# CONFIG_IPROC_MTD_NAND is not set +CONFIG_IPROC_MTD_NAND=y +# CONFIG_IPROC_MTD_NAND_USE_JFFS2 is not set # CONFIG_IPROC_PWM is not set CONFIG_IPROC_USB2H=y CONFIG_USB_EHCI_BCM=y diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch new file mode 100644 index 00000000..6dd2774b --- /dev/null +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch @@ -0,0 +1,181 @@ +diff --git a/arch/arm/boot/dts/delta_ag6248c.dts b/arch/arm/boot/dts/delta_ag6248c.dts +new file mode 100755 +index 0000000..f86c35b +--- /dev/null ++++ b/arch/arm/boot/dts/delta_ag6248c.dts +@@ -0,0 +1,78 @@ ++/* ++ * Delta Networks, Inc. AG6248C Device Tree Source ++ * ++ * Copyright 2015, Cumulus Networks, Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; either version 2 of the License, or (at your ++ * option) any later version. ++ * ++ */ ++/dts-v1/; ++/include/ "helix4.dtsi" ++ ++/ { ++ model = "delta,ag6248c"; ++ compatible = "delta,ag6248c"; ++ ++ aliases { ++ serial0 = &uart0; ++ i2c-controller0 = &i2c0; ++ i2c-controller1 = &i2c1; ++ }; ++ ++ memory { ++ reg = <0x61000000 0x7f000000>; ++ }; ++ ++ cpus { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ cpu@0 { ++ device_type = "cpu"; ++ compatible = "arm,cortex-a9"; ++ next-level-cache = <&L2>; ++ reg = <0x00>; ++ }; ++ cpu@1 { ++ device_type = "cpu"; ++ compatible = "arm,cortex-a9"; ++ next-level-cache = <&L2>; ++ reg = <0x01>; ++ }; ++ }; ++ ++ localbus@1e000000{ ++ address-cells = <0x2>; ++ #size-cells = <0x1>; ++ compatible = "simple-bus"; ++ ranges = <0x0 0x0 0x1e000000 0x02000000>; ++ ++ }; ++ ++ i2c0: i2c@18038000 { ++ compatible = "iproc-smb"; ++ reg = <0x18038000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ interrupts = < 127 >; ++ clock-frequency = <400000>; ++ rtc@68 { ++ compatible = "m41st85"; ++ reg = <0x68>; ++ }; ++ }; ++ ++ ++ i2c1: i2c@1803b000 { ++ compatible = "iproc-smb"; ++ reg = <0x1803b000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ interrupts = < 128 >; ++ clock-frequency = <100000>; ++ ++ }; ++}; +diff --git a/arch/arm/mach-iproc/Kconfig b/arch/arm/mach-iproc/Kconfig +index c77208d..c6a87fc 100644 +--- a/arch/arm/mach-iproc/Kconfig ++++ b/arch/arm/mach-iproc/Kconfig +@@ -49,6 +49,12 @@ config MACH_ACCTON_AS4610_54 + help + Support for Accton AS4610-54 POE and non -POE board. + ++config MACH_DELTA_AG6248C ++ select ARM_L1_CACHE_SHIFT_6 ++ bool "Support Delta AG6248C board" ++ help ++ Support for Delta AG6248C board. ++ + config MACH_IPROC_P7 + bool "Support iProc Profile 7 architecture" + depends on MACH_GH +diff --git a/arch/arm/mach-iproc/board_bu.c b/arch/arm/mach-iproc/board_bu.c +index 7e07ed1..5479020 100644 +--- a/arch/arm/mach-iproc/board_bu.c ++++ b/arch/arm/mach-iproc/board_bu.c +@@ -1083,6 +1083,7 @@ MACHINE_END + static const char * helix4_dt_board_compat[] = { + "dni,dni_3448p", + "accton,as4610_54", ++ "delta,ag6248c", + NULL + }; + +diff --git a/arch/arm/mach-iproc/common.c b/arch/arm/mach-iproc/common.c +index b116ffc..e911a2b 100644 +--- a/arch/arm/mach-iproc/common.c ++++ b/arch/arm/mach-iproc/common.c +@@ -187,7 +187,8 @@ static struct platform_device wdt_device = + enum { + HX4_NONE = 0, + HX4_DNI_3448P, +- HX4_ACCTON_AS4610_54 ++ HX4_ACCTON_AS4610_54, ++ HX4_DELTA_AG6248C, + }; + + /* +@@ -212,6 +213,8 @@ int brcm_get_hx4_model(void) + return HX4_DNI_3448P; + else if (!strcmp(model, "accton,as4610_54")) + return HX4_ACCTON_AS4610_54; ++ else if (!strcmp(model, "delta,ag6248c")) ++ return HX4_DELTA_AG6248C; + + printk( KERN_ERR "Unknown Model %s\n", model ); + return HX4_NONE; +diff --git a/arch/arm/mach-iproc/include/mach/iproc_regs.h b/arch/arm/mach-iproc/include/mach/iproc_regs.h +index 460c436..50ea557 100644 +--- a/arch/arm/mach-iproc/include/mach/iproc_regs.h ++++ b/arch/arm/mach-iproc/include/mach/iproc_regs.h +@@ -364,7 +364,11 @@ + #define IPROC_GMAC3_INT 182 + #elif (defined(CONFIG_MACH_HX4) || defined(CONFIG_MACH_KT2) || defined(CONFIG_MACH_DNI_3448P) || \ + defined(CONFIG_MACH_ACCTON_AS4610_54)) ++#if defined(CONFIG_MACH_DELTA_AG6248C) ++#define IPROC_NUM_GMACS 1 ++#else + #define IPROC_NUM_GMACS 2 ++#endif + #define IPROC_GMAC0_REG_BASE (GMAC0_DEVCONTROL) //(0x18022000) + #define IPROC_GMAC1_REG_BASE (GMAC1_DEVCONTROL) //(0x18023000) + #define IPROC_GMAC2_REG_BASE (0) // n/a +diff --git a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c +index d5b400d..a823697 100644 +--- a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c ++++ b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c +@@ -143,7 +143,8 @@ __setup("envaddr=", envaddr_setup); + enum { + HX4_NONE = 0, + HX4_DNI_3448P, +- HX4_ACCTON_AS4610_54 ++ HX4_ACCTON_AS4610_54, ++ HX4_DELTA_AG6248C + }; + + static void +@@ -158,7 +159,10 @@ setup_uboot_vars(void) { + } else if (modelnum == HX4_ACCTON_AS4610_54) { + env_offset = 0x000f0000; + uboot_vars_start = CONFIG_SPI_BASE + env_offset; +- } ++ }else if (modelnum == HX4_DELTA_AG6248C) { ++ env_offset = 0x00300000; ++ uboot_vars_start = CONFIG_NAND_BASE + env_offset; ++ } + } + + /* +-- +2.1.4 + diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series index e2adb686..3028ed13 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series @@ -506,3 +506,4 @@ scripts_package_Makefile.patch tools_include_tools_be_byteshift.h.patch tools_include_tools_le_byteshift.h.patch platform-accton-as4610-device-drivers.patch +platform-delta-ag6248c-device-drivers.patch diff --git a/packages/platforms/delta/armel/Makefile b/packages/platforms/delta/armel/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/README.md b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md new file mode 100644 index 00000000..b49d2126 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md @@ -0,0 +1,25 @@ +#How to run ONL in DELTA AG6248C board + +For the first step, it only support install the ONL to the USB and boot up. +It will be support to install the ONL to NandFlash next step. + +Build the ONL +-------------------------------------------------------------------------- +Please refer the $ONL/docs/Building.md + +Install the ONL through ONIE +-------------------------------------------------------------------------- +``` +ONIE:/ # onie-discovery-stop +discover: installer mode detected. +Stopping: discover... done. +ONIE:/ # +ONIE:/ # ifconfig eth0 192.168.1.1 #configure the DUT IP address +ONIE:/ # tftp -r ONL-2.*_ARMEL_INSTALLED_INSTALLER -g 192.168.1.99 -b 10240 +ONIE:/ # onie-nos-install ONL-2.*_ARMEL_INSTALLED_INSTALLER +``` +Boot the ONL +-------------------------------------------------------------------------- +Device will reboot automatically after install the ONL installer successfull. + +Now it will start the ONL boot progress. diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore new file mode 100644 index 00000000..4d978b36 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore @@ -0,0 +1,2 @@ +*x86*64*cel*redstone*xp*.mk +onlpdump.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml new file mode 100755 index 00000000..cb9893f5 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c KERNELS="onl-kernel-3.2-lts-arm-iproc-all:armel" diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore new file mode 100755 index 00000000..a813c369 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore @@ -0,0 +1,2 @@ +onlpdump.mk +lib diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile new file mode 100755 index 00000000..465902c8 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.2-lts-arm-iproc-all:armel +KMODULES := $(wildcard *.c) +VENDOR := delta +BASENAME := arm-delta-ag6248c +ARCH := arm +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c new file mode 100755 index 00000000..56d68b13 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c @@ -0,0 +1,242 @@ +/* + * An I2C multiplexer dirver for delta as5812 CPLD + * + * Copyright (C) 2017 Delta Networks, Inc. + * Brandon Chuang + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Delta ag7648c CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x0 +#define CTRL_CPLD_I2C_ADDR 0x28 +#define PARENT_CHAN 0x0 +#define NUM_OF_CPLD_CHANS 0x2 + +#define CPLD_CHANNEL_SELECT_REG 0x19 +#define CPLD_CHANNEL_SELECT_MASK 0x3 +#define CPLD_CHANNEL_SELECT_OFFSET 0x0 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x2 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try; + s32 res = -EIO; + u8 reg_val = 0; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // read first + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + + // modify the field we wanted + data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte |= reg_val; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Dave Hu "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c new file mode 100755 index 00000000..12b5fb38 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c @@ -0,0 +1,243 @@ +/* + * An I2C multiplexer dirver for delta as5812 CPLD + * + * Copyright (C) 2017 Delta Networks, Inc. + * Brandon Chuang + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Delta ag7648c CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x0 +#define CTRL_CPLD_I2C_ADDR 0x28 +#define PARENT_CHAN 0x1 +#define NUM_OF_CPLD_CHANS 0x2 + +#define CPLD_CHANNEL_SELECT_REG 0x19 +#define CPLD_CHANNEL_SELECT_MASK 0x3 +#define CPLD_CHANNEL_SELECT_OFFSET 0x5 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x2 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try; + s32 res = -EIO; + u8 reg_val = 0; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // read first + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + + // modify the field we wanted + data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte |= reg_val; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Dave Hu "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml new file mode 100644 index 00000000..63b56dc7 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=arm-delta-ag6248c ARCH=armel TOOLCHAIN=arm-linux-gnueabi diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile new file mode 100644 index 00000000..46fdfee8 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile @@ -0,0 +1,44 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.armel.mk + +MODULE := libonlp-arm-delta-ag6248c +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF arm_delta_ag6248c onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-arm-delta-ag6248c.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk new file mode 100644 index 00000000..9cf2a027 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-arm-delta-ag6248c module. +# +# Autogenerated 2016-07-20 18:27:47.344268 +# +############################################################################### +libonlp-arm-delta-ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..3fe979f3 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.armel.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp arm_delta_ag6248c onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml new file mode 100644 index 00000000..16ff5c28 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c REVISION=r0 diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml new file mode 100644 index 00000000..ba1cbec5 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml @@ -0,0 +1,43 @@ +--- + +###################################################################### +# +# platform-config for AG6248C +# +###################################################################### + +arm-delta-ag6248c-r0: + flat_image_tree: + kernel: + <<: *arm-iproc-kernel + dtb: + =: delta_ag6248c.dtb + <<: *arm-iproc-kernel-package + itb: + <<: *arm-itb + + loader: + device: /dev/mtdblock4 + loadaddr: 0x70000000 + nos_bootcmds: *flash_bootcmds + + environment: + - device: /dev/mtd2 + env_offset: 0x00000000 + env_size: 0x00002000 + sector_size: 0x00010000 + + installer: + - ONL-BOOT: + =: 128MiB + format: ubifs + - ONL-CONFIG: + =: 128MiB + format: ubifs + - ONL-IMAGES: + =: 1024MiB + format: ubifs + - ONL-DATA: + =: 2048MiB + format: ubifs + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py new file mode 100755 index 00000000..7d7b97a1 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py @@ -0,0 +1,23 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_arm_delta_ag6248c_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x1_2x10): + PLATFORM='arm-delta-ag6248c-r0' + MODEL="AG6248C" + SYS_OBJECT_ID=".6248.2" + + def baseconfig(self): + self.insmod('arm-delta-ag6248c-cpld-mux-1.ko') + self.insmod('arm-delta-ag6248c-cpld-mux-2.ko') + + self.new_i2c_devices( + [ + # initiate lm75 + ('tmp75', 0x49, 0), + ('tmp75', 0x4a, 0), + + + + ] + ) + return True diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore new file mode 100644 index 00000000..82fb1eaf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore @@ -0,0 +1,2 @@ +/arm_delta_ag6248c_poe.mk +/doc diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module new file mode 100644 index 00000000..1e18e32c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module @@ -0,0 +1 @@ +name: arm_delta_ag6248c diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile new file mode 100644 index 00000000..bfc40983 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile @@ -0,0 +1,28 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.mk +MODULE := arm_delta_ag6248c +AUTOMODULE := arm_delta_ag6248c +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy new file mode 100644 index 00000000..b13fcf5d --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy @@ -0,0 +1,1869 @@ +# Doxyfile 1.8.3.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "arm_delta_ag6248c" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Open Network Platform Linux Example Implementation." + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented classes, +# or namespaces to their corresponding documentation. Such a link can be +# prevented in individual cases by by putting a percent sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if section-label ... \endif +# and \cond section-label ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. Do not use +# file names with spaces, bibtex cannot handle them. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = module/inc + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page (index.html). +# This can be useful if you have a project on for instance GitHub and want reuse +# the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# SVG. The default value is HTML-CSS, which is slower, but has the best +# compatibility. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a web server instead of a web client using Javascript. +# There are two flavours of web server based search depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. +# See the manual for details. + +SERVER_BASED_SEARCH = NO + +# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain +# the search results. Doxygen ships with an example indexer (doxyindexer) and +# search engine (doxysearch.cgi) which are based on the open source search engine +# library Xapian. See the manual for configuration details. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will returned the search results when EXTERNAL_SEARCH is enabled. +# Doxygen ships with an example search engine (doxysearch) which is based on +# the open source search engine library Xapian. See the manual for configuration +# details. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id +# of to a relative location where the documentation can be found. +# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... + +EXTRA_SEARCH_MAPPINGS = + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50 percent before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk new file mode 100644 index 00000000..42ac4368 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk @@ -0,0 +1,13 @@ + +############################################################################### +# +# Inclusive Makefile for the arm_delta_ag6248c module. +# +# Autogenerated 2017-02-16 14:19:33.628446 +# +############################################################################### +arm_delta_ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(arm_delta_ag6248c_BASEDIR)module/make.mk +include $(arm_delta_ag6248c_BASEDIR)module/auto/make.mk +include $(arm_delta_ag6248c_BASEDIR)module/src/make.mk + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml new file mode 100644 index 00000000..80f1a97d --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml @@ -0,0 +1,67 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ + +cdefs: &cdefs +- ONLPSIM_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- ONLPSIM_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- ONLPSIM_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: ONLPSIM_CONFIG_PORTING_STDLIB +- ONLPSIM_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- ONLPSIM_CONFIG_SFP_COUNT: + doc: "SFP Count." + default: 0 + +definitions: + cdefs: + ONLPSIM_CONFIG_HEADER: + defs: *cdefs + basename: arm_delta_ag6248c_config + + portingmacro: + ONLPSIM: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk new file mode 100644 index 00000000..57889792 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk @@ -0,0 +1,28 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ + +arm_delta_ag6248c_AUTO_DEFS := module/auto/arm_delta_ag6248c.yml +arm_delta_ag6248c_AUTO_DIRS := module/inc/arm_delta_ag6248c module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x new file mode 100644 index 00000000..f15500cc --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x @@ -0,0 +1,34 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h new file mode 100644 index 00000000..68664185 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h @@ -0,0 +1,162 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +/**************************************************************************//** + * + * @file + * @brief arm_delta_ag6248c Configuration Header + * + * @addtogroup arm_delta_ag6248c-config + * @{ + * + *****************************************************************************/ +#ifndef __ONLPSIM_CONFIG_H__ +#define __ONLPSIM_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef ONLPSIM_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * ONLPSIM_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef ONLPSIM_CONFIG_INCLUDE_LOGGING +#define ONLPSIM_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT +#define ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * ONLPSIM_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef ONLPSIM_CONFIG_LOG_BITS_DEFAULT +#define ONLPSIM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * ONLPSIM_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef ONLPSIM_CONFIG_PORTING_STDLIB +#define ONLPSIM_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLPSIM_CONFIG_PORTING_STDLIB +#endif + +/** + * ONLPSIM_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef ONLPSIM_CONFIG_INCLUDE_UCLI +#define ONLPSIM_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * ONLPSIM_CONFIG_SFP_COUNT + * + * SFP Count. */ + + +#ifndef ONLPSIM_CONFIG_SFP_COUNT +#define ONLPSIM_CONFIG_SFP_COUNT 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct arm_delta_ag6248c_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} arm_delta_ag6248c_config_settings_t; + +/** Configuration settings table. */ +/** arm_delta_ag6248c_config_settings table. */ +extern arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* arm_delta_ag6248c_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "arm_delta_ag6248c_porting.h" + +#endif /* __ONLPSIM_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h new file mode 100644 index 00000000..20f312ed --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h @@ -0,0 +1,51 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +/********************************************************//** + * + * arm_delta_ag6248c Doxygen Header + * + ***********************************************************/ +#ifndef __ONLPSIM_DOX_H__ +#define __ONLPSIM_DOX_H__ + +/** + * @defgroup arm_delta_ag6248c arm_delta_ag6248c - onlpsim Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup arm_delta_ag6248c-arm_delta_ag6248c Public Interface + * @defgroup arm_delta_ag6248c-config Compile Time Configuration + * @defgroup arm_delta_ag6248c-porting Porting Macros + * + * @} + * + */ + +#endif /* __ONLPSIM_DOX_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h new file mode 100644 index 00000000..19853401 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h @@ -0,0 +1,132 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +/********************************************************//** + * + * @file + * @brief arm_delta_ag6248c Porting Macros. + * + * @addtogroup arm_delta_ag6248c-porting + * @{ + * + ***********************************************************/ +#ifndef __ONLPSIM_PORTING_H__ +#define __ONLPSIM_PORTING_H__ + + +/* */ +#if ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef ONLPSIM_MALLOC + #if defined(GLOBAL_MALLOC) + #define ONLPSIM_MALLOC GLOBAL_MALLOC + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_MALLOC malloc + #else + #error The macro ONLPSIM_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_FREE + #if defined(GLOBAL_FREE) + #define ONLPSIM_FREE GLOBAL_FREE + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_FREE free + #else + #error The macro ONLPSIM_FREE is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_MEMSET + #if defined(GLOBAL_MEMSET) + #define ONLPSIM_MEMSET GLOBAL_MEMSET + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_MEMSET memset + #else + #error The macro ONLPSIM_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define ONLPSIM_MEMCPY GLOBAL_MEMCPY + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_MEMCPY memcpy + #else + #error The macro ONLPSIM_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define ONLPSIM_STRNCPY GLOBAL_STRNCPY + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_STRNCPY strncpy + #else + #error The macro ONLPSIM_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define ONLPSIM_VSNPRINTF GLOBAL_VSNPRINTF + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_VSNPRINTF vsnprintf + #else + #error The macro ONLPSIM_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define ONLPSIM_SNPRINTF GLOBAL_SNPRINTF + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_SNPRINTF snprintf + #else + #error The macro ONLPSIM_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_STRLEN + #if defined(GLOBAL_STRLEN) + #define ONLPSIM_STRLEN GLOBAL_STRLEN + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_STRLEN strlen + #else + #error The macro ONLPSIM_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __ONLPSIM_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk new file mode 100644 index 00000000..29f7a9f3 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk @@ -0,0 +1,29 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +arm_delta_ag6248c_INCLUDES := -I $(THIS_DIR)inc +arm_delta_ag6248c_INTERNAL_INCLUDES := -I $(THIS_DIR)src +arm_delta_ag6248c_DEPENDMODULE_ENTRIES := init:arm_delta_ag6248c ucli:arm_delta_ag6248c + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile new file mode 100644 index 00000000..94aa2ec9 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile @@ -0,0 +1,30 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# Local source generation targets. +# +############################################################ + +include ../../../../init.mk + +ucli: + $(SUBMODULE_BIGCODE)/tools/uclihandlers.py arm_delta_ag6248c_ucli.c + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c new file mode 100644 index 00000000..6447135c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c @@ -0,0 +1,101 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +/* */ +#define __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) #_x +#define __arm_delta_ag6248c_config_STRINGIFY_VALUE(_x) __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) +arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[] = +{ +#ifdef ONLPSIM_CONFIG_INCLUDE_LOGGING + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_LOGGING), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_LOGGING) }, +#else +{ ONLPSIM_CONFIG_INCLUDE_LOGGING(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_LOG_BITS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ ONLPSIM_CONFIG_LOG_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_PORTING_STDLIB + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_STDLIB), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_STDLIB) }, +#else +{ ONLPSIM_CONFIG_PORTING_STDLIB(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_INCLUDE_UCLI + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_UCLI), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_UCLI) }, +#else +{ ONLPSIM_CONFIG_INCLUDE_UCLI(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_SFP_COUNT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_SFP_COUNT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_SFP_COUNT) }, +#else +{ ONLPSIM_CONFIG_SFP_COUNT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __arm_delta_ag6248c_config_STRINGIFY_VALUE +#undef __arm_delta_ag6248c_config_STRINGIFY_NAME + +const char* +arm_delta_ag6248c_config_lookup(const char* setting) +{ + int i; + for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) { + if(strcmp(arm_delta_ag6248c_config_settings[i].name, setting)) { + return arm_delta_ag6248c_config_settings[i].value; + } + } + return NULL; +} + +int +arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", arm_delta_ag6248c_config_settings[i].name, arm_delta_ag6248c_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c new file mode 100644 index 00000000..2a14c2cc --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c @@ -0,0 +1,30 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h new file mode 100644 index 00000000..8dfd2c7c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h @@ -0,0 +1,32 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#ifndef __ONLPSIM_INT_H__ +#define __ONLPSIM_INT_H__ + +#include + + +#endif /* __ONLPSIM_INT_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c new file mode 100644 index 00000000..1941f294 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c @@ -0,0 +1,38 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +#include "arm_delta_ag6248c_log.h" +/* + * arm_delta_ag6248c log struct. + */ +AIM_LOG_STRUCT_DEFINE( + ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT, + ONLPSIM_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h new file mode 100644 index 00000000..13d00bc5 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h @@ -0,0 +1,32 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#ifndef __ONLPSIM_LOG_H__ +#define __ONLPSIM_LOG_H__ + +#define AIM_LOG_MODULE_NAME arm_delta_ag6248c +#include + +#endif /* __ONLPSIM_LOG_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c new file mode 100644 index 00000000..fdb080f0 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c @@ -0,0 +1,44 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +#include "arm_delta_ag6248c_log.h" + +static int +datatypes_init__(void) +{ +#define ONLPSIM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __arm_delta_ag6248c_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c new file mode 100644 index 00000000..4dbeeed0 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c @@ -0,0 +1,82 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +#if ONLPSIM_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +arm_delta_ag6248c_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(arm_delta_ag6248c) +} + +/* */ +/****************************************************************************** + * + * These handler table(s) were autogenerated from the symbols in this + * source file. + * + *****************************************************************************/ +static ucli_command_handler_f arm_delta_ag6248c_ucli_ucli_handlers__[] = +{ + arm_delta_ag6248c_ucli_ucli__config__, + NULL +}; +/******************************************************************************/ +/* */ + +static ucli_module_t +arm_delta_ag6248c_ucli_module__ = + { + "arm_delta_ag6248c_ucli", + NULL, + arm_delta_ag6248c_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +arm_delta_ag6248c_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&arm_delta_ag6248c_ucli_module__); + n = ucli_node_create("arm_delta_ag6248c", NULL, &arm_delta_ag6248c_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("arm_delta_ag6248c")); + return n; +} + +#else +void* +arm_delta_ag6248c_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c new file mode 100755 index 00000000..a7a83e0e --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "arm_delta_ag6248c_log.h" +#include "arm_delta_i2c.h" +#include + +struct i2c_device_info i2c_device_list[]={ + {"RTC",0X0,0X68}, + {"TMP1_CLOSE_TO_MAC",0X0,0X49}, + {"TMP2_CLOSE_TO_PHY",0X0,0X4a}, + {"CPLD",0X0,0X28}, + {"FAN_ON_BOARD",0X1,0X2C}, + {"CURT_MONTOR",0X1,0X40}, + {"SFP1",0X2,0X50}, + {"SFP2",0X3,0X50}, +// ------------------------- + {"PSU1_PMBUS",0X4,0X58}, + {"PSU2_PMBUS",0X5,0X59}, + {"PSU1_EEPROM",0X4,0X50}, + {"PSU2_EEPROM",0X5,0X51}, +// ------------------------- + {"PSU1_PMBUS_POE",0X4,0X58}, + {"PSU2_PMBUS_POE",0X5,0X58}, + {"PSU1_EEPROM_POE",0X4,0X52}, + {"PSU2_EEPROM_POE",0X5,0X52}, + {NULL, -1,-1}, +}; + + +uint32_t i2c_flag=ONLP_I2C_F_FORCE; + + +i2c_device_info_t *i2c_dev_find_by_name (char *name) +{ + i2c_device_info_t *i2c_dev = i2c_device_list; + + if (name == NULL) return NULL; + + while (i2c_dev->name) { + if (strcmp (name, i2c_dev->name) == 0) break; + ++ i2c_dev; + } + if (i2c_dev->name == NULL) return NULL; + + return i2c_dev; +} + +int i2c_devname_read_byte (char *name, int reg) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_readb (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); + + return ret; +} + +int i2c_devname_write_byte (char *name, int reg, int value) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_writeb (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); + + + return ret; +} + +int i2c_devname_read_word (char *name, int reg) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_readw (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); + + return ret; +} + +int i2c_devname_write_word (char *name, int reg, int value) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_writew (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); + + return ret; +} + +int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size) +{ + int ret = -1; + + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret = onlp_i2c_block_read (i2c_dev->i2cbus, i2c_dev->addr, reg, buff_size, buff, i2c_flag); + + return ret; + +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h new file mode 100755 index 00000000..76c35cbb --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h @@ -0,0 +1,54 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************/ +/* the i2c struct header*/ + +#ifndef __ARM_DELTA_I2C_H__ +#define __ARM_DELTA_I2C_H__ + +#include "arm_delta_ag6248c_log.h" + +struct i2c_device_info { + /*i2c device name*/ + char *name; + char i2cbus; + char addr; +}; + + +typedef struct i2c_device_info i2c_device_info_t; + +extern struct i2c_device_info i2c_device_list[]; + + +extern int i2c_devname_read_byte(char *name, int reg); + +extern int i2c_devname_write_byte(char *name, int reg, int value); + + +extern int i2c_devname_read_word(char *name, int reg); + +extern int i2c_devname_write_word(char *name, int reg, int value); + + +extern int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size); + +#endif diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c new file mode 100755 index 00000000..9e0fb0cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c @@ -0,0 +1,463 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_i2c.h" + + +#define MAX_FAN_SPEED 16000 +#define MAX_PSU_FAN_SPEED 23000 + +#define FILE_NAME_LEN 80 + +/* The MAX6639 registers, valid channel numbers: 0, 1 */ +#define MAX6639_REG_STATUS 0x02 +#define MAX6639_REG_FAN_CONFIG1(ch) (0x10 + 4*(ch-1)) +#define MAX6639_REG_FAN_CNT(ch) (0x20 + (ch-1)) +#define MAX6639_REG_TARGET_CNT(ch) (0x22 + (ch-1)) + +/*define the reg bit mask*/ +#define MAX6639_REG_FAN_STATUS_BIT(ch) (0X02>>(ch-1)) +#define MAX6639_FAN_CONFIG1_RPM_RANGE 0x03 +#define MAX6639_FAN_PRESENT_REG (0x0c) +#define MAX6639_FAN_PRESENT_BIT (0x2) +#define MAX6639_FAN_GOOD_BIT (0x1) +#define FAN_FROM_REG(val) ((480000.0) / (val)) + +static int fan_initd=0; + +enum onlp_fan_id +{ + FAN_RESERVED = 0, + FAN_1_ON_MAIN_BOARD, + FAN_2_ON_MAIN_BOARD, + FAN_1_ON_PSU1, + FAN_1_ON_PSU2 +}; + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM| ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ + (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int + _onlp_psu_fan_val_to_rpm (int v) +{ + int lf = (v & 0xffff); + int y, n; + + y = lf & 0x7ff; + n = ((lf >> 11) & 0x1f); + + return (y * (1 << n)); +} + +static int +_onlp_fan_board_init(void) +{ + i2c_devname_write_byte("FAN_ON_BOARD", 0x03,0xfc); + i2c_devname_write_byte("FAN_ON_BOARD", 0x04,0x30); + + i2c_devname_write_byte("FAN_ON_BOARD", 0x10,0x23); + i2c_devname_write_byte("FAN_ON_BOARD", 0x11,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x12,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x13,0x21); + i2c_devname_write_byte("FAN_ON_BOARD", 0x24,0xe8); + + i2c_devname_write_byte("FAN_ON_BOARD", 0x14,0x23); + i2c_devname_write_byte("FAN_ON_BOARD", 0x15,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x16,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x17,0x21); + i2c_devname_write_byte("FAN_ON_BOARD", 0x25,0xe8); + + fan_initd=1; + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) +{ + int r_data,fan_good,fan_present,fan_fault; + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + /* get fan fault status (turn on when any one fails)*/ + r_data= i2c_devname_read_byte("CPLD",MAX6639_FAN_PRESENT_REG); + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_present = r_data & MAX6639_FAN_PRESENT_BIT; + + if(!fan_present){ + + info->status |= ONLP_FAN_STATUS_PRESENT; + + fan_good=r_data&MAX6639_FAN_GOOD_BIT; + + if(fan_good) + info->status&=~ONLP_FAN_STATUS_FAILED; + else{ + r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_STATUS); + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_fault=r_data & MAX6639_REG_FAN_STATUS_BIT(local_id); + + if(!fan_fault) + info->status &=~ ONLP_FAN_STATUS_FAILED; + else{ + info->status |=ONLP_FAN_STATUS_FAILED; + info->rpm=0; + info->percentage=0; + goto mode; + } + } + } + else{ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* get fan speed */ + r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_FAN_CNT(local_id)); + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + info->rpm = FAN_FROM_REG(r_data); + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_FAN_SPEED; + +mode: + if(info->percentage>100) + strcpy(info->model,"ONLP_FAN_MODE_LAST"); + else if(info->percentage==100) + strcpy(info->model,"ONLP_FAN_MODE_MAX"); + else if(info->percentage>=75&&info->percentage<100) + strcpy(info->model,"ONLP_FAN_MODE_FAST"); + else if(info->percentage>=35&&info->percentage<75) + strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); + else if(info->percentage>0&&info->percentage<35) + strcpy(info->model,"ONLP_FAN_MODE_SLOW"); + else if(info->percentage<=0) + strcpy(info->model,"ONLP_FAN_MODE_OFF"); + else{ } + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) +{ + int psu_id; + int r_data,fan_rpm; + + psu_type_t psu_type; + + enum ag6248c_product_id pid = get_product_id(); + /* get fan fault status + */ + psu_id = (local_id - FAN_1_ON_PSU1) + 1; + DEBUG_PRINT("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id); + + psu_type = get_psu_type(psu_id); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */ + DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B); + break; + case PSU_TYPE_AC_B2F: + info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* get fan speed*/ + if(pid == PID_AG6248C_48){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x90); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x90); + } + else{ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x90); + else + r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x90); + } + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_rpm=_onlp_psu_fan_val_to_rpm(r_data); + + info->rpm = fan_rpm; + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_PSU_FAN_SPEED; + + if(info->percentage>100) + strcpy(info->model,"ONLP_FAN_MODE_LAST"); + else if(info->percentage==100) + strcpy(info->model,"ONLP_FAN_MODE_MAX"); + else if(info->percentage>=75&&info->percentage<100) + strcpy(info->model,"ONLP_FAN_MODE_FAST"); + else if(info->percentage>=35&&info->percentage<75) + strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); + else if(info->percentage>0&&info->percentage<35) + strcpy(info->model,"ONLP_FAN_MODE_SLOW"); + else if(info->percentage<=0) + strcpy(info->model,"ONLP_FAN_MODE_OFF"); + else{} + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + int rc; + rc=_onlp_fan_board_init(); + return rc; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if (chassis_fan_count() == 0) { + local_id += 1; + } + + *info = linfo[local_id]; + + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + rc = _onlp_fani_info_get_fan_on_psu(local_id, info); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ /* + the rpm is the actual rpm/1000. so 16 represents the 16000(max spd) + */ + int fan_set_rpm_cont,rc; + int local_id; + int actual_rpm=rpm; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) + return ONLP_STATUS_E_UNSUPPORTED; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_INVALID; + } + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + /* reject rpm=0 (rpm=0, stop fan) */ + if (actual_rpm == 0) + return ONLP_STATUS_E_INVALID; + + /*get ret value for the speed set*/ + fan_set_rpm_cont=FAN_FROM_REG(actual_rpm); + + /*set the rpm speed */ + rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont); + + if(rc<0) + return ONLP_STATUS_E_INVALID; + + return ONLP_STATUS_OK; +} +/*set the percentage for the psu fan*/ + + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + /* + p is between 0 and 100 ,p=100 represents 16000(max spd) + */ + int rpm_val,fan_set_rpm_cont,rc; + int local_id; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) + return ONLP_STATUS_E_UNSUPPORTED; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_INVALID; + } + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + rpm_val=p* MAX_PSU_FAN_SPEED/100; + + /*get ret value for the speed set*/ + fan_set_rpm_cont=FAN_FROM_REG(rpm_val); + + /*set the rpm speed */ + rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(id), fan_set_rpm_cont); + + if(rc<0) + return ONLP_STATUS_E_INVALID; + + return ONLP_STATUS_OK; + + +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c new file mode 100755 index 00000000..1a0ea7bb --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c @@ -0,0 +1,352 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include + +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_i2c.h" +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +#define CPLD_LED_MODE_REG (0X0A) +#define CPLD_LED_MODE_TEMP_REG (0X0B) +#define CPLD_LED_MODE_REG_BIT(ch) (0x3<<2*((ch)-1)) +#define CPLD_LED_MODE_TEMP_REG_BIT (0x0C) +#define CPLD_LED_MODE_MASTER_REG_BIT (0x02) +#define CPLD_LED_MODE_REG_OFFSET(ch) (2*((ch)-1)) +#define CPLD_LED_MODE_TEMP_REG_OFFSET (2) +#define CPLD_LED_MODE_MASTER_REG_OFFSET (1) + + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS), "sys", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN_BLINKING |ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_RED , + }, + + { + { ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 }, + ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + + { + { ONLP_LED_ID_CREATE(LED_PSU2), "psu2", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_GREEN , + }, + + { + { ONLP_LED_ID_CREATE(LED_PSU1), "psu1", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_GREEN , + }, + + { + { ONLP_LED_ID_CREATE(LED_TEMP), "temp", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_RED , + }, + + { + { ONLP_LED_ID_CREATE(LED_MASTER), "master", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN , + }, +}; + +static int conver_led_light_mode_to_onl(uint32_t id, int led_ligth_mode) +{ + switch (id) { + case LED_SYS: + switch (led_ligth_mode) { + case SYS_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; + case SYS_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case SYS_LED_MODE_RED: return ONLP_LED_MODE_RED; + case SYS_LED_MODE_RED_BLINKING: return ONLP_LED_MODE_RED_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_PSU1: + case LED_PSU2: + switch (led_ligth_mode) { + case PSU_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case PSU_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case PSU_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_FAN: + switch (led_ligth_mode) { + case FAN_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case FAN_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case FAN_LED_MODE_RED: return ONLP_LED_MODE_RED; + default: return ONLP_LED_MODE_OFF; + } + case LED_TEMP: + switch (led_ligth_mode) { + case TEMP_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case TEMP_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case TEMP_LED_MODE_RED: return ONLP_LED_MODE_RED; + default: return ONLP_LED_MODE_OFF; + } + case LED_MASTER: + switch (led_ligth_mode) { + case MASTER_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case MASTER_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + default: return ONLP_LED_MODE_OFF; + } + } + + return ONLP_LED_MODE_OFF; +} + +static int conver_onlp_led_light_mode_to_driver(uint32_t id, int led_ligth_mode) +{ + switch (id) { + case LED_SYS: + switch (led_ligth_mode) { + case ONLP_LED_MODE_GREEN_BLINKING: return SYS_LED_MODE_GREEN_BLINKING; + case ONLP_LED_MODE_GREEN: return SYS_LED_MODE_GREEN; + case ONLP_LED_MODE_RED: return SYS_LED_MODE_RED ; + case ONLP_LED_MODE_RED_BLINKING: return SYS_LED_MODE_RED_BLINKING; + default: return SYS_LED_MODE_UNKNOWN; + } + case LED_PSU1: + case LED_PSU2: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return PSU_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return PSU_LED_MODE_GREEN; + case ONLP_LED_MODE_GREEN_BLINKING: return PSU_LED_MODE_GREEN_BLINKING; + default: return PSU_LED_MODE_UNKNOWN; + } + case LED_FAN: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return FAN_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return FAN_LED_MODE_GREEN ; + case ONLP_LED_MODE_RED: return FAN_LED_MODE_RED; + default: return FAN_LED_MODE_UNKNOWN; + } + case LED_TEMP: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return TEMP_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return TEMP_LED_MODE_GREEN; + case ONLP_LED_MODE_RED: return TEMP_LED_MODE_RED; + default: return TEMP_LED_MODE_UNKNOWN; + } + case LED_MASTER: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return MASTER_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return MASTER_LED_MODE_GREEN; + default: return TEMP_LED_MODE_UNKNOWN; + } + + } + + return ONLP_LED_MODE_OFF; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +onlp_ledi_oid_to_internal_id(onlp_oid_t id) +{ + enum ag6248c_product_id pid = get_product_id(); + int lid = ONLP_OID_ID_GET(id); + + if ((pid != PID_AG6248C_48P)||(pid != PID_AG6248C_48)) { + return lid; + } + + switch (lid) { + case 1: return LED_SYS; + case 2: return LED_FAN; + case 3: return LED_PSU2; + case 4: return LED_PSU1; + case 5: return LED_TEMP; + case 6: return LED_MASTER; + } + + return lid; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int r_data,m_data; + + int lid = onlp_ledi_oid_to_internal_id(id); + + VALIDATE(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[lid]; + + if((lid==LED_TEMP)||(lid==LED_MASTER)) + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG); + else + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG); + + if(r_data<0) + return ONLP_STATUS_E_INTERNAL; + + if(lid==LED_TEMP) + m_data=(r_data & CPLD_LED_MODE_TEMP_REG_BIT); + else if(lid==LED_MASTER) + m_data=(r_data & CPLD_LED_MODE_MASTER_REG_BIT); + else + m_data=(r_data & CPLD_LED_MODE_REG_BIT(lid)); + + if(lid==LED_TEMP) + m_data=(m_data>> CPLD_LED_MODE_TEMP_REG_OFFSET); + else if(lid==LED_MASTER) + m_data=(m_data>> CPLD_LED_MODE_MASTER_REG_OFFSET); + else + m_data=(m_data>>CPLD_LED_MODE_REG_OFFSET(lid)); + + info->mode = conver_led_light_mode_to_onl(lid, m_data); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + + } + + return ONLP_STATUS_OK; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int r_data,driver_mode, rc; + + int lid = onlp_ledi_oid_to_internal_id(id); + + VALIDATE(id); + + driver_mode = conver_onlp_led_light_mode_to_driver(lid, mode); + + if((driver_mode==SYS_LED_MODE_UNKNOWN)||(driver_mode==PSU_LED_MODE_UNKNOWN)||\ + (driver_mode==FAN_LED_MODE_UNKNOWN)||(driver_mode==TEMP_LED_MODE_UNKNOWN)||\ + (driver_mode==MASTER_LED_MODE_UNKNOWN)) + return ONLP_STATUS_E_UNSUPPORTED; + + if((lid==LED_TEMP)||(lid==LED_MASTER)) + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG); + else + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG); + + if(r_data<0) + return ONLP_STATUS_E_INTERNAL; + + if(lid==LED_TEMP) + r_data=r_data&(~CPLD_LED_MODE_TEMP_REG_BIT); + else if(lid==LED_MASTER) + r_data=r_data&(~CPLD_LED_MODE_MASTER_REG_BIT); + else + r_data=r_data&(~CPLD_LED_MODE_REG_BIT(lid)); + + if(lid==LED_TEMP) + driver_mode=(driver_mode< +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ + +LIBRARY := arm_delta_ag6248c +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +#$(LIBRARY)_LAST := 1 +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c new file mode 100755 index 00000000..118cc437 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c @@ -0,0 +1,85 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_i2c.h" + + +psu_type_t get_psu_type(int id) +{ + if ((id == PSU1_ID)||(id == PSU2_ID)) + return PSU_TYPE_AC_B2F; + return PSU_TYPE_UNKNOWN; +} + +enum ag6248c_product_id get_product_id(void) +{ + int ret; + int pid = PID_UNKNOWN; + + ret = i2c_devname_read_byte("CPLD", 0X01); + + if(ret<0) + return PID_UNKNOWN; + + pid = ((ret&0xf0)>>4); + + + if (pid >= PID_UNKNOWN || pid < PID_AG6248C_48) { + return PID_UNKNOWN; + } + + return pid; +} + +int chassis_fan_count(void) +{ + enum ag6248c_product_id pid = get_product_id(); + + if ((pid == PID_AG6248C_48P)||(pid == PID_AG6248C_48)) { + return 4; + } + + return 0 ; +} + +int chassis_led_count(void) +{ + enum ag6248c_product_id pid = get_product_id(); + + if (pid == PID_AG6248C_48P) + return 5; + else if(pid == PID_AG6248C_48) + return 6; + else + return 0; +} diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h new file mode 100755 index 00000000..d0d01f24 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h @@ -0,0 +1,134 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "arm_delta_ag6248c_log.h" + +#define CHASSIS_THERMAL_COUNT 2 +#define CHASSIS_PSU_COUNT 2 + +#define PSU1_ID 1 +#define PSU2_ID 2 + + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +enum onlp_fan_duty_cycle_percentage +{ + FAN_IDLE_RPM = 5500, + FAN_LEVEL1_RPM = 7000, + FAN_LEVEL2_RPM = 9000, + FAN_LEVEL3_RPM = 12000, +}; + +enum ag6248c_product_id { + PID_AG6248C_48= 2, + PID_AG6248C_48P=4, + PID_UNKNOWN +}; +/* LED related data */ +enum sys_led_light_mode { + SYS_LED_MODE_GREEN_BLINKING = 0, + SYS_LED_MODE_GREEN, + SYS_LED_MODE_RED, + SYS_LED_MODE_RED_BLINKING, + SYS_LED_MODE_AUTO, + SYS_LED_MODE_UNKNOWN +}; + +enum fan_led_light_mode { + FAN_LED_MODE_OFF=0, + FAN_LED_MODE_GREEN, + FAN_LED_MODE_RED, + FAN_LED_MODE_RESERVERD, + FAN_LED_MODE_AUTO, + FAN_LED_MODE_UNKNOWN +}; + +enum psu_led_light_mode { + PSU_LED_MODE_OFF =0, + PSU_LED_MODE_GREEN, + PSU_LED_MODE_GREEN_BLINKING, + PSU_LED_MODE_RESERVERD, + PSU_LED_MODE_UNKNOWN +}; + +enum temp_led_light_mode { + TEMP_LED_MODE_OFF =0, + TEMP_LED_MODE_GREEN, + TEMP_LED_MODE_RED, + TEMP_LED_MODE_RESERVERD, + TEMP_LED_MODE_UNKNOWN +}; + +enum master_led_light_mode { + MASTER_LED_MODE_OFF =0, + MASTER_LED_MODE_GREEN, + MASTER_LED_MODE_OFF1, + MASTER_LED_MODE_RESERVERD, + MASTER_LED_MODE_UNKNOWN +}; + +typedef enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS, + LED_FAN, + LED_PSU2, + LED_PSU1, + LED_TEMP, + LED_MASTER +} onlp_led_id_t; + +enum ag6248c_product_id get_product_id(void); +int chassis_fan_count(void); +int chassis_led_count(void); + +typedef enum platform_id_e { + PLATFORM_ID_UNKNOWN, + PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0, + PLATFORM_ID_POWERPC_DELTA_AG6248C_R0, +} platform_id_t; + +extern platform_id_t platform_id; + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c new file mode 100755 index 00000000..66cfdb74 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c @@ -0,0 +1,380 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_i2c.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 +#define PSU_STATUS_REG (0X08) +#define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1)) +#define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1)) +#define PSU_STATUS_PRESENT_OFFSET(ch) (4*ch-1) +#define PSU_STATUS_GOOD_OFFSET(ch) (0x2+4*(ch-1)) +#define PSU_PNBUS_VIN_REG (0x88) +#define PSU_PNBUS_IIN_REG (0x89) +#define PSU_PNBUS_PIN_REG (0x97) +#define PSU_PNBUS_VOUT_REG (0x8b) +#define PSU_PNBUS_IOUT_REG (0x8c) +#define PSU_PNBUS_POUT_REG (0x96) +#define PSU_PNBUS_SERIAL_REG (0x39) +#define PSU_PNBUS_MODEL_REG (0xc) + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static long psu_data_convert(unsigned int d, int mult) +{ + long X, Y, N, n; + + Y = d & 0x07FF; + N = (d >> 11) & 0x0f; + n = d & 0x8000 ? 1 : 0; + + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = (Y * mult) * (N=(1<<(N&0xf))); + + return X; +} + +static long psu_data_convert_16(unsigned int d, int mult) +{ + long X; + X = (d * mult) / (1 << 9); + return X; + +} + + +static int +psu_status_info_get(int id, char *node) +{ + int ret; + int r_data; + ret=i2c_devname_read_byte("CPLD",PSU_STATUS_REG); + + if(ret<0) + return -1; + + if (PSU1_ID == id) { + if(!strcmp("present",node)) + r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); + else if(!strcmp("good",node)) + r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); + else + r_data=-1; + + } + else if (PSU2_ID == id) { + + if(!strcmp("present",node)) + r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); + else if(!strcmp("good",node)) + r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); + else + r_data=-1; + } + else{ + r_data=-1; + } + + return r_data; +} + +static int +psu_value_info_get(int id, char *type) +{ + int ret; + char *dev_name; + int reg_offset; + + enum ag6248c_product_id pid = get_product_id(); + + if(pid == PID_AG6248C_48){ + if(PSU1_ID == id) + dev_name="PSU1_PMBUS"; + else + dev_name="PSU2_PMBUS"; + } + else{ + if(PSU1_ID == id) + dev_name="PSU1_PMBUS_POE"; + else + dev_name="PSU2_PMBUS_POE"; + } + + if(!strcmp(type,"vin")) + reg_offset=PSU_PNBUS_VIN_REG; + else if(!strcmp(type,"iin")) + reg_offset=PSU_PNBUS_IIN_REG; + else if(!strcmp(type,"pin")) + reg_offset=PSU_PNBUS_PIN_REG; + else if(!strcmp(type,"vout")) + reg_offset=PSU_PNBUS_VOUT_REG; + else if(!strcmp(type,"iout")) + reg_offset=PSU_PNBUS_IOUT_REG; + else + reg_offset=PSU_PNBUS_POUT_REG; + + ret=i2c_devname_read_word(dev_name,reg_offset); + + if(ret<0) + return -1; + + return ret; +} + + +static int +psu_serial_model_info_get(int id,char *type,char*data,int data_len) +{ + int i,r_data,re_cnt; + char *dev_name; + int reg_offset; + + enum ag6248c_product_id pid = get_product_id(); + + if(pid == PID_AG6248C_48){ + if(PSU1_ID == id) + dev_name="PSU1_EEPROM"; + else + dev_name="PSU2_EEPROM"; + } + else{ + if(PSU1_ID == id) + dev_name="PSU1_EEPROM_POE"; + else + dev_name="PSU2_EEPROM_POE"; + } + + if(!strcmp(type,"serial")) + reg_offset=PSU_PNBUS_SERIAL_REG; + else + reg_offset=PSU_PNBUS_MODEL_REG; + + for(i=0;istatus &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + /* Get power good status */ + val=psu_status_info_get(index,"good"); + + if (val<0) { + AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + /* Get PSU type + */ + psu_type = get_psu_type(index); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + info->caps = ONLP_PSU_CAPS_AC; + ret = ONLP_STATUS_OK; + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + /* Get PSU vin,vout*/ + + r_data=psu_value_info_get(index,"vin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Vin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mvin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"vout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Vout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mvout=psu_data_convert_16(r_data,1000); + /* Get PSU iin, iout + */ + r_data=psu_value_info_get(index,"iin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Iin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->miin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"iout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Iout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->miout=psu_data_convert(r_data,1000); + + /* Get PSU pin, pout + */ + r_data=psu_value_info_get(index,"pin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Pin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mpin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"pout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Pout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mpout=psu_data_convert(r_data,1000); + /* Get PSU serial + */ + + ret=psu_serial_model_info_get(index,"serial",sn_data,14); + if (ret!=ONLP_STATUS_OK) { + AIM_LOG_INFO("Unable to read PSU %d SN value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + strcpy(info->serial,sn_data); + + /* Get PSU model + */ + ret=psu_serial_model_info_get(index,"model",model_data,16); + if (ret!=ONLP_STATUS_OK) { + AIM_LOG_INFO("Unable to read PSU %d model value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + strcpy(info->model,model_data); + + return ONLP_STATUS_OK; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c new file mode 100755 index 00000000..4764bbe9 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c @@ -0,0 +1,364 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#include +#include "arm_delta_ag6248c_log.h" +#include "arm_delta_i2c.h" + +#define SFP_PRESENT_REG (0X14) +#define SFP_RX_LOS_REG (0X11) +#define SFP_TX_DISABLE_REG (0X17) +#define SFP_PRESENT_PORT47_BIT (0X40) +#define SFP_PRESENT_PORT48_BIT (0X80) +#define SFP_PRESENT_PORT47_OFFSET (0X06) +#define SFP_PRESENT_PORT48_OFFSET (0X07) + + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + int start_port, end_port; + + if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| + (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)) + { + start_port = 47; + end_port = 48; + } + else /*reserved*/ + { + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + for(p = start_port; p <=end_port; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present,r_data; + + if((port==47)||(port==48)) + r_data=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG); + else{ + AIM_LOG_ERROR("The port %d is invalid \r\n", port); + return ONLP_STATUS_E_UNSUPPORTED; + } + + if(r_data<0){ + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if(port==47){ + r_data&=SFP_PRESENT_PORT47_BIT; + present=!(r_data>>SFP_PRESENT_PORT47_OFFSET); + } + else{ + r_data&=SFP_PRESENT_PORT48_BIT; + present=!(r_data>>SFP_PRESENT_PORT48_OFFSET); + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int status; + int port, i = 0; + uint64_t presence_all=0; + + AIM_BITMAP_CLR_ALL(dst); + + if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \ + (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){ + + port=47; + + } + else{ + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + status=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG); + + if(status<0){ + AIM_LOG_ERROR("Unable to read the sfp_is_present_all value. \r\n"); + return ONLP_STATUS_E_INTERNAL; + } + status=~status; + + status>>=6; + + /* Convert to 64 bit integer in port order */ + + presence_all = status & 0x3; + + presence_all <<= port; + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int status; + int port,i = 0; + uint64_t rx_los_all = 0; + + AIM_BITMAP_CLR_ALL(dst); + + if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \ + (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){ + + port=47; + + } + else{ + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + status=i2c_devname_read_byte("CPLD", SFP_RX_LOS_REG); + + if(status<0){ + AIM_LOG_ERROR("Unable to read the rx loss reg value. \r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + status>>=6; + + /* Convert to 64 bit integer in port order */ + rx_los_all = status & 0x3; + + rx_los_all <<= port; + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + + int i, r_data, re_cnt; + char* sfp_name; + + memset(data, 0, 256); + + if(port==47) + sfp_name="SFP1"; + else + sfp_name="SFP2"; + + + for(i=0;i<256;i++){ + re_cnt=3; + while(re_cnt){ + r_data=i2c_devname_read_byte(sfp_name,i); + if(r_data<0){ + re_cnt--; + continue; + } + data[i]=r_data; + break; + } + if(re_cnt==0){ + AIM_LOG_ERROR("Unable to read the %d reg \r\n",i); + return ONLP_STATUS_E_INTERNAL; + } + + } + + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + + return onlp_sfpi_eeprom_read( port, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + /*value is 1 if the tx disable + value is 0 if the tx enable + */ + + int rc,r_data,dis_value,present; + + present=onlp_sfpi_is_present(port); + + if(present==0){ + AIM_LOG_INFO("The port %d is not present and can not set tx disable\r\n",port); + return ONLP_STATUS_E_UNSUPPORTED; + } + + r_data=i2c_devname_read_byte("CPLD", SFP_TX_DISABLE_REG); + + if(r_data<0){ + AIM_LOG_INFO("Unable to read sfp tx disable reg value\r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + if(port==47){ + r_data&=~(0x1<>SFP_PRESENT_PORT47_OFFSET); + } + else{ + r_data&=(0x1<>SFP_PRESENT_PORT48_OFFSET); + } + + return ONLP_STATUS_OK; +} + + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c new file mode 100755 index 00000000..b8b0adec --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c @@ -0,0 +1,290 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_ag6248c_log.h" + +#include "platform_lib.h" +#include "arm_delta_i2c.h" +platform_id_t platform_id = PLATFORM_ID_UNKNOWN; + +#define ONIE_PLATFORM_NAME "arm-delta-ag6248c-r0" + +const char* +onlp_sysi_platform_get(void) +{ + enum ag6248c_product_id pid = get_product_id(); + + if (pid == PID_AG6248C_48) + return "arm-delta-ag6248c"; + else if(pid == PID_AG6248C_48P) + return "arm-delta-ag6248c-poe"; + else + return "unknow"; +} + +int +onlp_sysi_platform_set(const char* platform) +{ + if(strstr(platform,"arm-delta-ag6248c-r0")) { + platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_R0; + return ONLP_STATUS_OK; + } + if(strstr(platform,"arm-delta-ag6248c-poe-r0")) { + platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0; + return ONLP_STATUS_OK; + } + AIM_LOG_ERROR("No support for platform '%s'", platform); + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int v; + + v = i2c_devname_read_byte("CPLD", 0X07); + + pi->cpld_versions = aim_fstrdup("%d", v); + + return 0; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + int fd,rc_size; + char fullpath[20] = {0}; + + sprintf(fullpath, "/dev/mtd7"); + + fd=open(fullpath,O_RDWR); + + if(fd<0){ + aim_free(rdata); + return ONLP_STATUS_E_INTERNAL ; + } + + rc_size=read(fd,rdata,256); + + if(rc_size<0||rc_size!=256){ + aim_free(rdata); + return ONLP_STATUS_E_INTERNAL ; + } + + *data = rdata; + + return ONLP_STATUS_OK; + + +} + +void +onlp_sysi_onie_data_free(uint8_t* data) +{ + aim_free(data); +} + + + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 1 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* LEDs on the chassis */ + for (i = 1; i <= chassis_led_count(); i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 1 Fans on the chassis */ + for (i = 1; i <= chassis_fan_count(); i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_manage_fans(void) +{ + + int rc; + onlp_thermal_info_t ti1; + onlp_thermal_info_t ti2; + int mtemp=0; + int new_rpm=0; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* Get temperature */ + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + mtemp=(ti1.mcelsius+ti2.mcelsius)/2; + /* Bring fan speed according the temp + */ + if(mtemp<50000) + new_rpm=FAN_IDLE_RPM; + else if((mtemp>=55000)&&(mtemp<60000)) + new_rpm=FAN_LEVEL1_RPM; + else if((mtemp>=65000)&&(mtemp<70000)) + new_rpm=FAN_LEVEL2_RPM; + else if(mtemp>=75000) + new_rpm=FAN_LEVEL3_RPM; + else{ + return ONLP_STATUS_OK; + } + + onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); + onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); + + + return ONLP_STATUS_OK; +} + + +int +onlp_sysi_platform_manage_leds(void) +{ + int rc,rc1; + + onlp_fan_info_t info1,info2; + onlp_led_mode_t fan_new_mode; + onlp_thermal_info_t ti; + onlp_led_mode_t temp_new_mode; + onlp_psu_info_t psu1; + onlp_led_mode_t psu1_new_mode; + onlp_psu_info_t psu2; + onlp_led_mode_t psu2_new_mode; + onlp_led_mode_t sys_new_mode; + /*fan led */ + rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &info1); + + rc1=onlp_fani_info_get(ONLP_FAN_ID_CREATE(2), &info2); + + if ((rc != ONLP_STATUS_OK)||(rc1 != ONLP_STATUS_OK)){ + fan_new_mode=ONLP_LED_MODE_RED; + goto temp_led; + } + if(((info1.status&0x3)==1)&&((info2.status&0x3)==1)) + fan_new_mode=ONLP_LED_MODE_GREEN; + else + fan_new_mode=ONLP_LED_MODE_RED; + +temp_led: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode); + + /*temperature led */ + + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti); + if (rc != ONLP_STATUS_OK) { + temp_new_mode=ONLP_LED_MODE_OFF; + goto psu1_led; + } + if(ti.mcelsius >= 75000) + temp_new_mode=ONLP_LED_MODE_RED; + else + temp_new_mode=ONLP_LED_MODE_GREEN; + +psu1_led: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_TEMP),temp_new_mode); + + /*psu1 and psu2 led */ + rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(1),&psu1); + + if (rc != ONLP_STATUS_OK) { + psu1_new_mode=ONLP_LED_MODE_OFF; + goto psu2_led; + } + + if((psu1.status&0x1)&&!(psu1.status&0x2)) + psu1_new_mode=ONLP_LED_MODE_GREEN; + else + psu1_new_mode=ONLP_LED_MODE_OFF; +psu2_led: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1),psu1_new_mode); + //psu2 led ---------------- + rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(2),&psu2); + + if (rc != ONLP_STATUS_OK) { + psu2_new_mode=ONLP_LED_MODE_OFF; + goto sys_led; + } + + if((psu2.status&0x1)&&!(psu2.status&0x2)) + psu2_new_mode=ONLP_LED_MODE_GREEN; + else + psu2_new_mode=ONLP_LED_MODE_OFF; +sys_led : + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2),psu2_new_mode); + //sys led ---------------- + + if((fan_new_mode!=ONLP_LED_MODE_GREEN)||((psu2_new_mode!=ONLP_LED_MODE_GREEN)&& \ + (psu1_new_mode!=ONLP_LED_MODE_GREEN))) + sys_new_mode=ONLP_LED_MODE_RED_BLINKING; + else + sys_new_mode=ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode); + + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c new file mode 100755 index 00000000..8b02459f --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c @@ -0,0 +1,128 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_log.h" +#include +#define prefix_path "/sys/bus/i2c/devices/" +#define LOCAL_DEBUG 0 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_1_CLOSE_TO_MAC, + THERMAL_2_CLOSE_TO_PHY, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* last_path[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "0-0049/temp1_input", + "0-004a/temp1_input", + "4-0058/psu_temp1_input", + "5-0058/psu_temp1_input", +}; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_MAC), "Thermal Sensor 1- close to mac", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_CLOSE_TO_PHY), "Thermal Sensor 2- close to phy", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int len, nbytes = 10, temp_base=1, local_id; + uint8_t r_data[10] = {0}; + char fullpath[50] = {0}; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + /* get fullpath */ + sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]); + + onlp_file_read(r_data,nbytes,&len, fullpath); + + info->mcelsius =ONLPLIB_ATOI((char*)r_data) / temp_base; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/delta/armel/modules/Makefile b/packages/platforms/delta/armel/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/modules/PKG.yml b/packages/platforms/delta/armel/modules/PKG.yml new file mode 100644 index 00000000..e73b86da --- /dev/null +++ b/packages/platforms/delta/armel/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=armel VENDOR=delta From 7465185885524ff9d9801222be5c8994ed7f90a7 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 21 Nov 2017 07:49:03 -0800 Subject: [PATCH 076/244] Latest --- sm/bigcode | 2 +- sm/infra | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sm/bigcode b/sm/bigcode index 19a601e7..6a3c9705 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 19a601e7937fbb514d3abe466e4aacef02418b54 +Subproject commit 6a3c9705a418c419dbea2dc46c46fa2f00dcd6b2 diff --git a/sm/infra b/sm/infra index b4477ce7..98245bd9 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit b4477ce792024e069089c34aca6590be76a0ac4a +Subproject commit 98245bd9464448baf4eab74c869b7866e5d0367e From f4ff46fe0d3a894a7219f5aae7002f0b1fd6e292 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 22 Nov 2017 01:36:52 +0000 Subject: [PATCH 077/244] Latest --- sm/infra | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/infra b/sm/infra index 98245bd9..34c433a3 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 98245bd9464448baf4eab74c869b7866e5d0367e +Subproject commit 34c433a353012eddcfe596347f102f47ac72593f From de02d859faea4fb49ca53d04126041dd8e917dad Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Fri, 24 Nov 2017 11:28:46 +0800 Subject: [PATCH 078/244] [as5712-54x] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as5712-54x-sfp.c | 2316 +++++++++++++---- .../x86_64_accton_as5712_54x_r0/__init__.py | 15 +- 2 files changed, 1770 insertions(+), 561 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c index 1c2a93c1..8202b39e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c @@ -1,5 +1,5 @@ /* - * An hwmon driver for accton as5712_54x sfp + * SFP driver for accton as5712_54x sfp * * Copyright (C) Brandon Chuang * @@ -13,7 +13,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -30,41 +30,189 @@ #include #include #include +#include -#define NUM_OF_SFP_PORT 54 -#define BIT_INDEX(i) (1ULL << (i)) +#define DRIVER_NAME "as5712_54x_sfp" -#if 0 -static ssize_t show_status(struct device *dev, struct device_attribute *da,char *buf); -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); -static int as5712_54x_sfp_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) #endif -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; +#define NUM_OF_SFP_PORT 54 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ -/* Each client has this additional data +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8472_DIAG_MON_TYPE_ADDR 92 +#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. */ -struct as5712_54x_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u64 status[4]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => is_present - 1 => tx_fail - 2 => tx_disable - 3 => rx_loss */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL }; +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_rx_loss, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* SFP msa attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); +static struct attribute *sfp_msa_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + NULL +}; + +/* Platform dependent +++ */ /* The table maps active port to cpld port. * Array index 0 is for active port 1, * index 1 for active port 2, and so on. @@ -75,598 +223,1660 @@ static const u8 cpld_to_front_port_table[] = 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 52, 50, 53, 51, 54}; - #define CPLD_PORT_TO_FRONT_PORT(port) (cpld_to_front_port_table[port]) -static struct as5712_54x_sfp_data *as5712_54x_sfp_update_device(struct device *dev, int update_eeprom); -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum as5712_54x_sfp_sysfs_attributes { - SFP_IS_PRESENT, - SFP_TX_FAULT, - SFP_TX_DISABLE, - SFP_RX_LOSS, - SFP_PORT_NUMBER, - SFP_EEPROM, - SFP_RX_LOS_ALL, - SFP_IS_PRESENT_ALL, +enum port_numbers { +as5712_54x_port1, as5712_54x_port2, as5712_54x_port3, as5712_54x_port4, +as5712_54x_port5, as5712_54x_port6, as5712_54x_port7, as5712_54x_port8, +as5712_54x_port9, as5712_54x_port10, as5712_54x_port11, as5712_54x_port12, +as5712_54x_port13, as5712_54x_port14, as5712_54x_port15, as5712_54x_port16, +as5712_54x_port17, as5712_54x_port18, as5712_54x_port19, as5712_54x_port20, +as5712_54x_port21, as5712_54x_port22, as5712_54x_port23, as5712_54x_port24, +as5712_54x_port25, as5712_54x_port26, as5712_54x_port27, as5712_54x_port28, +as5712_54x_port29, as5712_54x_port30, as5712_54x_port31, as5712_54x_port32, +as5712_54x_port33, as5712_54x_port34, as5712_54x_port35, as5712_54x_port36, +as5712_54x_port37, as5712_54x_port38, as5712_54x_port39, as5712_54x_port40, +as5712_54x_port41, as5712_54x_port42, as5712_54x_port43, as5712_54x_port44, +as5712_54x_port45, as5712_54x_port46, as5712_54x_port47, as5712_54x_port48, +as5712_54x_port49, as5712_54x_port52, as5712_54x_port50, as5712_54x_port53, +as5712_54x_port51, as5712_54x_port54 }; -/* sysfs attributes for hwmon +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as5712_54x_port1), +I2C_DEV_ID(as5712_54x_port2), +I2C_DEV_ID(as5712_54x_port3), +I2C_DEV_ID(as5712_54x_port4), +I2C_DEV_ID(as5712_54x_port5), +I2C_DEV_ID(as5712_54x_port6), +I2C_DEV_ID(as5712_54x_port7), +I2C_DEV_ID(as5712_54x_port8), +I2C_DEV_ID(as5712_54x_port9), +I2C_DEV_ID(as5712_54x_port10), +I2C_DEV_ID(as5712_54x_port11), +I2C_DEV_ID(as5712_54x_port12), +I2C_DEV_ID(as5712_54x_port13), +I2C_DEV_ID(as5712_54x_port14), +I2C_DEV_ID(as5712_54x_port15), +I2C_DEV_ID(as5712_54x_port16), +I2C_DEV_ID(as5712_54x_port17), +I2C_DEV_ID(as5712_54x_port18), +I2C_DEV_ID(as5712_54x_port19), +I2C_DEV_ID(as5712_54x_port20), +I2C_DEV_ID(as5712_54x_port21), +I2C_DEV_ID(as5712_54x_port22), +I2C_DEV_ID(as5712_54x_port23), +I2C_DEV_ID(as5712_54x_port24), +I2C_DEV_ID(as5712_54x_port25), +I2C_DEV_ID(as5712_54x_port26), +I2C_DEV_ID(as5712_54x_port27), +I2C_DEV_ID(as5712_54x_port28), +I2C_DEV_ID(as5712_54x_port29), +I2C_DEV_ID(as5712_54x_port30), +I2C_DEV_ID(as5712_54x_port31), +I2C_DEV_ID(as5712_54x_port32), +I2C_DEV_ID(as5712_54x_port33), +I2C_DEV_ID(as5712_54x_port34), +I2C_DEV_ID(as5712_54x_port35), +I2C_DEV_ID(as5712_54x_port36), +I2C_DEV_ID(as5712_54x_port37), +I2C_DEV_ID(as5712_54x_port38), +I2C_DEV_ID(as5712_54x_port39), +I2C_DEV_ID(as5712_54x_port40), +I2C_DEV_ID(as5712_54x_port41), +I2C_DEV_ID(as5712_54x_port42), +I2C_DEV_ID(as5712_54x_port43), +I2C_DEV_ID(as5712_54x_port44), +I2C_DEV_ID(as5712_54x_port45), +I2C_DEV_ID(as5712_54x_port46), +I2C_DEV_ID(as5712_54x_port47), +I2C_DEV_ID(as5712_54x_port48), +I2C_DEV_ID(as5712_54x_port49), +I2C_DEV_ID(as5712_54x_port50), +I2C_DEV_ID(as5712_54x_port51), +I2C_DEV_ID(as5712_54x_port52), +I2C_DEV_ID(as5712_54x_port53), +I2C_DEV_ID(as5712_54x_port54), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data */ -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_status, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, show_status, NULL, SFP_TX_FAULT); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, show_status, set_tx_disable, SFP_TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_rx_loss, S_IRUGO, show_status,NULL, SFP_RX_LOSS); -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, show_status,NULL, SFP_RX_LOS_ALL); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_status,NULL, SFP_IS_PRESENT_ALL); - -static struct attribute *as5712_54x_sfp_attributes[] = { - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - NULL +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ }; -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_sfp_data *data = i2c_get_clientdata(client); +struct sfp_msa_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u64 status[6]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss + 3 => device id + 4 => 10G Ethernet Compliance Codes + to distinguish SFP or SFP+ + 5 => DIAGNOSTIC MONITORING TYPE */ + struct eeprom_data eeprom; +#if (MULTIPAGE_SUPPORT == 1) + struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ +#endif +}; - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct sfp_msa_data *msa; + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); } -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf) +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as5712_54x_sfp_data *data; - u8 val; - int values[7]; + int i = 0, j = 0, status = -1; + u8 reg; + unsigned short cpld_addr; + struct sfp_port_data *data = i2c_get_clientdata(client); - /* Error-check the CPLD read results. */ -#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ - do { \ - _rv = (_read_expr); \ - if(_rv < 0) { \ - return sprintf(_buf, "READ ERROR\n"); \ - } \ - if(_invert) { \ - _rv = ~_rv; \ - } \ - _rv &= 0xFF; \ - } while(0) + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + data->present = 0; - if(attr->index == SFP_RX_LOS_ALL) { - /* - * Report the RX_LOS status for all ports. - * This does not depend on the currently active SFP selector. - */ + /* Read present status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 3; j++) { + cpld_addr = 0x61+i; + reg = 0x6+j; + status = as5712_54x_i2c_cpld_read(cpld_addr, reg); - /* RX_LOS Ports 1-8 */ - VALIDATED_READ(buf, values[0], as5712_54x_i2c_cpld_read(0x61, 0x0F), 0); - /* RX_LOS Ports 9-16 */ - VALIDATED_READ(buf, values[1], as5712_54x_i2c_cpld_read(0x61, 0x10), 0); - /* RX_LOS Ports 17-24 */ - VALIDATED_READ(buf, values[2], as5712_54x_i2c_cpld_read(0x61, 0x11), 0); - /* RX_LOS Ports 25-32 */ - VALIDATED_READ(buf, values[3], as5712_54x_i2c_cpld_read(0x62, 0x0F), 0); - /* RX_LOS Ports 33-40 */ - VALIDATED_READ(buf, values[4], as5712_54x_i2c_cpld_read(0x62, 0x10), 0); - /* RX_LOS Ports 41-48 */ - VALIDATED_READ(buf, values[5], as5712_54x_i2c_cpld_read(0x62, 0x11), 0); + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } + DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); + data->present |= (u64)status << ((i*24) + (j%3)*8); + } + } - if(attr->index == SFP_IS_PRESENT_ALL) { - /* - * Report the SFP_PRESENCE status for all ports. - * This does not depend on the currently active SFP selector. - */ + /* Read present status of port 49-54(QSFP port) */ + cpld_addr = 0x62; + reg = 0x14; + status = as5712_54x_i2c_cpld_read(cpld_addr, reg); - /* SFP_PRESENT Ports 1-8 */ - VALIDATED_READ(buf, values[0], as5712_54x_i2c_cpld_read(0x61, 0x6), 1); - /* SFP_PRESENT Ports 9-16 */ - VALIDATED_READ(buf, values[1], as5712_54x_i2c_cpld_read(0x61, 0x7), 1); - /* SFP_PRESENT Ports 17-24 */ - VALIDATED_READ(buf, values[2], as5712_54x_i2c_cpld_read(0x61, 0x8), 1); - /* SFP_PRESENT Ports 25-32 */ - VALIDATED_READ(buf, values[3], as5712_54x_i2c_cpld_read(0x62, 0x6), 1); - /* SFP_PRESENT Ports 33-40 */ - VALIDATED_READ(buf, values[4], as5712_54x_i2c_cpld_read(0x62, 0x7), 1); - /* SFP_PRESENT Ports 41-48 */ - VALIDATED_READ(buf, values[5], as5712_54x_i2c_cpld_read(0x62, 0x8), 1); - /* QSFP_PRESENT Ports 49-54 */ - VALIDATED_READ(buf, values[6], as5712_54x_i2c_cpld_read(0x62, 0x14), 1); + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + else { + data->present |= (u64)status << 48; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0, j = 0; + int status = -1; + + if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { + return data; + } + + DEBUG_PRINT("Starting as5712_54x sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->msa->valid = 0; + memset(data->msa->status, 0, sizeof(data->msa->status)); + + /* Read status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 9; j++) { + u8 reg; + unsigned short cpld_addr; + reg = 0x9+j; + cpld_addr = 0x61+i; + + status = as5712_54x_i2c_cpld_read(cpld_addr, reg); + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + + data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); + } + } + + data->msa->valid = 1; + data->msa->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + unsigned short cpld_addr = 0; + u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; + long disable; + int error; + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_set_tx_disable(dev, da, buf, count); + } + + error = kstrtol(buf, 10, &disable); + if (error) { + return error; + } + + mutex_lock(&data->update_lock); + + if(data->port < 24) { + cpld_addr = 0x61; + cpld_reg = 0xC + data->port / 8; + cpld_bit = 1 << (data->port % 8); + } + else { /* port 24 ~ 48 */ + cpld_addr = 0x62; + cpld_reg = 0xC + (data->port - 24) / 8; + cpld_bit = 1 << (data->port % 8); + } + + /* Read current status */ + cpld_val = as5712_54x_i2c_cpld_read(cpld_addr, cpld_reg); + + /* Update tx_disable status */ + if (disable) { + data->msa->status[1] |= BIT_INDEX(data->port); + cpld_val |= cpld_bit; + } + else { + data->msa->status[1] &= ~BIT_INDEX(data->port); + cpld_val &= ~cpld_bit; + } + + as5712_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); + mutex_unlock(&data->update_lock); + return count; +} +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + int i; + u8 values[7] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } /* Return values 1 -> 54 in order */ return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", values[0], values[1], values[2], values[3], values[4], values[5], values[6] & 0x3F); - } - /* - * The remaining attributes are gathered on a per-selected-sfp basis. - */ - data = as5712_54x_sfp_update_device(dev, 0); - if (attr->index == SFP_IS_PRESENT) { - val = (data->status[attr->index] & BIT_INDEX(data->port)) ? 0 : 1; - } - else { - val = (data->status[attr->index] & BIT_INDEX(data->port)) ? 1 : 0; - } + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); - return sprintf(buf, "%d", val); + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; } -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +/* Platform dependent +++ */ +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 val = 0, index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_sfp_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; + struct sfp_port_data *data = i2c_get_clientdata(client); - /* Tx disable is not supported for QSFP ports(49-54) */ - if (data->port >= 48) { - return -EINVAL; - } + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_show_tx_rx_status(dev, da, buf); + } - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } + data = sfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } - mutex_lock(&data->update_lock); + if(attr->index == RX_LOS_ALL) { + int i = 0; + u8 values[6] = {0}; - if(data->port < 24) { - cpld_addr = 0x61; - cpld_reg = 0xC + data->port / 8; - cpld_bit = 1 << (data->port % 8); - } - else { - cpld_addr = 0x62; - cpld_reg = 0xC + (data->port - 24) / 8; - cpld_bit = 1 << (data->port % 8); - } + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = (u8)(data->msa->status[2] >> (i * 8)); + } + + /** Return values 1 -> 48 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5]); + } + + switch (attr->index) { + case TX_FAULT: + index = 0; + break; + case TX_DISABLE: + index = 1; + break; + case RX_LOS: + index = 2; + break; + default: + return 0; + } - cpld_val = as5712_54x_i2c_cpld_read(cpld_addr, cpld_reg); + val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; + return sprintf(buf, "%d", val); +} +/* Platform dependent --- */ - /* Update tx_disable status */ - if (disable) { - data->status[SFP_TX_DISABLE] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->status[SFP_TX_DISABLE] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; - as5712_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif - mutex_unlock(&data->update_lock); - return count; } -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, - char *buf) +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) { - struct as5712_54x_sfp_data *data = as5712_54x_sfp_update_device(dev, 1); + ssize_t retval = 0; - if (!data->valid) { - return 0; - } + if (unlikely(!count)) { + return count; + } - if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) != 0) { - return 0; - } + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); - memcpy(buf, data->eeprom, sizeof(data->eeprom)); + while (count) { + ssize_t status; - return sizeof(data->eeprom); + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif } -static const struct attribute_group as5712_54x_sfp_group = { - .attrs = as5712_54x_sfp_attributes, -}; - -static int as5712_54x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) { - struct as5712_54x_sfp_data *data; - int status; +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; - extern int platform_accton_as5712_54x(void); - if(!platform_accton_as5712_54x()) { - return -ENODEV; - } + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - status = -EIO; - goto exit; - } + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } - data = kzalloc(sizeof(struct as5712_54x_sfp_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } + break; + } - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5712_54x_sfp_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as5712_54x_sfp_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as5712_54x_sfp_remove(struct i2c_client *client) -{ - struct as5712_54x_sfp_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as5712_54x_sfp_group); - kfree(data); - - return 0; -} - -enum port_numbers { -as5712_54x_sfp1, as5712_54x_sfp2, as5712_54x_sfp3, as5712_54x_sfp4, -as5712_54x_sfp5, as5712_54x_sfp6, as5712_54x_sfp7, as5712_54x_sfp8, -as5712_54x_sfp9, as5712_54x_sfp10, as5712_54x_sfp11,as5712_54x_sfp12, -as5712_54x_sfp13, as5712_54x_sfp14, as5712_54x_sfp15,as5712_54x_sfp16, -as5712_54x_sfp17, as5712_54x_sfp18, as5712_54x_sfp19,as5712_54x_sfp20, -as5712_54x_sfp21, as5712_54x_sfp22, as5712_54x_sfp23,as5712_54x_sfp24, -as5712_54x_sfp25, as5712_54x_sfp26, as5712_54x_sfp27,as5712_54x_sfp28, -as5712_54x_sfp29, as5712_54x_sfp30, as5712_54x_sfp31,as5712_54x_sfp32, -as5712_54x_sfp33, as5712_54x_sfp34, as5712_54x_sfp35,as5712_54x_sfp36, -as5712_54x_sfp37, as5712_54x_sfp38, as5712_54x_sfp39,as5712_54x_sfp40, -as5712_54x_sfp41, as5712_54x_sfp42, as5712_54x_sfp43,as5712_54x_sfp44, -as5712_54x_sfp45, as5712_54x_sfp46, as5712_54x_sfp47,as5712_54x_sfp48, -as5712_54x_sfp49, as5712_54x_sfp52, as5712_54x_sfp50,as5712_54x_sfp53, -as5712_54x_sfp51, as5712_54x_sfp54 -}; - -static const struct i2c_device_id as5712_54x_sfp_id[] = { -{ "as5712_54x_sfp1", as5712_54x_sfp1 }, { "as5712_54x_sfp2", as5712_54x_sfp2 }, -{ "as5712_54x_sfp3", as5712_54x_sfp3 }, { "as5712_54x_sfp4", as5712_54x_sfp4 }, -{ "as5712_54x_sfp5", as5712_54x_sfp5 }, { "as5712_54x_sfp6", as5712_54x_sfp6 }, -{ "as5712_54x_sfp7", as5712_54x_sfp7 }, { "as5712_54x_sfp8", as5712_54x_sfp8 }, -{ "as5712_54x_sfp9", as5712_54x_sfp9 }, { "as5712_54x_sfp10", as5712_54x_sfp10 }, -{ "as5712_54x_sfp11", as5712_54x_sfp11 }, { "as5712_54x_sfp12", as5712_54x_sfp12 }, -{ "as5712_54x_sfp13", as5712_54x_sfp13 }, { "as5712_54x_sfp14", as5712_54x_sfp14 }, -{ "as5712_54x_sfp15", as5712_54x_sfp15 }, { "as5712_54x_sfp16", as5712_54x_sfp16 }, -{ "as5712_54x_sfp17", as5712_54x_sfp17 }, { "as5712_54x_sfp18", as5712_54x_sfp18 }, -{ "as5712_54x_sfp19", as5712_54x_sfp19 }, { "as5712_54x_sfp20", as5712_54x_sfp20 }, -{ "as5712_54x_sfp21", as5712_54x_sfp21 }, { "as5712_54x_sfp22", as5712_54x_sfp22 }, -{ "as5712_54x_sfp23", as5712_54x_sfp23 }, { "as5712_54x_sfp24", as5712_54x_sfp24 }, -{ "as5712_54x_sfp25", as5712_54x_sfp25 }, { "as5712_54x_sfp26", as5712_54x_sfp26 }, -{ "as5712_54x_sfp27", as5712_54x_sfp27 }, { "as5712_54x_sfp28", as5712_54x_sfp28 }, -{ "as5712_54x_sfp29", as5712_54x_sfp29 }, { "as5712_54x_sfp30", as5712_54x_sfp30 }, -{ "as5712_54x_sfp31", as5712_54x_sfp31 }, { "as5712_54x_sfp32", as5712_54x_sfp32 }, -{ "as5712_54x_sfp33", as5712_54x_sfp33 }, { "as5712_54x_sfp34", as5712_54x_sfp34 }, -{ "as5712_54x_sfp35", as5712_54x_sfp35 }, { "as5712_54x_sfp36", as5712_54x_sfp36 }, -{ "as5712_54x_sfp37", as5712_54x_sfp37 }, { "as5712_54x_sfp38", as5712_54x_sfp38 }, -{ "as5712_54x_sfp39", as5712_54x_sfp39 }, { "as5712_54x_sfp40", as5712_54x_sfp40 }, -{ "as5712_54x_sfp41", as5712_54x_sfp41 }, { "as5712_54x_sfp42", as5712_54x_sfp42 }, -{ "as5712_54x_sfp43", as5712_54x_sfp43 }, { "as5712_54x_sfp44", as5712_54x_sfp44 }, -{ "as5712_54x_sfp45", as5712_54x_sfp45 }, { "as5712_54x_sfp46", as5712_54x_sfp46 }, -{ "as5712_54x_sfp47", as5712_54x_sfp47 }, { "as5712_54x_sfp48", as5712_54x_sfp48 }, -{ "as5712_54x_sfp49", as5712_54x_sfp49 }, { "as5712_54x_sfp50", as5712_54x_sfp50 }, -{ "as5712_54x_sfp51", as5712_54x_sfp51 }, { "as5712_54x_sfp52", as5712_54x_sfp52 }, -{ "as5712_54x_sfp53", as5712_54x_sfp53 }, { "as5712_54x_sfp54", as5712_54x_sfp54 }, - -{} -}; -MODULE_DEVICE_TABLE(i2c, as5712_54x_sfp_id); - -static struct i2c_driver as5712_54x_sfp_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as5712_54x_sfp", - }, - .probe = as5712_54x_sfp_probe, - .remove = as5712_54x_sfp_remove, - .id_table = as5712_54x_sfp_id, - .address_list = normal_i2c, -}; - -static int as5712_54x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data) -{ - int result = i2c_smbus_read_byte_data(client, command); - - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } - - *data = (u8)result; - result = 0; + //result = data_len; abort: - return result; + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif } -#define ALWAYS_UPDATE_DEVICE 1 - -static struct as5712_54x_sfp_data *as5712_54x_sfp_update_device(struct device *dev, int update_eeprom) +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) { - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_sfp_data *data = i2c_get_clientdata(client); + unsigned page = 0; - mutex_lock(&data->update_lock); + *client = port_data->client; - if (ALWAYS_UPDATE_DEVICE || time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status = -1; - int i = 0, j = 0; + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = port_data->msa->ddm_client; + *offset -= 256; + } + } - data->valid = 0; - //dev_dbg(&client->dev, "Starting as5712_54x sfp status update\n"); - memset(data->status, 0, sizeof(data->status)); + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 12; j++) { - status = as5712_54x_i2c_cpld_read(0x61+i, 0x6+j); + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - goto exit; - } - - data->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* - * Bring QSFPs out of reset, - * This is a temporary fix until the QSFP+_MOD_RST register - * can be exposed through the driver. - */ - as5712_54x_i2c_cpld_write(0x62, 0x15, 0x3F); - - /* Read present status of port 49-54(QSFP port) */ - status = as5712_54x_i2c_cpld_read(0x62, 0x14); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - } - else { - data->status[SFP_IS_PRESENT] |= (u64)status << 48; - } - - if (update_eeprom) { - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) == 0) { - /* read eeprom */ - for (i = 0; i < sizeof(data->eeprom); i++) { - status = as5712_54x_sfp_read_byte(client, i, data->eeprom + i); - - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", - CPLD_PORT_TO_FRONT_PORT(data->port)); - goto exit; - } - } - } - } - - data->valid = 1; - data->last_updated = jiffies; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; + return page; /* note also returning client and offset */ } -module_i2c_driver(as5712_54x_sfp_driver); +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + if ((off + len) <= 256) return len; + /* if no pages needed, we're good */ + //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + + /* Check if ddm is supported */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF8472_DIAG_MON_TYPE_ADDR, 1); + if (status < 0) return status; /* error out (no module?) */ + if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { + if (off >= 256) return -EINVAL; + maxlen = 256 - off; + } + else { + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; + +static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_msa_data **data) +{ + int status; + struct sfp_msa_data *msa; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); + if (!msa) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + +#if (MULTIPAGE_SUPPORT == 1) + msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); + if (!msa->ddm_client) { + dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); + status = -EADDRINUSE; + goto exit_eeprom; + } +#endif + + *data = msa; + dev_info(&client->dev, "sfp msa '%s'\n", client->name); + + return 0; + +exit_eeprom: + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); +exit_free: + kfree(msa); +exit: + + return status; +} + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + /* Bring QSFPs out of reset */ + as5712_54x_i2c_cpld_write(0x62, 0x15, 0x3F); + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as5712_54x_port1 || dev_id->driver_data > as5712_54x_port54) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + + if (dev_id->driver_data >= as5712_54x_port1 && dev_id->driver_data <= as5712_54x_port48) { + data->driver_type = DRIVER_TYPE_SFP_MSA; + ret = sfp_msa_probe(client, dev_id, &data->msa); + } + else { /* as5712_54x_portsfp49 ~ as5712_54x_portsfp54 */ + data->driver_type = DRIVER_TYPE_QSFP; + ret = qsfp_probe(client, dev_id, &data->qsfp); + } + + if (ret < 0) { + goto exit_kfree_buf; + } + + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); +#if (MULTIPAGE_SUPPORT == 1) + i2c_unregister_device(data->ddm_client); +#endif + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); + kfree(data); + return 0; +} + +static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + return sfp_msa_remove(client, data->msa); + case DRIVER_TYPE_QSFP: + return qfp_remove(client, data->qsfp); + } + +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) + kfree(data->writebuf); +#endif + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5712_54x_sfp driver"); MODULE_LICENSE("GPL"); -#if 0 - int i = 0, j = 0; +module_init(sfp_init); +module_exit(sfp_exit); - data->valid = 0; - //dev_dbg(&client->dev, "Starting as5712_54x sfp update\n"); - memset(data->status, 0, sizeof(data->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 12; j++) { - status = as5712_54x_i2c_cpld_read(0x61+i, 0x6+j); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - continue; - } - - data->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-54(QSFP port) */ - status = as5712_54x_i2c_cpld_read(0x62, 0x14); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - } - else { - data->status[SFP_IS_PRESENT] |= (u64)status << 48; - } -#endif - -/* Reserver to prevent from CPLD port mapping is changed - */ -#if 0 -BIT_INDEX(port_present_index[data->port]) -/* The bit index of is_present field read from CPLD - * Array index 0 is for as5712_54x_sfp1, - * index 1 is for as5712_54x_sfp2, and so on. - */ -static const int port_present_index[] = { - 4, 5, 6, 7, 9, 8, 11, 10, - 0, 1, 2, 3, 12, 13, 14, 15, -16, 17, 18, 19, 28, 29, 30, 31, -20, 21, 22, 23, 24, 25, 26, 27 -}; -#endif - -#if 0 -static struct as5712_54x_sfp_data *as5712_54x_sfp_update_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_sfp_data *data = i2c_get_clientdata(client); - int status = -1; - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->status_last_updated + HZ + HZ / 2) - || !data->status_valid) { - int status = -1; - int i = 0, j = 0; - - data->status_valid = 0; - //dev_dbg(&client->dev, "Starting as5712_54x sfp status update\n"); - memset(data->status, 0, sizeof(data->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 12; j++) { - status = as5712_54x_i2c_cpld_read(0x61+i, 0x6+j); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - goto exit; - } - - data->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* - * Bring QSFPs out of reset, - * This is a temporary fix until the QSFP+_MOD_RST register - * can be exposed through the driver. - */ - as5712_54x_i2c_cpld_write(0x62, 0x15, 0x3F); - - /* Read present status of port 49-54(QSFP port) */ - status = as5712_54x_i2c_cpld_read(0x62, 0x14); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - } - else { - data->status[SFP_IS_PRESENT] |= (u64)status << 48; - } - - data->status_valid = 1; - data->status_last_updated = jiffies; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} - -static struct as5712_54x_sfp_data *as5712_54x_sfp_update_eeprom(struct device *dev) -{ - struct as5712_54x_sfp_data *data = NULL; - - data = as5712_54x_sfp_update_status(dev); - - if (data == NULL || data->status_valid == 0) { - data->eeprom_valid = 0; - return data; - } - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->eeprom_last_updated + HZ + HZ / 2) - || !data->eeprom_valid) { - int status = -1; - int i = 0; - - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) == 0) { - /* read eeprom */ - for (i = 0; i < sizeof(data->eeprom)/I2C_SMBUS_BLOCK_MAX; i++) { - status = as5712_54x_sfp_read_block(client, i*I2C_SMBUS_BLOCK_MAX, - data->eeprom+(i*I2C_SMBUS_BLOCK_MAX), - I2C_SMBUS_BLOCK_MAX); - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", - CPLD_PORT_TO_FRONT_PORT(data->port)); - goto exit; - } - } - } - - data->eeprom_last_updated = jiffies; - data->eeprom_valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} -#endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py index 3b32120d..810419ce 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py @@ -25,16 +25,15 @@ class OnlPlatform_x86_64_accton_as5712_54x_r0(OnlPlatformAccton, ) # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5712_54x_sfp%d' % port, 0x50, port+1) - self.new_i2c_device('as5712_54x_sfp%d' % port, 0x51, port+1) + self.new_i2c_device('as5712_54x_port%d' % port, 0x50, port+1) # Initialize QSFP devices - self.new_i2c_device('as5712_54x_sfp49', 0x50, 50) - self.new_i2c_device('as5712_54x_sfp52', 0x50, 51) - self.new_i2c_device('as5712_54x_sfp50', 0x50, 52) - self.new_i2c_device('as5712_54x_sfp53', 0x50, 53) - self.new_i2c_device('as5712_54x_sfp51', 0x50, 54) - self.new_i2c_device('as5712_54x_sfp54', 0x50, 55) + self.new_i2c_device('as5712_54x_port49', 0x50, 50) + self.new_i2c_device('as5712_54x_port52', 0x50, 51) + self.new_i2c_device('as5712_54x_port50', 0x50, 52) + self.new_i2c_device('as5712_54x_port53', 0x50, 53) + self.new_i2c_device('as5712_54x_port51', 0x50, 54) + self.new_i2c_device('as5712_54x_port54', 0x50, 55) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From e25ce95ec520510c4bee1a15aa5aada2794251f7 Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Fri, 24 Nov 2017 11:35:50 +0800 Subject: [PATCH 079/244] [as5912-54x] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as5912-54x-sfp.c | 1091 +++++++++++++---- .../x86_64_accton_as5912_54x_r0/__init__.py | 5 +- 2 files changed, 827 insertions(+), 269 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c index 59eb9304..2416142f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c @@ -48,11 +48,10 @@ #define EEPROM_SIZE 256 /* 256 byte eeprom */ #define BIT_INDEX(i) (1ULL << (i)) #define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) #define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 #define SFF8024_DEVICE_ID_SFP 0x3 @@ -62,26 +61,78 @@ #define SFF8472_DIAG_MON_TYPE_ADDR 92 #define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - #define SFF8436_RX_LOS_ADDR 3 #define SFF8436_TX_FAULT_ADDR 4 #define SFF8436_TX_DISABLE_ADDR 86 +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + + /* Platform dependent +++ */ #define I2C_ADDR_CPLD1 0x60 #define I2C_ADDR_CPLD2 0x62 /* Platform dependent --- */ static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); @@ -113,7 +164,6 @@ enum sfp_sysfs_attributes { /* SFP/QSFP common attributes for sysfs */ static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); @@ -135,7 +185,6 @@ static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); static struct attribute *qsfp_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, &sensor_dev_attr_sfp_rx_los.dev_attr.attr, @@ -157,14 +206,11 @@ static struct attribute *qsfp_attributes[] = { }; /* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); static struct attribute *sfp_msa_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, &sensor_dev_attr_sfp_rx_los.dev_attr.attr, &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, @@ -172,62 +218,90 @@ static struct attribute *sfp_msa_attributes[] = { NULL }; -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - /* Platform dependent +++ */ #define CPLD_PORT_TO_FRONT_PORT(port) (port+1) enum port_numbers { -as5912_54x_sfp1, as5912_54x_sfp2, as5912_54x_sfp3, as5912_54x_sfp4, as5912_54x_sfp5, as5912_54x_sfp6, as5912_54x_sfp7, as5912_54x_sfp8, -as5912_54x_sfp9, as5912_54x_sfp10, as5912_54x_sfp11, as5912_54x_sfp12, as5912_54x_sfp13, as5912_54x_sfp14, as5912_54x_sfp15, as5912_54x_sfp16, -as5912_54x_sfp17, as5912_54x_sfp18, as5912_54x_sfp19, as5912_54x_sfp20, as5912_54x_sfp21, as5912_54x_sfp22, as5912_54x_sfp23, as5912_54x_sfp24, -as5912_54x_sfp25, as5912_54x_sfp26, as5912_54x_sfp27, as5912_54x_sfp28, as5912_54x_sfp29, as5912_54x_sfp30, as5912_54x_sfp31, as5912_54x_sfp32, -as5912_54x_sfp33, as5912_54x_sfp34, as5912_54x_sfp35, as5912_54x_sfp36, as5912_54x_sfp37, as5912_54x_sfp38, as5912_54x_sfp39, as5912_54x_sfp40, -as5912_54x_sfp41, as5912_54x_sfp42, as5912_54x_sfp43, as5912_54x_sfp44, as5912_54x_sfp45, as5912_54x_sfp46, as5912_54x_sfp47, as5912_54x_sfp48, -as5912_54x_sfp49, as5912_54x_sfp50, as5912_54x_sfp51, as5912_54x_sfp52, as5912_54x_sfp53, as5912_54x_sfp54 +as5912_54x_port1, as5912_54x_port2, as5912_54x_port3, as5912_54x_port4, +as5912_54x_port5, as5912_54x_port6, as5912_54x_port7, as5912_54x_port8, +as5912_54x_port9, as5912_54x_port10, as5912_54x_port11, as5912_54x_port12, +as5912_54x_port13, as5912_54x_port14, as5912_54x_port15, as5912_54x_port16, +as5912_54x_port17, as5912_54x_port18, as5912_54x_port19, as5912_54x_port20, +as5912_54x_port21, as5912_54x_port22, as5912_54x_port23, as5912_54x_port24, +as5912_54x_port25, as5912_54x_port26, as5912_54x_port27, as5912_54x_port28, +as5912_54x_port29, as5912_54x_port30, as5912_54x_port31, as5912_54x_port32, +as5912_54x_port33, as5912_54x_port34, as5912_54x_port35, as5912_54x_port36, +as5912_54x_port37, as5912_54x_port38, as5912_54x_port39, as5912_54x_port40, +as5912_54x_port41, as5912_54x_port42, as5912_54x_port43, as5912_54x_port44, +as5912_54x_port45, as5912_54x_port46, as5912_54x_port47, as5912_54x_port48, +as5912_54x_port49, as5912_54x_port52, as5912_54x_port50, as5912_54x_port53, +as5912_54x_port51, as5912_54x_port54 }; +#define I2C_DEV_ID(x) { #x, x} + static const struct i2c_device_id sfp_device_id[] = { -{ "as5912_54x_sfp1", as5912_54x_sfp1 }, { "as5912_54x_sfp2", as5912_54x_sfp2 }, { "as5912_54x_sfp3", as5912_54x_sfp3 }, { "as5912_54x_sfp4", as5912_54x_sfp4 }, -{ "as5912_54x_sfp5", as5912_54x_sfp5 }, { "as5912_54x_sfp6", as5912_54x_sfp6 }, { "as5912_54x_sfp7", as5912_54x_sfp7 }, { "as5912_54x_sfp8", as5912_54x_sfp8 }, -{ "as5912_54x_sfp9", as5912_54x_sfp9 }, { "as5912_54x_sfp10", as5912_54x_sfp10 }, { "as5912_54x_sfp11", as5912_54x_sfp11 }, { "as5912_54x_sfp12", as5912_54x_sfp12 }, -{ "as5912_54x_sfp13", as5912_54x_sfp13 }, { "as5912_54x_sfp14", as5912_54x_sfp14 }, { "as5912_54x_sfp15", as5912_54x_sfp15 }, { "as5912_54x_sfp16", as5912_54x_sfp16 }, -{ "as5912_54x_sfp17", as5912_54x_sfp17 }, { "as5912_54x_sfp18", as5912_54x_sfp18 }, { "as5912_54x_sfp19", as5912_54x_sfp19 }, { "as5912_54x_sfp20", as5912_54x_sfp20 }, -{ "as5912_54x_sfp21", as5912_54x_sfp21 }, { "as5912_54x_sfp22", as5912_54x_sfp22 }, { "as5912_54x_sfp23", as5912_54x_sfp23 }, { "as5912_54x_sfp24", as5912_54x_sfp24 }, -{ "as5912_54x_sfp25", as5912_54x_sfp25 }, { "as5912_54x_sfp26", as5912_54x_sfp26 }, { "as5912_54x_sfp27", as5912_54x_sfp27 }, { "as5912_54x_sfp28", as5912_54x_sfp28 }, -{ "as5912_54x_sfp29", as5912_54x_sfp29 }, { "as5912_54x_sfp30", as5912_54x_sfp30 }, { "as5912_54x_sfp31", as5912_54x_sfp31 }, { "as5912_54x_sfp32", as5912_54x_sfp32 }, -{ "as5912_54x_sfp33", as5912_54x_sfp33 }, { "as5912_54x_sfp34", as5912_54x_sfp34 }, { "as5912_54x_sfp35", as5912_54x_sfp35 }, { "as5912_54x_sfp36", as5912_54x_sfp36 }, -{ "as5912_54x_sfp37", as5912_54x_sfp37 }, { "as5912_54x_sfp38", as5912_54x_sfp38 }, { "as5912_54x_sfp39", as5912_54x_sfp39 }, { "as5912_54x_sfp40", as5912_54x_sfp40 }, -{ "as5912_54x_sfp41", as5912_54x_sfp41 }, { "as5912_54x_sfp42", as5912_54x_sfp42 }, { "as5912_54x_sfp43", as5912_54x_sfp43 }, { "as5912_54x_sfp44", as5912_54x_sfp44 }, -{ "as5912_54x_sfp45", as5912_54x_sfp45 }, { "as5912_54x_sfp46", as5912_54x_sfp46 }, { "as5912_54x_sfp47", as5912_54x_sfp47 }, { "as5912_54x_sfp48", as5912_54x_sfp48 }, -{ "as5912_54x_sfp49", as5912_54x_sfp49 }, { "as5912_54x_sfp50", as5912_54x_sfp50 }, { "as5912_54x_sfp51", as5912_54x_sfp51 }, { "as5912_54x_sfp52", as5912_54x_sfp52 }, -{ "as5912_54x_sfp53", as5912_54x_sfp53 }, { "as5912_54x_sfp54", as5912_54x_sfp54 }, +I2C_DEV_ID(as5912_54x_port1), +I2C_DEV_ID(as5912_54x_port2), +I2C_DEV_ID(as5912_54x_port3), +I2C_DEV_ID(as5912_54x_port4), +I2C_DEV_ID(as5912_54x_port5), +I2C_DEV_ID(as5912_54x_port6), +I2C_DEV_ID(as5912_54x_port7), +I2C_DEV_ID(as5912_54x_port8), +I2C_DEV_ID(as5912_54x_port9), +I2C_DEV_ID(as5912_54x_port10), +I2C_DEV_ID(as5912_54x_port11), +I2C_DEV_ID(as5912_54x_port12), +I2C_DEV_ID(as5912_54x_port13), +I2C_DEV_ID(as5912_54x_port14), +I2C_DEV_ID(as5912_54x_port15), +I2C_DEV_ID(as5912_54x_port16), +I2C_DEV_ID(as5912_54x_port17), +I2C_DEV_ID(as5912_54x_port18), +I2C_DEV_ID(as5912_54x_port19), +I2C_DEV_ID(as5912_54x_port20), +I2C_DEV_ID(as5912_54x_port21), +I2C_DEV_ID(as5912_54x_port22), +I2C_DEV_ID(as5912_54x_port23), +I2C_DEV_ID(as5912_54x_port24), +I2C_DEV_ID(as5912_54x_port25), +I2C_DEV_ID(as5912_54x_port26), +I2C_DEV_ID(as5912_54x_port27), +I2C_DEV_ID(as5912_54x_port28), +I2C_DEV_ID(as5912_54x_port29), +I2C_DEV_ID(as5912_54x_port30), +I2C_DEV_ID(as5912_54x_port31), +I2C_DEV_ID(as5912_54x_port32), +I2C_DEV_ID(as5912_54x_port33), +I2C_DEV_ID(as5912_54x_port34), +I2C_DEV_ID(as5912_54x_port35), +I2C_DEV_ID(as5912_54x_port36), +I2C_DEV_ID(as5912_54x_port37), +I2C_DEV_ID(as5912_54x_port38), +I2C_DEV_ID(as5912_54x_port39), +I2C_DEV_ID(as5912_54x_port40), +I2C_DEV_ID(as5912_54x_port41), +I2C_DEV_ID(as5912_54x_port42), +I2C_DEV_ID(as5912_54x_port43), +I2C_DEV_ID(as5912_54x_port44), +I2C_DEV_ID(as5912_54x_port45), +I2C_DEV_ID(as5912_54x_port46), +I2C_DEV_ID(as5912_54x_port47), +I2C_DEV_ID(as5912_54x_port48), +I2C_DEV_ID(as5912_54x_port49), +I2C_DEV_ID(as5912_54x_port50), +I2C_DEV_ID(as5912_54x_port51), +I2C_DEV_ID(as5912_54x_port52), +I2C_DEV_ID(as5912_54x_port53), +I2C_DEV_ID(as5912_54x_port54), { /* LIST END */ } }; MODULE_DEVICE_TABLE(i2c, sfp_device_id); /* Platform dependent --- */ -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - enum driver_type_e { DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, DRIVER_TYPE_QSFP }; @@ -250,11 +324,10 @@ struct sfp_msa_data { 4 => 10G Ethernet Compliance Codes to distinguish SFP or SFP+ 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; + struct eeprom_data eeprom; +#if (MULTIPAGE_SUPPORT == 1) + struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ +#endif }; struct qsfp_data { @@ -273,16 +346,23 @@ struct sfp_port_data { struct mutex update_lock; enum driver_type_e driver_type; int port; /* CPLD port index */ - oom_driver_port_type_t port_type; u64 present; /* present status, bit0:port0, bit1:port1 and so on */ struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; struct qsfp_data *qsfp; struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif }; +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf) { @@ -339,7 +419,7 @@ exit: return (status < 0) ? ERR_PTR(status) : data; } -static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) +static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct sfp_port_data *data = i2c_get_clientdata(client); @@ -376,7 +456,7 @@ static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) exit: mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; + return (status < 0) ? ERR_PTR(status) : data; } static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, @@ -429,6 +509,7 @@ static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *d mutex_unlock(&data->update_lock); return count; } +/* Platform dependent --- */ static int sfp_is_port_present(struct i2c_client *client, int port) { @@ -439,9 +520,10 @@ static int sfp_is_port_present(struct i2c_client *client, int port) return PTR_ERR(data); } - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ } +/* Platform dependent +++ */ static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf) { @@ -481,92 +563,6 @@ static ssize_t show_present(struct device *dev, struct device_attribute *da, } /* Platform dependent --- */ -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -703,7 +699,12 @@ static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute * mutex_lock(&data->update_lock); if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } } else {/* TX_DISABLE1 ~ TX_DISABLE4*/ if (disable) { @@ -724,40 +725,14 @@ static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute * return count; } -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - /* Platform dependent +++ */ static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf) { u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); if (data->driver_type == DRIVER_TYPE_QSFP) { return qsfp_show_tx_rx_status(dev, da, buf); @@ -791,15 +766,16 @@ static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute break; case RX_LOS: index = 2; - break; + break; default: return 0; } - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); + val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; return sprintf(buf, "%d\n", val); } /* Platform dependent --- */ + static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, int data_len) { @@ -850,6 +826,7 @@ static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const cha } +#if (MULTIPAGE_SUPPORT == 0) static ssize_t sfp_port_write(struct sfp_port_data *data, const char *buf, loff_t off, size_t count) { @@ -884,7 +861,7 @@ static ssize_t sfp_port_write(struct sfp_port_data *data, mutex_unlock(&data->update_lock); return retval; } - +#endif static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -905,7 +882,11 @@ static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, return -ENODEV; } +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else return sfp_port_write(data, buf, off, count); +#endif } static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, @@ -968,6 +949,518 @@ abort: #endif } +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = port_data->msa->ddm_client; + *offset -= 256; + } + } + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + if ((off + len) <= 256) return len; + /* if no pages needed, we're good */ + //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + + /* Check if ddm is supported */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF8472_DIAG_MON_TYPE_ADDR, 1); + if (status < 0) return status; /* error out (no module?) */ + if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { + if (off >= 256) return -EINVAL; + maxlen = 256 - off; + } + else { + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else static ssize_t sfp_port_read(struct sfp_port_data *data, char *buf, loff_t off, size_t count) { @@ -1005,6 +1498,7 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, return retval; } +#endif static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -1013,8 +1507,8 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, int present; struct sfp_port_data *data; DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); if (IS_ERR_VALUE(present)) { return present; @@ -1025,10 +1519,18 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, return -ENODEV; } +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else return sfp_port_read(data, buf, off, count); +#endif } +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif { int err; @@ -1037,7 +1539,11 @@ static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eep eeprom->attr.mode = S_IWUSR | S_IRUGO; eeprom->read = sfp_bin_read; eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else eeprom->size = EEPROM_SIZE; +#endif /* Create eeprom file */ err = sysfs_create_bin_file(kobj, eeprom); @@ -1054,10 +1560,8 @@ static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute * return 0; } -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; +#if (MULTIPAGE_SUPPORT == 0) static int sfp_i2c_check_functionality(struct i2c_client *client) { #if USE_I2C_BLOCK_READ @@ -1066,18 +1570,25 @@ static int sfp_i2c_check_functionality(struct i2c_client *client) return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); #endif } +#endif + +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, struct sfp_msa_data **data) { int status; struct sfp_msa_data *msa; - + +#if (MULTIPAGE_SUPPORT == 0) if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } - +#endif + msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); if (!msa) { status = -ENOMEM; @@ -1091,16 +1602,31 @@ static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id * } /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); +#endif if (status) { goto exit_remove; } +#if (MULTIPAGE_SUPPORT == 1) + msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); + if (!msa->ddm_client) { + dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); + status = -EADDRINUSE; + goto exit_eeprom; + } +#endif + *data = msa; dev_info(&client->dev, "sfp msa '%s'\n", client->name); return 0; +exit_eeprom: + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); exit_remove: sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); exit_free: @@ -1110,53 +1636,6 @@ exit: return status; } -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - static const struct attribute_group qsfp_group = { .attrs = qsfp_attributes, }; @@ -1167,10 +1646,12 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev int status; struct qsfp_data *qsfp; +#if (MULTIPAGE_SUPPORT == 0) if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } +#endif qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); if (!qsfp) { @@ -1185,7 +1666,11 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev } /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif if (status) { goto exit_remove; } @@ -1208,51 +1693,122 @@ exit: static int sfp_device_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { + int ret = 0; struct sfp_port_data *data = NULL; + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as5912_54x_port1 || dev_id->driver_data > as5912_54x_port54) { + return -ENXIO; + } + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); if (!data) { return -ENOMEM; } +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + i2c_set_clientdata(client, data); mutex_init(&data->update_lock); data->port = dev_id->driver_data; data->client = client; - if (dev_id->driver_data >= as5912_54x_sfp1 && dev_id->driver_data <= as5912_54x_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } + if (dev_id->driver_data >= as5912_54x_port1 && dev_id->driver_data <= as5912_54x_port48) { + data->driver_type = DRIVER_TYPE_SFP_MSA; + ret = sfp_msa_probe(client, dev_id, &data->msa); } - else { /* as5912_54x_sfp49 ~ as5912_54x_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } + else { /* as5912_54x_portsfp49 ~ as5912_54x_portsfp54 */ + data->driver_type = DRIVER_TYPE_QSFP; + ret = qsfp_probe(client, dev_id, &data->qsfp); + } + + if (ret < 0) { + goto exit_kfree_buf; } - return -ENODEV; + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; } /* Platform dependent --- */ static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) { sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); +#if (MULTIPAGE_SUPPORT == 1) + i2c_unregister_device(data->ddm_client); +#endif + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); kfree(data); return 0; } @@ -1267,18 +1823,22 @@ static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) static int sfp_device_remove(struct i2c_client *client) { + int ret = 0; struct sfp_port_data *data = i2c_get_clientdata(client); switch (data->driver_type) { case DRIVER_TYPE_SFP_MSA: return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); case DRIVER_TYPE_QSFP: return qfp_remove(client, data->qsfp); - } + } - return 0; +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) + kfree(data->writebuf); +#endif + kfree(data); + return ret; } /* Addresses scanned @@ -1309,7 +1869,6 @@ MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5912_54x_sfp driver"); MODULE_LICENSE("GPL"); -late_initcall(sfp_init); +module_init(sfp_init); module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py index 723c6234..6ba3a28b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py @@ -69,12 +69,11 @@ class OnlPlatform_x86_64_accton_as5912_54x_r0(OnlPlatformAccton, # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5912_54x_sfp%d' % port, 0x50, port+25) - self.new_i2c_device('as5912_54x_sfp%d' % port, 0x51, port+25) + self.new_i2c_device('as5912_54x_port%d' % port, 0x50, port+25) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5912_54x_sfp%d' % port, 0x50, port+25) + self.new_i2c_device('as5912_54x_port%d' % port, 0x50, port+25) return True From 7828b91eb4380994e930cc1585378be76f42ca6d Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Fri, 24 Nov 2017 13:50:00 +0800 Subject: [PATCH 080/244] [as7312-54x] Support multi-page reading of the eeprom for OOM --- .../builds/x86-64-accton-as7312-54x-sfp.c | 1206 ++++++++++++----- .../x86_64_accton_as7312_54x_r0/__init__.py | 108 +- 2 files changed, 922 insertions(+), 392 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c index 3cdb23f7..89591201 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c @@ -48,11 +48,10 @@ #define EEPROM_SIZE 256 /* 256 byte eeprom */ #define BIT_INDEX(i) (1ULL << (i)) #define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) #define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 #define SFF8024_DEVICE_ID_SFP 0x3 @@ -62,26 +61,77 @@ #define SFF8472_DIAG_MON_TYPE_ADDR 92 #define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - #define SFF8436_RX_LOS_ADDR 3 #define SFF8436_TX_FAULT_ADDR 4 #define SFF8436_TX_DISABLE_ADDR 86 +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + /* Platform dependent +++ */ #define I2C_ADDR_CPLD1 0x60 #define I2C_ADDR_CPLD2 0x62 #define I2C_ADDR_CPLD3 0x64 /* Platform dependent --- */ static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); extern int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); @@ -112,7 +162,6 @@ enum sfp_sysfs_attributes { /* SFP/QSFP common attributes for sysfs */ static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); @@ -134,7 +183,6 @@ static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); static struct attribute *qsfp_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, &sensor_dev_attr_sfp_rx_los.dev_attr.attr, @@ -156,14 +204,11 @@ static struct attribute *qsfp_attributes[] = { }; /* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); static struct attribute *sfp_msa_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, &sensor_dev_attr_sfp_rx_los.dev_attr.attr, &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, @@ -171,93 +216,91 @@ static struct attribute *sfp_msa_attributes[] = { NULL }; -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - /* Platform dependent +++ */ #define CPLD_PORT_TO_FRONT_PORT(port) (port+1) enum port_numbers { - as7312_54x_sfp1, as7312_54x_sfp2, as7312_54x_sfp3, as7312_54x_sfp4, as7312_54x_sfp5, as7312_54x_sfp6, as7312_54x_sfp7, as7312_54x_sfp8, - as7312_54x_sfp9, as7312_54x_sfp10, as7312_54x_sfp11, as7312_54x_sfp12, as7312_54x_sfp13, as7312_54x_sfp14, as7312_54x_sfp15, as7312_54x_sfp16, - as7312_54x_sfp17, as7312_54x_sfp18, as7312_54x_sfp19, as7312_54x_sfp20, as7312_54x_sfp21, as7312_54x_sfp22, as7312_54x_sfp23, as7312_54x_sfp24, - as7312_54x_sfp25, as7312_54x_sfp26, as7312_54x_sfp27, as7312_54x_sfp28, as7312_54x_sfp29, as7312_54x_sfp30, as7312_54x_sfp31, as7312_54x_sfp32, - as7312_54x_sfp33, as7312_54x_sfp34, as7312_54x_sfp35, as7312_54x_sfp36, as7312_54x_sfp37, as7312_54x_sfp38, as7312_54x_sfp39, as7312_54x_sfp40, - as7312_54x_sfp41, as7312_54x_sfp42, as7312_54x_sfp43, as7312_54x_sfp44, as7312_54x_sfp45, as7312_54x_sfp46, as7312_54x_sfp47, as7312_54x_sfp48, - as7312_54x_sfp49, as7312_54x_sfp50, as7312_54x_sfp51, as7312_54x_sfp52, as7312_54x_sfp53, as7312_54x_sfp54 +as7312_54x_port1, as7312_54x_port2, as7312_54x_port3, as7312_54x_port4, +as7312_54x_port5, as7312_54x_port6, as7312_54x_port7, as7312_54x_port8, +as7312_54x_port9, as7312_54x_port10, as7312_54x_port11, as7312_54x_port12, +as7312_54x_port13, as7312_54x_port14, as7312_54x_port15, as7312_54x_port16, +as7312_54x_port17, as7312_54x_port18, as7312_54x_port19, as7312_54x_port20, +as7312_54x_port21, as7312_54x_port22, as7312_54x_port23, as7312_54x_port24, +as7312_54x_port25, as7312_54x_port26, as7312_54x_port27, as7312_54x_port28, +as7312_54x_port29, as7312_54x_port30, as7312_54x_port31, as7312_54x_port32, +as7312_54x_port33, as7312_54x_port34, as7312_54x_port35, as7312_54x_port36, +as7312_54x_port37, as7312_54x_port38, as7312_54x_port39, as7312_54x_port40, +as7312_54x_port41, as7312_54x_port42, as7312_54x_port43, as7312_54x_port44, +as7312_54x_port45, as7312_54x_port46, as7312_54x_port47, as7312_54x_port48, +as7312_54x_port49, as7312_54x_port52, as7312_54x_port50, as7312_54x_port53, +as7312_54x_port51, as7312_54x_port54 }; -#define DEV_NAME_ID(x) {#x, x} -static const struct i2c_device_id as7312_54x_sfp_id[] = { -#if 1 - DEV_NAME_ID(as7312_54x_sfp1), DEV_NAME_ID(as7312_54x_sfp2), - DEV_NAME_ID(as7312_54x_sfp3), DEV_NAME_ID(as7312_54x_sfp4), - DEV_NAME_ID(as7312_54x_sfp5), DEV_NAME_ID(as7312_54x_sfp6), - DEV_NAME_ID(as7312_54x_sfp7), DEV_NAME_ID(as7312_54x_sfp8), - DEV_NAME_ID(as7312_54x_sfp9), DEV_NAME_ID(as7312_54x_sfp10), - DEV_NAME_ID(as7312_54x_sfp11), DEV_NAME_ID(as7312_54x_sfp12), - DEV_NAME_ID(as7312_54x_sfp13), DEV_NAME_ID(as7312_54x_sfp14), - DEV_NAME_ID(as7312_54x_sfp15), DEV_NAME_ID(as7312_54x_sfp16), - DEV_NAME_ID(as7312_54x_sfp17), DEV_NAME_ID(as7312_54x_sfp18), - DEV_NAME_ID(as7312_54x_sfp19), DEV_NAME_ID(as7312_54x_sfp20), - DEV_NAME_ID(as7312_54x_sfp21), DEV_NAME_ID(as7312_54x_sfp22), - DEV_NAME_ID(as7312_54x_sfp23), DEV_NAME_ID(as7312_54x_sfp24), - DEV_NAME_ID(as7312_54x_sfp25), DEV_NAME_ID(as7312_54x_sfp26), - DEV_NAME_ID(as7312_54x_sfp27), DEV_NAME_ID(as7312_54x_sfp28), - DEV_NAME_ID(as7312_54x_sfp29), DEV_NAME_ID(as7312_54x_sfp30), - DEV_NAME_ID(as7312_54x_sfp31), DEV_NAME_ID(as7312_54x_sfp32), - DEV_NAME_ID(as7312_54x_sfp33), DEV_NAME_ID(as7312_54x_sfp34), - DEV_NAME_ID(as7312_54x_sfp35), DEV_NAME_ID(as7312_54x_sfp36), - DEV_NAME_ID(as7312_54x_sfp37), DEV_NAME_ID(as7312_54x_sfp38), - DEV_NAME_ID(as7312_54x_sfp39), DEV_NAME_ID(as7312_54x_sfp40), - DEV_NAME_ID(as7312_54x_sfp41), DEV_NAME_ID(as7312_54x_sfp42), - DEV_NAME_ID(as7312_54x_sfp43), DEV_NAME_ID(as7312_54x_sfp44), - DEV_NAME_ID(as7312_54x_sfp45), DEV_NAME_ID(as7312_54x_sfp46), - DEV_NAME_ID(as7312_54x_sfp47), DEV_NAME_ID(as7312_54x_sfp48), - DEV_NAME_ID(as7312_54x_sfp49), DEV_NAME_ID(as7312_54x_sfp50), - DEV_NAME_ID(as7312_54x_sfp51), DEV_NAME_ID(as7312_54x_sfp52), - DEV_NAME_ID(as7312_54x_sfp53), DEV_NAME_ID(as7312_54x_sfp54), -#else - { "as7312_54x_sfp1", as7312_54x_sfp1 }, { "as7312_54x_sfp2", as7312_54x_sfp2 }, { "as7312_54x_sfp3", as7312_54x_sfp3 }, { "as7312_54x_sfp4", as7312_54x_sfp4 }, - { "as7312_54x_sfp5", as7312_54x_sfp5 }, { "as7312_54x_sfp6", as7312_54x_sfp6 }, { "as7312_54x_sfp7", as7312_54x_sfp7 }, { "as7312_54x_sfp8", as7312_54x_sfp8 }, - { "as7312_54x_sfp9", as7312_54x_sfp9 }, { "as7312_54x_sfp10", as7312_54x_sfp10 }, { "as7312_54x_sfp11", as7312_54x_sfp11 }, { "as7312_54x_sfp12", as7312_54x_sfp12 }, - { "as7312_54x_sfp13", as7312_54x_sfp13 }, { "as7312_54x_sfp14", as7312_54x_sfp14 }, { "as7312_54x_sfp15", as7312_54x_sfp15 }, { "as7312_54x_sfp16", as7312_54x_sfp16 }, - { "as7312_54x_sfp17", as7312_54x_sfp17 }, { "as7312_54x_sfp18", as7312_54x_sfp18 }, { "as7312_54x_sfp19", as7312_54x_sfp19 }, { "as7312_54x_sfp20", as7312_54x_sfp20 }, - { "as7312_54x_sfp21", as7312_54x_sfp21 }, { "as7312_54x_sfp22", as7312_54x_sfp22 }, { "as7312_54x_sfp23", as7312_54x_sfp23 }, { "as7312_54x_sfp24", as7312_54x_sfp24 }, - { "as7312_54x_sfp25", as7312_54x_sfp25 }, { "as7312_54x_sfp26", as7312_54x_sfp26 }, { "as7312_54x_sfp27", as7312_54x_sfp27 }, { "as7312_54x_sfp28", as7312_54x_sfp28 }, - { "as7312_54x_sfp29", as7312_54x_sfp29 }, { "as7312_54x_sfp30", as7312_54x_sfp30 }, { "as7312_54x_sfp31", as7312_54x_sfp31 }, { "as7312_54x_sfp32", as7312_54x_sfp32 }, - { "as7312_54x_sfp33", as7312_54x_sfp33 }, { "as7312_54x_sfp34", as7312_54x_sfp34 }, { "as7312_54x_sfp35", as7312_54x_sfp35 }, { "as7312_54x_sfp36", as7312_54x_sfp36 }, - { "as7312_54x_sfp37", as7312_54x_sfp37 }, { "as7312_54x_sfp38", as7312_54x_sfp38 }, { "as7312_54x_sfp39", as7312_54x_sfp39 }, { "as7312_54x_sfp40", as7312_54x_sfp40 }, - { "as7312_54x_sfp41", as7312_54x_sfp41 }, { "as7312_54x_sfp42", as7312_54x_sfp42 }, { "as7312_54x_sfp43", as7312_54x_sfp43 }, { "as7312_54x_sfp44", as7312_54x_sfp44 }, - { "as7312_54x_sfp45", as7312_54x_sfp45 }, { "as7312_54x_sfp46", as7312_54x_sfp46 }, { "as7312_54x_sfp47", as7312_54x_sfp47 }, { "as7312_54x_sfp48", as7312_54x_sfp48 }, - { "as7312_54x_sfp49", as7312_54x_sfp49 }, { "as7312_54x_sfp50", as7312_54x_sfp50 }, { "as7312_54x_sfp51", as7312_54x_sfp51 }, { "as7312_54x_sfp52", as7312_54x_sfp52 }, - { "as7312_54x_sfp53", as7312_54x_sfp53 }, { "as7312_54x_sfp54", as7312_54x_sfp54 }, -#endif - { /* LIST END */ } + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as7312_54x_port1), +I2C_DEV_ID(as7312_54x_port2), +I2C_DEV_ID(as7312_54x_port3), +I2C_DEV_ID(as7312_54x_port4), +I2C_DEV_ID(as7312_54x_port5), +I2C_DEV_ID(as7312_54x_port6), +I2C_DEV_ID(as7312_54x_port7), +I2C_DEV_ID(as7312_54x_port8), +I2C_DEV_ID(as7312_54x_port9), +I2C_DEV_ID(as7312_54x_port10), +I2C_DEV_ID(as7312_54x_port11), +I2C_DEV_ID(as7312_54x_port12), +I2C_DEV_ID(as7312_54x_port13), +I2C_DEV_ID(as7312_54x_port14), +I2C_DEV_ID(as7312_54x_port15), +I2C_DEV_ID(as7312_54x_port16), +I2C_DEV_ID(as7312_54x_port17), +I2C_DEV_ID(as7312_54x_port18), +I2C_DEV_ID(as7312_54x_port19), +I2C_DEV_ID(as7312_54x_port20), +I2C_DEV_ID(as7312_54x_port21), +I2C_DEV_ID(as7312_54x_port22), +I2C_DEV_ID(as7312_54x_port23), +I2C_DEV_ID(as7312_54x_port24), +I2C_DEV_ID(as7312_54x_port25), +I2C_DEV_ID(as7312_54x_port26), +I2C_DEV_ID(as7312_54x_port27), +I2C_DEV_ID(as7312_54x_port28), +I2C_DEV_ID(as7312_54x_port29), +I2C_DEV_ID(as7312_54x_port30), +I2C_DEV_ID(as7312_54x_port31), +I2C_DEV_ID(as7312_54x_port32), +I2C_DEV_ID(as7312_54x_port33), +I2C_DEV_ID(as7312_54x_port34), +I2C_DEV_ID(as7312_54x_port35), +I2C_DEV_ID(as7312_54x_port36), +I2C_DEV_ID(as7312_54x_port37), +I2C_DEV_ID(as7312_54x_port38), +I2C_DEV_ID(as7312_54x_port39), +I2C_DEV_ID(as7312_54x_port40), +I2C_DEV_ID(as7312_54x_port41), +I2C_DEV_ID(as7312_54x_port42), +I2C_DEV_ID(as7312_54x_port43), +I2C_DEV_ID(as7312_54x_port44), +I2C_DEV_ID(as7312_54x_port45), +I2C_DEV_ID(as7312_54x_port46), +I2C_DEV_ID(as7312_54x_port47), +I2C_DEV_ID(as7312_54x_port48), +I2C_DEV_ID(as7312_54x_port49), +I2C_DEV_ID(as7312_54x_port50), +I2C_DEV_ID(as7312_54x_port51), +I2C_DEV_ID(as7312_54x_port52), +I2C_DEV_ID(as7312_54x_port53), +I2C_DEV_ID(as7312_54x_port54), +{ /* LIST END */ } }; -MODULE_DEVICE_TABLE(i2c, as7312_54x_sfp_id); +MODULE_DEVICE_TABLE(i2c, sfp_device_id); /* Platform dependent --- */ -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_QSFP }; /* Each client has this additional data @@ -280,10 +323,9 @@ struct sfp_msa_data { to distinguish SFP or SFP+ 5 => DIAGNOSTIC MONITORING TYPE */ struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; +#if (MULTIPAGE_SUPPORT == 1) + struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ +#endif }; struct qsfp_data { @@ -302,16 +344,23 @@ struct sfp_port_data { struct mutex update_lock; enum driver_type_e driver_type; int port; /* CPLD port index */ - oom_driver_port_type_t port_type; u64 present; /* present status, bit0:port0, bit1:port1 and so on */ struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; struct qsfp_data *qsfp; struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif }; +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf) { @@ -482,9 +531,10 @@ static int sfp_is_port_present(struct i2c_client *client, int port) return PTR_ERR(data); } - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ } +/* Platform dependent +++ */ static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf) { @@ -522,92 +572,7 @@ static ssize_t show_present(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", present); } } - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} +/* Platform dependent --- */ static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) { @@ -670,7 +635,7 @@ static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribut if (present == 0) { /* port is not present */ - return -ENODEV; + return -ENXIO; } data = qsfp_update_tx_rx_status(dev); @@ -680,31 +645,31 @@ static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribut switch (attr->index) { case TX_FAULT: - val = (data->qsfp->status[2] & 0xF) ? 1 : 0; + val = !!(data->qsfp->status[2] & 0xF); break; case TX_FAULT1: case TX_FAULT2: case TX_FAULT3: case TX_FAULT4: - val = (data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)) ? 1 : 0; + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); break; case TX_DISABLE: - val = (data->qsfp->status[1] & 0xF) ? 1 : 0; + val = data->qsfp->status[1] & 0xF; break; case TX_DISABLE1: case TX_DISABLE2: case TX_DISABLE3: case TX_DISABLE4: - val = (data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)) ? 1 : 0; + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); break; case RX_LOS: - val = (data->qsfp->status[0] & 0xF) ? 1 : 0; + val = !!(data->qsfp->status[0] & 0xF); break; case RX_LOS1: case RX_LOS2: case RX_LOS3: case RX_LOS4: - val = (data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)) ? 1 : 0; + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); break; default: break; @@ -719,7 +684,18 @@ static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute * long disable; int status; struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct sfp_port_data *data = NULL; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } status = kstrtol(buf, 10, &disable); if (status) { @@ -760,40 +736,14 @@ static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute * return count; } -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", (ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK) ? 1 : 0); -} - /* Platform dependent +++ */ static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf) { u8 val = 0, index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct i2c_client *client = to_i2c_client(dev); struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); if (data->driver_type == DRIVER_TYPE_QSFP) { return qsfp_show_tx_rx_status(dev, da, buf); @@ -832,7 +782,7 @@ static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute return 0; } - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); + val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; return sprintf(buf, "%d\n", val); } /* Platform dependent --- */ @@ -886,6 +836,7 @@ static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const cha } +#if (MULTIPAGE_SUPPORT == 0) static ssize_t sfp_port_write(struct sfp_port_data *data, const char *buf, loff_t off, size_t count) { @@ -920,7 +871,7 @@ static ssize_t sfp_port_write(struct sfp_port_data *data, mutex_unlock(&data->update_lock); return retval; } - +#endif static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -941,7 +892,11 @@ static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, return -ENODEV; } - return sfp_port_write(data, buf, off, count); +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif } static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, @@ -1004,6 +959,518 @@ abort: #endif } +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = port_data->msa->ddm_client; + *offset -= 256; + } + } + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + if ((off + len) <= 256) return len; + /* if no pages needed, we're good */ + //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + + /* Check if ddm is supported */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF8472_DIAG_MON_TYPE_ADDR, 1); + if (status < 0) return status; /* error out (no module?) */ + if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { + if (off >= 256) return -EINVAL; + maxlen = 256 - off; + } + else { + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else static ssize_t sfp_port_read(struct sfp_port_data *data, char *buf, loff_t off, size_t count) { @@ -1041,6 +1508,7 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, return retval; } +#endif static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -1061,10 +1529,18 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, return -ENODEV; } - return sfp_port_read(data, buf, off, count); +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif } +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif { int err; @@ -1073,7 +1549,11 @@ static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eep eeprom->attr.mode = S_IWUSR | S_IRUGO; eeprom->read = sfp_bin_read; eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif /* Create eeprom file */ err = sysfs_create_bin_file(kobj, eeprom); @@ -1090,10 +1570,8 @@ static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute * return 0; } -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; +#if (MULTIPAGE_SUPPORT == 0) static int sfp_i2c_check_functionality(struct i2c_client *client) { #if USE_I2C_BLOCK_READ @@ -1102,6 +1580,11 @@ static int sfp_i2c_check_functionality(struct i2c_client *client) return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); #endif } +#endif + +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, struct sfp_msa_data **data) @@ -1109,10 +1592,12 @@ static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id * int status; struct sfp_msa_data *msa; +#if (MULTIPAGE_SUPPORT == 0) if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } +#endif msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); if (!msa) { @@ -1127,70 +1612,38 @@ static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id * } /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); +#endif if (status) { goto exit_remove; } +#if (MULTIPAGE_SUPPORT == 1) + msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); + if (!msa->ddm_client) { + dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); + status = -EADDRINUSE; + goto exit_eeprom; + } +#endif + *data = msa; dev_info(&client->dev, "sfp msa '%s'\n", client->name); return 0; +exit_eeprom: + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); exit_remove: sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); exit_free: kfree(msa); exit: - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; + return status; } static const struct attribute_group qsfp_group = { @@ -1203,10 +1656,12 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev int status; struct qsfp_data *qsfp; +#if (MULTIPAGE_SUPPORT == 0) if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } +#endif qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); if (!qsfp) { @@ -1221,7 +1676,11 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev } /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif if (status) { goto exit_remove; } @@ -1240,57 +1699,130 @@ exit: return status; } -static int as7312_54x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) { - struct sfp_port_data *data = NULL; + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as7312_54x_port1 || dev_id->driver_data > as7312_54x_port54) { + return -ENXIO; + } data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); if (!data) { return -ENOMEM; } - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; - if (dev_id->driver_data >= as7312_54x_sfp1 && dev_id->driver_data <= as7312_54x_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* as7312_54x_sfp49 ~ as7312_54x_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } - return -ENODEV; + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + + if (dev_id->driver_data >= as7312_54x_port1 && dev_id->driver_data <= as7312_54x_port48) { + data->driver_type = DRIVER_TYPE_SFP_MSA; + ret = sfp_msa_probe(client, dev_id, &data->msa); + } + else { /* as7312_54x_portsfp49 ~ as7312_54x_portsfp54 */ + data->driver_type = DRIVER_TYPE_QSFP; + ret = qsfp_probe(client, dev_id, &data->qsfp); + } + + if (ret < 0) { + goto exit_kfree_buf; + } + + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; } +/* Platform dependent --- */ static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) { sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); +#if (MULTIPAGE_SUPPORT == 1) + i2c_unregister_device(data->ddm_client); +#endif sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); kfree(data); return 0; } -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) { sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); @@ -1299,20 +1831,24 @@ static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) return 0; } -static int as7312_54x_sfp_remove(struct i2c_client *client) +static int sfp_device_remove(struct i2c_client *client) { - struct sfp_port_data *data = i2c_get_clientdata(client); + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + return sfp_msa_remove(client, data->msa); + case DRIVER_TYPE_QSFP: + return qfp_remove(client, data->qsfp); + } - return 0; +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) + kfree(data->writebuf); +#endif + kfree(data); + return ret; } /* Addresses scanned @@ -1320,35 +1856,29 @@ static int as7312_54x_sfp_remove(struct i2c_client *client) static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = as7312_54x_sfp_probe, - .remove = as7312_54x_sfp_remove, - .id_table = as7312_54x_sfp_id, - .address_list = normal_i2c, + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, }; -static int __init as7312_54x_sfp_init(void) +static int __init sfp_init(void) { - extern int platform_accton_as7312_54x(void); - if(!platform_accton_as7312_54x()) { - return -ENODEV; - } - - return i2c_add_driver(&sfp_driver); + return i2c_add_driver(&sfp_driver); } -static void __exit as7312_54x_sfp_exit(void) +static void __exit sfp_exit(void) { - i2c_del_driver(&sfp_driver); + i2c_del_driver(&sfp_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as7312_54x_sfp driver"); MODULE_LICENSE("GPL"); -module_init(as7312_54x_sfp_init); -module_exit(as7312_54x_sfp_exit); - +module_init(sfp_init); +module_exit(sfp_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py index 2342af5f..beae7266 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py @@ -69,60 +69,60 @@ class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, # initialize QSFP port 1~54 self.new_i2c_devices( [ - ('as7312_54x_sfp1', 0x50, 18), - ('as7312_54x_sfp2', 0x50, 19), - ('as7312_54x_sfp3', 0x50, 20), - ('as7312_54x_sfp4', 0x50, 21), - ('as7312_54x_sfp5', 0x50, 22), - ('as7312_54x_sfp6', 0x50, 23), - ('as7312_54x_sfp7', 0x50, 24), - ('as7312_54x_sfp8', 0x50, 25), - ('as7312_54x_sfp9', 0x50, 26), - ('as7312_54x_sfp10', 0x50, 27), - ('as7312_54x_sfp11', 0x50, 28), - ('as7312_54x_sfp12', 0x50, 29), - ('as7312_54x_sfp13', 0x50, 30), - ('as7312_54x_sfp14', 0x50, 31), - ('as7312_54x_sfp15', 0x50, 32), - ('as7312_54x_sfp16', 0x50, 33), - ('as7312_54x_sfp17', 0x50, 34), - ('as7312_54x_sfp18', 0x50, 35), - ('as7312_54x_sfp19', 0x50, 36), - ('as7312_54x_sfp20', 0x50, 37), - ('as7312_54x_sfp21', 0x50, 38), - ('as7312_54x_sfp22', 0x50, 39), - ('as7312_54x_sfp23', 0x50, 40), - ('as7312_54x_sfp24', 0x50, 41), - ('as7312_54x_sfp25', 0x50, 42), - ('as7312_54x_sfp26', 0x50, 43), - ('as7312_54x_sfp27', 0x50, 44), - ('as7312_54x_sfp28', 0x50, 45), - ('as7312_54x_sfp29', 0x50, 46), - ('as7312_54x_sfp30', 0x50, 47), - ('as7312_54x_sfp31', 0x50, 48), - ('as7312_54x_sfp32', 0x50, 49), - ('as7312_54x_sfp33', 0x50, 50), - ('as7312_54x_sfp34', 0x50, 51), - ('as7312_54x_sfp35', 0x50, 52), - ('as7312_54x_sfp36', 0x50, 53), - ('as7312_54x_sfp37', 0x50, 54), - ('as7312_54x_sfp38', 0x50, 55), - ('as7312_54x_sfp39', 0x50, 56), - ('as7312_54x_sfp40', 0x50, 57), - ('as7312_54x_sfp41', 0x50, 58), - ('as7312_54x_sfp42', 0x50, 59), - ('as7312_54x_sfp43', 0x50, 60), - ('as7312_54x_sfp44', 0x50, 61), - ('as7312_54x_sfp45', 0x50, 62), - ('as7312_54x_sfp46', 0x50, 63), - ('as7312_54x_sfp47', 0x50, 64), - ('as7312_54x_sfp48', 0x50, 65), - ('as7312_54x_sfp49', 0x50, 66), - ('as7312_54x_sfp50', 0x50, 67), - ('as7312_54x_sfp51', 0x50, 68), - ('as7312_54x_sfp52', 0x50, 69), - ('as7312_54x_sfp53', 0x50, 70), - ('as7312_54x_sfp54', 0x50, 71), + ('as7312_54x_port1', 0x50, 18), + ('as7312_54x_port2', 0x50, 19), + ('as7312_54x_port3', 0x50, 20), + ('as7312_54x_port4', 0x50, 21), + ('as7312_54x_port5', 0x50, 22), + ('as7312_54x_port6', 0x50, 23), + ('as7312_54x_port7', 0x50, 24), + ('as7312_54x_port8', 0x50, 25), + ('as7312_54x_port9', 0x50, 26), + ('as7312_54x_port10', 0x50, 27), + ('as7312_54x_port11', 0x50, 28), + ('as7312_54x_port12', 0x50, 29), + ('as7312_54x_port13', 0x50, 30), + ('as7312_54x_port14', 0x50, 31), + ('as7312_54x_port15', 0x50, 32), + ('as7312_54x_port16', 0x50, 33), + ('as7312_54x_port17', 0x50, 34), + ('as7312_54x_port18', 0x50, 35), + ('as7312_54x_port19', 0x50, 36), + ('as7312_54x_port20', 0x50, 37), + ('as7312_54x_port21', 0x50, 38), + ('as7312_54x_port22', 0x50, 39), + ('as7312_54x_port23', 0x50, 40), + ('as7312_54x_port24', 0x50, 41), + ('as7312_54x_port25', 0x50, 42), + ('as7312_54x_port26', 0x50, 43), + ('as7312_54x_port27', 0x50, 44), + ('as7312_54x_port28', 0x50, 45), + ('as7312_54x_port29', 0x50, 46), + ('as7312_54x_port30', 0x50, 47), + ('as7312_54x_port31', 0x50, 48), + ('as7312_54x_port32', 0x50, 49), + ('as7312_54x_port33', 0x50, 50), + ('as7312_54x_port34', 0x50, 51), + ('as7312_54x_port35', 0x50, 52), + ('as7312_54x_port36', 0x50, 53), + ('as7312_54x_port37', 0x50, 54), + ('as7312_54x_port38', 0x50, 55), + ('as7312_54x_port39', 0x50, 56), + ('as7312_54x_port40', 0x50, 57), + ('as7312_54x_port41', 0x50, 58), + ('as7312_54x_port42', 0x50, 59), + ('as7312_54x_port43', 0x50, 60), + ('as7312_54x_port44', 0x50, 61), + ('as7312_54x_port45', 0x50, 62), + ('as7312_54x_port46', 0x50, 63), + ('as7312_54x_port47', 0x50, 64), + ('as7312_54x_port48', 0x50, 65), + ('as7312_54x_port49', 0x50, 66), + ('as7312_54x_port50', 0x50, 67), + ('as7312_54x_port51', 0x50, 68), + ('as7312_54x_port52', 0x50, 69), + ('as7312_54x_port53', 0x50, 70), + ('as7312_54x_port54', 0x50, 71), ] ) self.new_i2c_device('24c02', 0x57, 1) From 26ddcb71086280c65325c787522b66f66f64bb7e Mon Sep 17 00:00:00 2001 From: Dave Hu Date: Mon, 4 Dec 2017 02:27:25 +0000 Subject: [PATCH 081/244] modified for the platform delta ag6248c --- .../src/arm_delta_ag6248c/module/src/fani.c | 21 ++-- .../module/src/platform_lib.h | 5 +- .../src/arm_delta_ag6248c/module/src/psui.c | 25 ++--- .../arm_delta_ag6248c/module/src/thermali.c | 100 ++++++++++++++++-- 4 files changed, 120 insertions(+), 31 deletions(-) diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c index 9e0fb0cf..b0c16526 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c @@ -29,9 +29,9 @@ #include "platform_lib.h" #include "arm_delta_ag6248c_int.h" #include "arm_delta_i2c.h" +#include - -#define MAX_FAN_SPEED 16000 +#define MAX_FAN_SPEED 12000 #define MAX_PSU_FAN_SPEED 23000 #define FILE_NAME_LEN 80 @@ -176,7 +176,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) } else{ info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_E_UNSUPPORTED; + return ONLP_STATUS_OK; } /* get fan speed */ @@ -213,10 +213,11 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) { int psu_id; int r_data,fan_rpm; - + int psu_present; + int psu_good; psu_type_t psu_type; - enum ag6248c_product_id pid = get_product_id(); + enum ag6248c_product_id pid = get_product_id(); /* get fan fault status */ psu_id = (local_id - FAN_1_ON_PSU1) + 1; @@ -224,6 +225,12 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) psu_type = get_psu_type(psu_id); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */ DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type); + psu_present=psu_status_info_get(psu_id, "present"); + psu_good=psu_status_info_get(psu_id, "good"); + if((psu_present<=0)||(psu_good<=0)){ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } switch (psu_type) { case PSU_TYPE_AC_F2B: @@ -408,13 +415,13 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) return ONLP_STATUS_E_INVALID; } - rpm_val=p* MAX_PSU_FAN_SPEED/100; + rpm_val=p*(MAX_FAN_SPEED/100); /*get ret value for the speed set*/ fan_set_rpm_cont=FAN_FROM_REG(rpm_val); /*set the rpm speed */ - rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(id), fan_set_rpm_cont); + rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont); if(rc<0) return ONLP_STATUS_E_INVALID; diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h index d0d01f24..b8f6fc46 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h @@ -28,7 +28,7 @@ #include "arm_delta_ag6248c_log.h" -#define CHASSIS_THERMAL_COUNT 2 +#define CHASSIS_THERMAL_COUNT 4 #define CHASSIS_PSU_COUNT 2 #define PSU1_ID 1 @@ -53,7 +53,7 @@ psu_type_t get_psu_type(int id); enum onlp_fan_duty_cycle_percentage { - FAN_IDLE_RPM = 5500, + FAN_IDLE_RPM = 5500, FAN_LEVEL1_RPM = 7000, FAN_LEVEL2_RPM = 9000, FAN_LEVEL3_RPM = 12000, @@ -130,5 +130,6 @@ typedef enum platform_id_e { extern platform_id_t platform_id; +extern int psu_status_info_get(int id, char *node); #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c index 66cfdb74..3a0d8344 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c @@ -79,7 +79,7 @@ static long psu_data_convert_16(unsigned int d, int mult) } -static int +int psu_status_info_get(int id, char *node) { int ret; @@ -234,9 +234,9 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) int ret = ONLP_STATUS_OK; int index = ONLP_OID_ID_GET(id); psu_type_t psu_type; - int r_data; - char sn_data[15]={0}; - char model_data[17]={0}; + int r_data; + char sn_data[15]={0}; + char model_data[17]={0}; VALIDATE(id); @@ -245,29 +245,30 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ /* Get the present state */ - val=psu_status_info_get(index, "present"); + val=psu_status_info_get(index, "present"); if (val<0) { - AIM_LOG_INFO("Unable to read PSU %d present value)\r\n", index); - return ONLP_STATUS_E_INVALID; + AIM_LOG_INFO("Unable to read PSU %d present value)\r\n", index); + return ONLP_STATUS_E_INVALID; } - if (val != PSU_STATUS_PRESENT) { + if (val != PSU_STATUS_PRESENT) { info->status &= ~ONLP_PSU_STATUS_PRESENT; return ONLP_STATUS_OK; } info->status |= ONLP_PSU_STATUS_PRESENT; /* Get power good status */ - val=psu_status_info_get(index,"good"); + val=psu_status_info_get(index,"good"); - if (val<0) { - AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index); - return ONLP_STATUS_E_INVALID; + if (val<0) { + AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index); + return ONLP_STATUS_E_INVALID; } if (val != PSU_STATUS_POWER_GOOD) { info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; } /* Get PSU type diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c index 8b02459f..807855c9 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c @@ -31,6 +31,7 @@ #include "platform_lib.h" #include "arm_delta_ag6248c_log.h" #include +#include "arm_delta_i2c.h" #define prefix_path "/sys/bus/i2c/devices/" #define LOCAL_DEBUG 0 @@ -46,7 +47,7 @@ enum onlp_thermal_id { THERMAL_RESERVED = 0, THERMAL_1_CLOSE_TO_MAC, - THERMAL_2_CLOSE_TO_PHY, + THERMAL_2_CLOSE_TO_PHY, THERMAL_1_ON_PSU1, THERMAL_1_ON_PSU2, }; @@ -56,8 +57,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */ "reserved", "0-0049/temp1_input", "0-004a/temp1_input", - "4-0058/psu_temp1_input", - "5-0058/psu_temp1_input", }; /* Static values */ @@ -80,7 +79,19 @@ static onlp_thermal_info_t linfo[] = { ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS } }; - +static int +_onlp_psu_thermali_val_to_temperature (int v,int mult) +{ + long X, Y, N, n; + Y = v & 0x07FF; + N = (v >> 11) & 0x0f; + n = v & 0x8000 ? 1 : 0; + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = Y * mult * (N=(1<<(N&0xf))); + return X; +} /* * This will be called to intiialize the thermali subsystem. */ @@ -100,20 +111,17 @@ onlp_thermali_init(void) * Note -- it is expected that you fill out the information * structure even if the sensor described by the OID is not present. */ -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +static int +_onlp_thermali_info_get(int id, onlp_thermal_info_t* info) { int len, nbytes = 10, temp_base=1, local_id; uint8_t r_data[10] = {0}; char fullpath[50] = {0}; - VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); + local_id = id; DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; /* get fullpath */ sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]); @@ -126,3 +134,75 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) return ONLP_STATUS_OK; } +static int +_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info) +{ + int psu_present,psu_good; + int psu_id,local_id; + int r_data,temperature_v; + enum ag6248c_product_id pid; + + local_id=id; + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + + psu_id=(local_id-THERMAL_1_ON_PSU1)+1; + pid=get_product_id(); + //if the psu is not, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + psu_good=psu_status_info_get(psu_id, "good"); + if((psu_present<=0)||(psu_good<=0)){ + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + //read the pus temperture register value + if(pid == PID_AG6248C_48){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); + } + else{ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x8d); + } + if(r_data<0) + return ONLP_STATUS_E_INVALID; + //get the real temperture value + temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000); + + info->mcelsius=temperature_v; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; + +} + +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rc; + int local_id; + + VALIDATE(id); + + local_id=ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if((local_id==THERMAL_1_CLOSE_TO_MAC) || (local_id==THERMAL_2_CLOSE_TO_PHY)) + rc= _onlp_thermali_info_get(local_id,info); + else if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2)) + rc=_onlp_thermali_psu_info_get(local_id,info); + else{ + rc=ONLP_STATUS_E_INVALID; + } + return rc; +} + + + From 43103d663308ff6b904c4998e9ab1a9488404352 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 8 Dec 2017 00:21:17 +0000 Subject: [PATCH 082/244] Cache the DMI system version at baseconfig time. --- .../src/python/onl/platform/baseconfig.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py index 1f43884b..30976a3a 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py @@ -61,6 +61,13 @@ def baseconfig(): ONLPDUMP = "%s/bin/onlpdump" % (platform.basedir_onl()) + try: + import dmidecode + with open("%s/dmi-system-version" % platform.basedir_onl(), "w") as f: + f.write(dmidecode.QuerySection('system')['0x0001']['data']['Version']) + except: + pass + if not platform.baseconfig(): msg("*** platform class baseconfig failed.\n", fatal=True) From 558bc2fe600c0e4d44935c7eb90da1f98f9db01b Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 8 Dec 2017 00:24:33 +0000 Subject: [PATCH 083/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 7d3a194f..90a1d56c 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 7d3a194f7d0b7a144b7773413a3dfb8d24ad1129 +Subproject commit 90a1d56c57385e5206c8452ef155b92bba06e26b From 2e7c9888671c712a940cab95cc77161ffd18bccb Mon Sep 17 00:00:00 2001 From: ericdocker Date: Fri, 8 Dec 2017 15:47:19 +0800 Subject: [PATCH 084/244] 1. fix the wrong display value of PSU 2. modify the shut down temperature on thermal sensors 3. modify the corresponding capability of LED on the frnt panel and fan 4. fixed the relative speed of fan and thermal Signed-off-by: ericdocker --- .../modules/builds/agc7648a_dps800ab.c | 6 +- .../onlp/builds/src/module/src/ledi.c | 274 +++++++++--------- .../onlp/builds/src/module/src/platform_lib.h | 2 +- .../onlp/builds/src/module/src/sysi.c | 166 ++++++++--- .../x86_64_delta_agc7648a_r0/__init__.py | 2 +- 5 files changed, 271 insertions(+), 179 deletions(-) mode change 100755 => 100644 packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c mode change 100755 => 100644 packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h mode change 100755 => 100644 packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c index 0d9b4aee..cc7c54cd 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c @@ -257,9 +257,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent)); + return (exponent > 0) ? \ + sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent)); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c old mode 100755 new mode 100644 index b9b68115..d752236a --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c @@ -51,37 +51,37 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, }, { { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, }, { { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "REAR LED (FAN TRAY 1)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED , }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "REAR LED (FAN TRAY 2)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "REAR LED (FAN TRAY 3)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "REAR LED (FAN TRAY 4)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, } }; /* @@ -121,23 +121,35 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { case LED_FRONT_FAN: if((r_data & 0x02) == 0x02) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x01) == 0x01) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x01) == 0x01) + info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0x01) == 0x03) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if((r_data & 0x01) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_SYS: - if((r_data & 0x10) == 0x10) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x20) == 0x20) - info->mode = ONLP_LED_MODE_ORANGE; - else - return ONLP_STATUS_E_INTERNAL; + if((r_data & 0xF0) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0xF0) == 0x20) + info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0xF0) == 0xa0) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if((r_data & 0xF0) == 0x90) + info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0xF0) == 0x0) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_PWR: if((r_data & 0x08) == 0x08) - info->mode = ONLP_LED_MODE_GREEN; + info->mode = ONLP_LED_MODE_GREEN; else if((r_data & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_ORANGE; else info->mode = ONLP_LED_MODE_OFF; break; @@ -151,10 +163,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x80) == 0x80) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_2: mux_info.channel= 0x01; @@ -166,10 +180,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x10) == 0x10) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x20) == 0x20) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_3: mux_info.channel= 0x02; @@ -178,13 +194,15 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); if(fantray_present >= 0) { - if((r_data1 & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data1 & 0x08) == 0x08) - info->mode = ONLP_LED_MODE_ORANGE; + if((r_data1 & 0x04) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data1 & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_4: mux_info.channel= 0x03; @@ -196,10 +214,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x01) == 0x01) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x02) == 0x02) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; default: @@ -250,23 +270,7 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0 ; - int fantray_present = -1 ,rpm = 0,rpm1 = 0; - uint8_t front_panel_led_value, fan_tray_led_value, power_state; - - - mux_info_t mux_info; - mux_info.bus = I2C_BUS_5; - mux_info.addr = SWPLD; - mux_info.offset = FAN_MUX_REG; - mux_info.channel = 0x07; - mux_info.flags = DEFAULT_FLAG; - - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; - + uint8_t front_panel_led_value, fan_tray_led_value; front_panel_led_value = dni_lock_cpld_read_attribute(SWPLD_PATH,LED_REG); fan_tray_led_value = dni_lock_cpld_read_attribute(SWPLD_PATH,FAN_TRAY_LED_REG); @@ -275,141 +279,137 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) case LED_FRONT_FAN: /* Clean the bit 1,0 */ front_panel_led_value &= ~0x3; - /* Read fan eeprom to check present */ - for(i = 0;i < 4; i++) + if(mode == ONLP_LED_MODE_GREEN) { - mux_info.channel = i; - /* FAN TRAT 1~4: 0x52 , 0x53, 0x54, 0x55 */ - dev_info.addr = FAN_TRAY_1 + i; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - if( fantray_present >= 0 ) - count++; + front_panel_led_value |= 0x02; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST) + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) { - front_panel_led_value|=0x02; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x03; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x01; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_OFF) + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); else - { - front_panel_led_value|=0x01; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); - } - + return ONLP_STATUS_E_UNSUPPORTED; break; + case LED_FRONT_SYS: + front_panel_led_value &= ~0xF0; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x10; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0xA0; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x20; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x90; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_OFF) + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + else + return ONLP_STATUS_E_UNSUPPORTED; + break; + case LED_FRONT_PWR: /* Clean bit 3,2 */ front_panel_led_value &= ~0x0C; /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_4; - dev_info.addr = PSU_EEPROM; - mux_info.channel = 0x00; - - /* Check the state of PSU 1, "state = 1, PSU exists' */ - power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); - /* Set the light of PSU */ - if((power_state&0x80) != 0x80) + if(mode == ONLP_LED_MODE_GREEN) { - /* Red */ - front_panel_led_value|=0x04; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x08; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - else if((power_state&0x80)==0x80) + else if(mode == ONLP_LED_MODE_ORANGE) { - /* Green */ - front_panel_led_value|=0x08; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x04; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - else - dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG, front_panel_led_value); + else if(mode == ONLP_LED_MODE_OFF) + { + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else + return ONLP_STATUS_E_UNSUPPORTED; break; - case LED_REAR_FAN_TRAY_1: - mux_info.channel= 0x00; - dev_info.addr = FAN_TRAY_1; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); fan_tray_led_value &= ~0xC0; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x40; + fan_tray_led_value |= 0x40; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x80; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x80; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; - case LED_REAR_FAN_TRAY_2: - mux_info.channel= 0x01; - dev_info.addr = FAN_TRAY_2; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - fan_tray_led_value &= ~0x30; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + case LED_REAR_FAN_TRAY_2: + fan_tray_led_value &= ~0x30; + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x10; + fan_tray_led_value |= 0x10; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x20; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x20; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; case LED_REAR_FAN_TRAY_3: - mux_info.channel= 0x02; - dev_info.bus = I2C_BUS_3; - dev_info.addr = FAN_TRAY_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); fan_tray_led_value &= ~0x0c; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x04; + fan_tray_led_value |= 0x04; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x08; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x08; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; case LED_REAR_FAN_TRAY_4: - mux_info.channel= 0x03; - dev_info.addr = FAN_TRAY_4; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); fan_tray_led_value &= ~0x03; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x01; + fan_tray_led_value |= 0x01; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x02; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x02; - dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } - break; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + + break; } return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h old mode 100755 new mode 100644 index 3a73af24..1e1eb419 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h @@ -33,7 +33,7 @@ #define PSU1_ID 1 #define PSU2_ID 2 - +#define ALL_FAN_TRAY_EXIST 4 #define SYS_DEV_PATH "/sys/bus/i2c/devices" #define CPU_CPLD_PATH SYS_DEV_PATH "/2-0031" #define SWPLD_PATH SYS_DEV_PATH "/5-0030" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c old mode 100755 new mode 100644 index 22214e61..d28595f5 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c @@ -58,27 +58,27 @@ decide_percentage(int *percentage, int temper) { int level; - if(temper < 65) + if(temper <= 25) { - *percentage = 50; + *percentage = 40; level = 0; } - else if(temper >= 65 && temper <= 70) + else if(temper > 25 && temper <= 40) { *percentage = 60; level = 1; } - else if(temper > 70 && temper <= 75) + else if(temper > 40 && temper <= 55) { - *percentage = 70; + *percentage = 80; level = 2; } - else if(temper > 75 && temper <= 80) + else if(temper > 55 && temper <= 75) { - *percentage = 85; + *percentage = 90; level = 3; } - else if(temper > 80) + else if(temper > 75) { *percentage = 100; level = 4; @@ -229,64 +229,156 @@ int onlp_sysi_platform_manage_leds(void) { - uint8_t present_bit = 0 ,addr = 0; - + uint8_t count, power_state; + int fantray_present = -1 ,rpm = 0,rpm1 = 0 , i; /* set PWR led in front panel */ - addr = dni_lock_cpld_read_attribute(SWPLD_PATH,LED_REG); - /* Turn the fan led on or off */ - if((addr & 0x3) == 0 || (addr & 0x3) == 0x3 ) + mux_info_t mux_info; + mux_info.bus = I2C_BUS_5; + mux_info.addr = SWPLD; + mux_info.offset = FAN_MUX_REG; + mux_info.channel = 0x07; + mux_info.flags = DEFAULT_FLAG; + + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + + /* FRONT FAN & SYS LED */ + for(i = 0;i < 4; i++) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); + mux_info.channel = i; + /* FAN TRAT 1~4: 0x52 , 0x53, 0x54, 0x55 */ + dev_info.addr = FAN_TRAY_1 + i; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + if( fantray_present >= 0 ) + count++; + } + if(count == ALL_FAN_TRAY_EXIST) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_ORANGE); } - if(dni_psu_present_get(1) == 1) - { /* PSU1 is present */ - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF); - } - /* Rare light fan tray 1-4 */ - present_bit = dni_lock_cpld_read_attribute(SWPLD_PATH,FAN_TRAY_LED_REG); + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; - if ((present_bit& 0x08) == 0x00) + /* Check the state of PSU 1, "state = 1, PSU exists' */ + power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); + /* Set the light of PSU */ + if((power_state&0x80) != 0x80) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); + /* ORANGE */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); + } + else if((power_state&0x80)==0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + + mux_info.channel= 0x00; + dev_info.addr = FAN_TRAY_1; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED); } - if ((present_bit& 0x04) == 0x00) + /* Fan tray 2 */ + mux_info.channel= 0x01; + dev_info.addr = FAN_TRAY_2; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED); } - if ((present_bit& 0x02) == 0x00) + + /* Fan tray 3 */ + mux_info.channel= 0x02; + dev_info.bus = I2C_BUS_3; + dev_info.addr = FAN_TRAY_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED); } - if ((present_bit& 0x01) == 0x00) + + /* Fan tray 4 */ + mux_info.channel= 0x03; + dev_info.addr = FAN_TRAY_4; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + 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 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED); } + + + /* Set front light of PWR */ + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; + + /* Check the state of PSU 1, "state = 1, PSU exists' */ + power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); + /* Set the light of PSU */ + + if((power_state&0x80) == 0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else if((power_state&0x80) != 0x80) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py index bb01636e..7e84909b 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py @@ -50,6 +50,6 @@ class OnlPlatform_x86_64_delta_agc7648a_r0(OnlPlatformDelta, self.new_i2c_device('agc7648a_sfp', 0x50, 8) # Set front panel green light of sys led - os.system("echo 0x30 > /sys/bus/i2c/devices/5-0030/addr") + os.system("echo 0x1c > /sys/bus/i2c/devices/5-0030/addr") os.system("echo 0x10 > /sys/bus/i2c/devices/5-0030/data") return True From 91cec7c245230f6444d4a4a9641b3ec63b92ca7a Mon Sep 17 00:00:00 2001 From: "johnson.lu" Date: Fri, 8 Dec 2017 15:54:40 +0800 Subject: [PATCH 085/244] fix bug: 1. Fixed bug: 1.1 shows the correct percentage speed display on fan 2. modify the corresponding LED capability Signed-off-by: johnson.lu --- .../modules/builds/dni_ag5648_psu.c | 10 +- .../modules/builds/dni_ag5648_sfp.c | 2 +- .../modules/builds/dni_emc2305.c | 44 +- .../onlp/builds/src/module/src/fani.c | 36 +- .../onlp/builds/src/module/src/ledi.c | 414 +++++++++--------- .../onlp/builds/src/module/src/platform_lib.c | 43 +- .../onlp/builds/src/module/src/platform_lib.h | 5 +- .../onlp/builds/src/module/src/sysi.c | 165 ++++--- .../onlp/builds/src/module/src/thermali.c | 27 +- .../python/x86_64_delta_ag5648_r0/__init__.py | 1 - 10 files changed, 422 insertions(+), 325 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c index eae7970e..a6bc521e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c @@ -176,8 +176,8 @@ static ssize_t for_linear_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(value >> 11, 5, 0x1f); mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - return (exponent >= 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ + return (exponent >= 0) ? \ + sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) : \ sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); } @@ -201,9 +201,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - return (exponent > 0) ? sprintf(buf, "%d\n", \ - mantissa * (1 << exponent)) : \ - sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier); + return (exponent > 0) ? \ + sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent)); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c index a0459f37..198084f1 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c @@ -199,7 +199,7 @@ static ssize_t for_r_port_data(struct device *dev, struct device_attribute *dev_ } } - return sprintf(buf, "%d\n", sfp_port_data); + return sprintf(buf, "%d\n", (int)sfp_port_data); } static ssize_t set_w_lp_mode_data(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c index 00ed5ebe..ba63bdc8 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c @@ -32,6 +32,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf); static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf); +static ssize_t show_percentage(struct device *dev, struct device_attribute *devattr, + char *buf); static ssize_t set_fan(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count); static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *devattr, @@ -57,6 +59,7 @@ static const unsigned short normal_i2c[] = { 0x2C, 0x2D, 0x2E, 0x2F, 0x4C, #define EMC2305_DEVICE 0x34 #define EMC2305_VENDOR 0x5D +#define MAX_FAN_SPEED 23000 struct emc2305_data { @@ -95,17 +98,17 @@ static SENSOR_DEVICE_ATTR(fan1_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 0); static SENSOR_DEVICE_ATTR(fan2_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 1); static SENSOR_DEVICE_ATTR(fan3_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 2); static SENSOR_DEVICE_ATTR(fan4_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); -static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 0); -static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 1); -static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 2); -static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 3); -static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 4); +//static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); +static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 0); +static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 1); +static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 2); +static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 3); +//static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 4); static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4); +//static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4); static struct attribute *emc2305_attr[] = { @@ -113,17 +116,17 @@ static struct attribute *emc2305_attr[] = &sensor_dev_attr_fan2_input.dev_attr.attr, &sensor_dev_attr_fan3_input.dev_attr.attr, &sensor_dev_attr_fan4_input.dev_attr.attr, - &sensor_dev_attr_fan5_input.dev_attr.attr, +// &sensor_dev_attr_fan5_input.dev_attr.attr, &sensor_dev_attr_fan1_input_percentage.dev_attr.attr, &sensor_dev_attr_fan2_input_percentage.dev_attr.attr, &sensor_dev_attr_fan3_input_percentage.dev_attr.attr, &sensor_dev_attr_fan4_input_percentage.dev_attr.attr, - &sensor_dev_attr_fan5_input_percentage.dev_attr.attr, +// &sensor_dev_attr_fan5_input_percentage.dev_attr.attr, &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, &sensor_dev_attr_pwm3.dev_attr.attr, &sensor_dev_attr_pwm4.dev_attr.attr, - &sensor_dev_attr_pwm5.dev_attr.attr, +// &sensor_dev_attr_pwm5.dev_attr.attr, NULL }; @@ -169,6 +172,25 @@ static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *d return count; } +static ssize_t show_percentage(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct emc2305_data *data = i2c_get_clientdata(client); + int val; + + + mutex_lock(&data->lock); + val = i2c_smbus_read_word_swapped(client, + EMC2305_REG_FAN_TACH(attr->index)); + mutex_unlock(&data->lock); + /* Left shift 3 bits for showing correct RPM */ + val = val >> 3; + if ((int)(3932160 * 2 / (val > 0 ? val : 1) == 960))return sprintf(buf, "%d\n", 0); + + return sprintf(buf, "%d\n", (int)(3932160 * 2 / (val > 0 ? val : 1) * 100 / MAX_FAN_SPEED)); +} static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf) @@ -332,7 +354,7 @@ static int emc2305_probe(struct i2c_client *client, goto exit_remove; } - for (i = 0; i < 5; i++) + for (i = 0; i < 4; i++) { /* set minimum drive to 0% */ i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_MIN_DRIVE(i), FAN_MINIMUN); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c index 3c3014e0..4b2d45f0 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c @@ -39,14 +39,14 @@ typedef struct fan_path_S static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { { NULL, NULL, NULL }, - { "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input" }, - { "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input" }, - { "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input" }, - { "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input" }, - { "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input" }, - { "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input" }, - { "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input" }, - { "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input" }, + { "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input_percentage" }, + { "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input_percentage" }, + { "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input_percentage" }, + { "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input_percentage" }, + { "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input_percentage" }, + { "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input_percentage" }, + { "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input_percentage" }, + { "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input_percentage" }, { "/6-0059/psu_fan1_fault", "/6-0059/psu_fan1_speed_rpm", "/6-0059/psu_fan1_duty_cycle_percentage" }, { "/6-0058/psu_fan1_fault", "/6-0058/psu_fan1_speed_rpm", "/6-0058/psu_fan1_duty_cycle_percentage" } }; @@ -55,7 +55,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { \ { ONLP_FAN_ID_CREATE(FAN_##id##_ON_FAN_BOARD), "Chassis Fan "#id, 0 }, \ 0x0, \ - (ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ 0, \ 0, \ ONLP_FAN_MODE_INVALID, \ @@ -274,7 +274,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) case FAN_6_ON_FAN_BOARD: case FAN_7_ON_FAN_BOARD: case FAN_8_ON_FAN_BOARD: - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed); break; default: return ONLP_STATUS_E_INVALID; @@ -303,13 +303,21 @@ onlp_fani_percentage_set(onlp_oid_t id, int percentage) /* Select PSU member */ switch (local_id) { - case FAN_1_ON_PSU1: - case FAN_1_ON_PSU2: - break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + case FAN_7_ON_FAN_BOARD: + case FAN_8_ON_FAN_BOARD: + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + break; default: return ONLP_STATUS_E_INVALID; } - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); /* Write percentage to psu_fan1_duty_cycle_percentage */ sprintf(data, "%d", percentage); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c index 4400b2cc..a6584362 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c @@ -2,7 +2,7 @@ * * * Copyright 2014 Big Switch Networks, Inc. - * Copyright (C) 2017 Delta Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. * * Licensed under the Eclipse Public License, Version 1.0 (the * "License"); you may not use this file except in compliance @@ -43,44 +43,44 @@ * Get the information for the given LED OID. */ static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ { - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - }; + { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, +}; /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -104,10 +104,10 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) dev_info.flags = DEFAULT_FLAG; /* Set front panel's mode of leds */ - r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); + r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); int local_id = ONLP_OID_ID_GET(id); switch(local_id) - { + { case LED_FRONT_FAN: if((r_data & 0xc0) == 0x80) info->mode = ONLP_LED_MODE_GREEN; @@ -118,6 +118,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) else info->mode = ONLP_LED_MODE_OFF; break; + case LED_FRONT_SYS: if((r_data & 0x30) == 0x10) info->mode = ONLP_LED_MODE_GREEN; @@ -125,9 +126,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) info->mode = ONLP_LED_MODE_ORANGE; else if((r_data & 0x30) == 0x00) info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0x30) == 0x30) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; else return ONLP_STATUS_E_INTERNAL; break; + case LED_FRONT_PWR: if((r_data & 0x06) == 0x04) info->mode = ONLP_LED_MODE_GREEN; @@ -138,67 +142,80 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) else info->mode = ONLP_LED_MODE_OFF; break; + case LED_REAR_FAN_TRAY_1: dev_info.addr = FAN_TRAY_1; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x01) == 0x01) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x01) == 0x01) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x02) == 0x02) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_2: dev_info.addr = FAN_TRAY_2; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x04) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_3: dev_info.addr = FAN_TRAY_3; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x10) == 0x10) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x10) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x20) == 0x20) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_4: dev_info.addr = FAN_TRAY_4; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x40) == 0x40) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x40) == 0x40) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x80) == 0x80) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + default: break; - } + } /* Set the on/off status */ - if (info->mode == ONLP_LED_MODE_OFF) + if (info->mode == ONLP_LED_MODE_OFF) info->status |= ONLP_LED_STATUS_FAILED; else info->status |=ONLP_LED_STATUS_PRESENT; @@ -236,186 +253,145 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0 ,fan_board_not_present_count = 0 , fan_stat2_reg_mask = 0 , fan_stat1_reg_mask = 0 ; - int fantray_present = -1, rpm = 0, rpm1 = 0; - uint8_t front_panel_led_value, power_state,fan_tray_led_reg_value, fan_led_status_value, fan_tray_pres_value; - uint8_t psu1_state, psu2_state, alarm_reg_value, fan_tray_interface_detected_value; - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; + uint8_t front_panel_led_value,fan_tray_led_reg_value; front_panel_led_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); fan_tray_led_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); - fan_led_status_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT1_REG); - fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); - alarm_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,ALARM_REG); - + switch(local_id) - { + { case LED_FRONT_FAN: - /* Clean the bit 7,6 */ - front_panel_led_value &= ~0xC0; - fan_board_not_present_count = 0; - /* Read cpld fan status to check present. Fan tray 1-4 */ - for(i = 0; i < 4; i++) - { - fan_stat2_reg_mask = 0x01 << i; - fan_stat1_reg_mask = 0x01 << (i * 2); - if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask) - fan_board_not_present_count++; - else if((fan_led_status_value & fan_stat1_reg_mask) == fan_stat1_reg_mask) - count++; - } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST) - { - front_panel_led_value |= 0x80;/*Solid green, FAN operates normally.*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - else if (fan_board_not_present_count > 0) - { - front_panel_led_value |= 0xc0;/*Blinking Yellow , FAN is failed */ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } + front_panel_led_value &= ~0xc0; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x80; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x40; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0xc0; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } else - { - front_panel_led_value |= 0x40;/*Solid Amber FAN operating is NOT present */ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - - break; - - case LED_FRONT_PWR: - /* Clean bit 2,1 */ - front_panel_led_value &= ~0x06; - /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_6; - dev_info.addr = PSU1_EEPROM; - psu1_state = dni_i2c_lock_read(NULL, &dev_info); - /* switch CPLD to PSU 2 */ - dev_info.addr = PSU2_EEPROM; - psu2_state = dni_i2c_lock_read(NULL, &dev_info); - - if(psu1_state == 1 && psu2_state == 1) - { - power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG); - - if((power_state & 0x40) == 0x40 || (power_state & 0x04) == 0x04) - { - front_panel_led_value |= 0x06; /*Blinking Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - else - { - front_panel_led_value |= 0x04; /*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - } - else - front_panel_led_value |= 0x02; /*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); break; case LED_FRONT_SYS: - /* Clean bit 4,5 */ front_panel_led_value &= ~0x30; - fan_board_not_present_count = 0; - /* Read fan eeprom to check present */ - for(i = 0;i < 4; i++) - { - fan_stat2_reg_mask = 0x01 << i; - if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask) - fan_board_not_present_count++; - } - if(fan_board_not_present_count > 0 || (alarm_reg_value & 0xff) == 0xff) - { - fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG); - if(fan_tray_interface_detected_value == 0xfe || (alarm_reg_value & 0xff) == 0xff) - { - front_panel_led_value |= 0x20; - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value); - } - } + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x10; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x20; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x00; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0x30; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } else - { - front_panel_led_value |= 0x10; - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + break; + + case LED_FRONT_PWR: + front_panel_led_value &= ~0x06; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x04; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x02; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0x06; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); break; case LED_REAR_FAN_TRAY_1: - dev_info.addr = FAN_TRAY_1; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); fan_tray_led_reg_value &= ~0x03; - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x01;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x01; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x02; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x02;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_2: - dev_info.addr = FAN_TRAY_2; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); fan_tray_led_reg_value &= ~0x0c; - - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x04;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x04; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x08; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x08;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_3: - dev_info.addr = FAN_TRAY_3; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); fan_tray_led_reg_value &= ~0x30; - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x10;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x10; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x20; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x20;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_4: - dev_info.addr = FAN_TRAY_4; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); fan_tray_led_reg_value &= ~0xc0; - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm !=0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x40; /*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x40; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x80; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x80;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + break; + } return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c index 648296d3..d6046c6e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c @@ -41,24 +41,29 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in int fd; int len; - if ((buffer == NULL) || (buf_size < 0)) { + if ((buffer == NULL) || (buf_size < 0)) + { return -1; } - if ((fd = open(filename, O_RDONLY)) == -1) { + if ((fd = open(filename, O_RDONLY)) == -1) + { return -1; } - if ((len = read(fd, buffer, buf_size)) < 0) { + if ((len = read(fd, buffer, buf_size)) < 0) + { close(fd); return -1; } - if ((close(fd) == -1)) { + if ((close(fd) == -1)) + { return -1; } - if ((len > buf_size) || (data_len != 0 && len != data_len)) { + if ((len > buf_size) || (data_len != 0 && len != data_len)) + { return -1; } @@ -278,3 +283,31 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data) return -1; } + +int dni_fan_speed_good() +{ + int rpm = 0, rpm1 = 0, speed_good = 0; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + return speed_good; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h index 8e617859..80792c62 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h @@ -39,7 +39,7 @@ #define MAX_REAR_FAN_SPEED 20500 #define MAX_FRONT_FAN_SPEED 23000 -#define MAX_PSU_FAN_SPEED 19000 +#define MAX_PSU_FAN_SPEED 20256 #define NUM_OF_SFP 48 #define NUM_OF_QSFP 6 @@ -94,6 +94,7 @@ #define TURN_OFF (0) #define TURN_ON (1) #define ALL_FAN_TRAY_EXIST (4) +#define FAN_SPEED_NORMALLY (4) #define PSU_STATUS_PRESENT (1) #define PSU_NODE_MAX_PATH_LEN (64) #define FAN_ZERO_RPM (960) @@ -133,7 +134,6 @@ #define FAN_STAT1_REG (0x05) #define FAN_STAT2_REG (0x06) #define PSU_STAT_REG (0x03) -#define ALARM_REG (0x06) #define INTERRUPT_REG (0x02) #define PORT_ADDR (0x50) @@ -170,6 +170,7 @@ 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_cpld_write_attribute(char *cpld_path, int addr, int data); int dni_lock_cpld_read_attribute(char *cpld_path, int addr); +int dni_fan_speed_good(); #define DEBUG_MODE 0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c index f5e6204b..183d15fe 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c @@ -172,10 +172,10 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max) int onlp_sysi_platform_manage_fans(void) { - int i = 0; - int new_percentage; - int highest_temp = 0; - onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS]; + int i = 0; + int new_percentage; + int highest_temp = 0; + onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS]; /* Get current temperature */ if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), &thermal[0]) != ONLP_STATUS_OK || onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), &thermal[1]) != ONLP_STATUS_OK || @@ -234,77 +234,136 @@ onlp_sysi_platform_manage_fans(void) int onlp_sysi_platform_manage_leds(void) { - /* Set front lights: fan, power supply 1, 2*/ - uint8_t addr, present_bit = 0x00; + int fantray_present = -1, rpm = 0, rpm1 = 0; + uint8_t psu1_state, psu2_state, power_state, fan_tray_interface_detected_value; + int fan_tray_pres_value, fan_board_not_present_count,i ,fan_stat_reg_mask; - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - /* Turn the fan led on or off */ - if((addr & 0xc0) == 0 ) + + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + /* Fan tray 1 */ + dev_info.addr = FAN_TRAY_1; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED); } - /* Set front light of SYS */ - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - if((addr & 0x30) == 0x30) + /* Fan tray 2 */ + dev_info.addr = FAN_TRAY_2; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED); } - /* Set front light of PSU */ - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - - if((addr & 0x06) == 0x00) + /* Fan tray 3 */ + dev_info.addr = FAN_TRAY_3; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED); } + + /* Fan tray 4 */ + dev_info.addr = FAN_TRAY_4; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); + } + else + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED); + } + + /* FRONT FAN & SYS LED */ + fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); + fan_board_not_present_count = 0; + + for(i = 0;i < 4; i++) + { + fan_stat_reg_mask = 0x01 << i; + if((fan_tray_pres_value & fan_stat_reg_mask) == fan_stat_reg_mask) + fan_board_not_present_count++; + } + + if(fan_board_not_present_count == 0 && dni_fan_speed_good() == FAN_SPEED_NORMALLY) + { + /* Green FAN operates normally */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_GREEN); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_GREEN); + } + else + { + /* Solid Amber FAN or more failed*/ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_ORANGE); + fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG); + + if(fan_tray_interface_detected_value == 0xfe || (fan_tray_pres_value & 0x10) != 0x10) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_ORANGE); + } + } + + /* Set front light of PWR */ + dev_info.bus = I2C_BUS_6; + dev_info.addr = PSU1_EEPROM; + psu1_state = dni_i2c_lock_read(NULL, &dev_info); - /* Turn on or off the FAN tray leds */ - present_bit = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); - if((present_bit & 0x01) == 0x00) + dev_info.addr = PSU2_EEPROM; + psu2_state = dni_i2c_lock_read(NULL, &dev_info); + power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG); + + if( psu1_state == 1 && psu2_state == 1 && (power_state & 0x22) == 0x22 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else if((power_state & 0x42) == 0x42 || (power_state & 0x24) == 0x24) + { + /* Blinking Amber */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE_BLINKING); } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); - } - if((present_bit & 0x02) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); - } - if((present_bit & 0x04) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); - } - if((present_bit & 0x08) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); + else if ( ( power_state & 0x42 ) != 0x42 || ( power_state & 0x24 ) != 0x24 ) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c index 22448190..b6ff50af 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c @@ -69,28 +69,28 @@ static char* cpu_coretemp_files[] = /* Static values */ static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(70000,80000,85000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) }, @@ -98,11 +98,11 @@ static onlp_thermal_info_t linfo[] = { ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS } @@ -151,5 +151,4 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) info->mcelsius = r_data / temp_base; return ONLP_STATUS_OK; -} - +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py index 336790ff..ae6dbc53 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py @@ -62,7 +62,6 @@ class OnlPlatform_x86_64_delta_ag5648_r0(OnlPlatformDelta, os.system("echo 80000 > /sys/class/hwmon/hwmon8/temp1_max_hyst") os.system("echo 60000 > /sys/class/hwmon/hwmon9/temp1_max_hyst") os.system("echo 55000 > /sys/class/hwmon/hwmon10/temp1_max_hyst") - return True From bd845a518a076acd2835d0e246aead3e33a0b458 Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Thu, 30 Nov 2017 09:57:43 +0800 Subject: [PATCH 086/244] [Quanta-LY8] Add Support for OOM: 1. Migrate device driver from opencomputeproject/oom/optoe 2. Change device driver of eeprom from 24c02 to optoe 3. Use platform data to initial port_name 4. BITMAP is set by port_name --- .../quanta/x86-64/modules/builds/optoe.c | 1154 +++++++++++++++++ .../modules/builds/quanta_platform_ly8.c | 148 ++- .../module/src/sfpi.c | 143 +- .../x86_64_quanta_ly8_rangeley_r0/__init__.py | 1 + 4 files changed, 1328 insertions(+), 118 deletions(-) create mode 100644 packages/platforms/quanta/x86-64/modules/builds/optoe.c mode change 100755 => 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/modules/builds/quanta_platform_ly8.c mode change 100755 => 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sfpi.c mode change 100755 => 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py diff --git a/packages/platforms/quanta/x86-64/modules/builds/optoe.c b/packages/platforms/quanta/x86-64/modules/builds/optoe.c new file mode 100644 index 00000000..27d7ffbd --- /dev/null +++ b/packages/platforms/quanta/x86-64/modules/builds/optoe.c @@ -0,0 +1,1154 @@ +/* + * optoe.c - A driver to read and write the EEPROM on optical transceivers + * (SFP, QSFP and similar I2C based devices) + * + * Copyright (C) 2014 Cumulus networks Inc. + * Copyright (C) 2017 Finisar Corp. + * Copyright (C) 2017 Quanta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Freeoftware Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +/* + * Description: + * a) Optical transceiver EEPROM read/write transactions are just like + * the at24 eeproms managed by the at24.c i2c driver + * b) The register/memory layout is up to 256 128 byte pages defined by + * a "pages valid" register and switched via a "page select" + * register as explained in below diagram. + * c) 256 bytes are mapped at a time. 'Lower page 00h' is the first 128 + * bytes of address space, and always references the same + * location, independent of the page select register. + * All mapped pages are mapped into the upper 128 bytes + * (offset 128-255) of the i2c address. + * d) Devices with one I2C address (eg QSFP) use I2C address 0x50 + * (A0h in the spec), and map all pages in the upper 128 bytes + * of that address. + * e) Devices with two I2C addresses (eg SFP) have 256 bytes of data + * at I2C address 0x50, and 256 bytes of data at I2C address + * 0x51 (A2h in the spec). Page selection and paged access + * only apply to this second I2C address (0x51). + * e) The address space is presented, by the driver, as a linear + * address space. For devices with one I2C client at address + * 0x50 (eg QSFP), offset 0-127 are in the lower + * half of address 50/A0h/client[0]. Offset 128-255 are in + * page 0, 256-383 are page 1, etc. More generally, offset + * 'n' resides in page (n/128)-1. ('page -1' is the lower + * half, offset 0-127). + * f) For devices with two I2C clients at address 0x50 and 0x51 (eg SFP), + * the address space places offset 0-127 in the lower + * half of 50/A0/client[0], offset 128-255 in the upper + * half. Offset 256-383 is in the lower half of 51/A2/client[1]. + * Offset 384-511 is in page 0, in the upper half of 51/A2/... + * Offset 512-639 is in page 1, in the upper half of 51/A2/... + * Offset 'n' is in page (n/128)-3 (for n > 383) + * + * One I2c addressed (eg QSFP) Memory Map + * + * 2-Wire Serial Address: 1010000x + * + * Lower Page 00h (128 bytes) + * ===================== + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * |Page Select Byte(127)| + * ===================== + * | + * | + * | + * | + * V + * ------------------------------------------------------------ + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * V V V V + * ------------ -------------- --------------- -------------- + * | | | | | | | | + * | Upper | | Upper | | Upper | | Upper | + * | Page 00h | | Page 01h | | Page 02h | | Page 03h | + * | | | (Optional) | | (Optional) | | (Optional | + * | | | | | | | for Cable | + * | | | | | | | Assemblies) | + * | ID | | AST | | User | | | + * | Fields | | Table | | EEPROM Data | | | + * | | | | | | | | + * | | | | | | | | + * | | | | | | | | + * ------------ -------------- --------------- -------------- + * + * The SFF 8436 (QSFP) spec only defines the 4 pages described above. + * In anticipation of future applications and devices, this driver + * supports access to the full architected range, 256 pages. + * + **/ + +/* #define DEBUG 1 */ + +#undef EEPROM_CLASS +#ifdef CONFIG_EEPROM_CLASS +#define EEPROM_CLASS +#endif +#ifdef CONFIG_EEPROM_CLASS_MODULE +#define EEPROM_CLASS +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef EEPROM_CLASS +#include +#endif + +#include + +/* + * The optoe driver is for read/write access to the EEPROM on standard + * I2C based optical transceivers (SFP, QSFP, etc) + * + * While based on the at24 driver, it eliminates code that supports other + * types of I2C EEPROMs, and adds support for pages accessed through the + * page-select register at offset 127. + */ + +struct optoe_platform_data { + u32 byte_len; /* size (sum of all addr) */ + u16 page_size; /* for writes */ + u8 flags; + + void (*setup)(struct memory_accessor *, void *context); + void *context; +#ifdef EEPROM_CLASS + struct eeprom_platform_data *eeprom_data; /* extra data for the eeprom_class */ +#endif + int oom_port_name; +}; + +/* fundamental unit of addressing for EEPROM */ +#define OPTOE_PAGE_SIZE 128 +/* + * Single address devices (eg QSFP) have 256 pages, plus the unpaged + * low 128 bytes. If the device does not support paging, it is + * only 2 'pages' long. + */ +#define OPTOE_ARCH_PAGES 256 +#define ONE_ADDR_EEPROM_SIZE ((1 + OPTOE_ARCH_PAGES) * OPTOE_PAGE_SIZE) +#define ONE_ADDR_EEPROM_UNPAGED_SIZE (2 * OPTOE_PAGE_SIZE) +/* + * Dual address devices (eg SFP) have 256 pages, plus the unpaged + * low 128 bytes, plus 256 bytes at 0x50. If the device does not + * support paging, it is 4 'pages' long. + */ +#define TWO_ADDR_EEPROM_SIZE ((3 + OPTOE_ARCH_PAGES) * OPTOE_PAGE_SIZE) +#define TWO_ADDR_EEPROM_UNPAGED_SIZE (4 * OPTOE_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define OPTOE_PAGE_SELECT_REG 0x7F +#define ONE_ADDR_PAGEABLE_REG 0x02 +#define ONE_ADDR_NOT_PAGEABLE (1<<2) +#define TWO_ADDR_PAGEABLE_REG 0x40 +#define TWO_ADDR_PAGEABLE (1<<4) +#define OPTOE_ID_REG 0 + +/* The maximum length of a port name */ +#define MAX_PORT_NAME_LEN 20 +struct optoe_data { + struct optoe_platform_data chip; + struct memory_accessor macc; + int use_smbus; + char port_name[MAX_PORT_NAME_LEN]; + + /* + * Lock protects against activities from other Linux tasks, + * but not from changes by other I2C masters. + */ + struct mutex lock; + struct bin_attribute bin; + struct attribute_group attr_group; + + u8 *writebuf; + unsigned write_max; + + unsigned num_addresses; + +#ifdef EEPROM_CLASS + struct eeprom_device *eeprom_dev; +#endif + + /* dev_class: ONE_ADDR (QSFP) or TWO_ADDR (SFP) */ + int dev_class; + + struct i2c_client *client[]; +}; + +typedef enum optoe_opcode { + OPTOE_READ_OP = 0, + OPTOE_WRITE_OP = 1 +} optoe_opcode_e; + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = OPTOE_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +/* + * flags to distinguish one-address (QSFP family) from two-address (SFP family) + * If the family is not known, figure it out when the device is accessed + */ +#define ONE_ADDR 1 +#define TWO_ADDR 2 + +static const struct i2c_device_id optoe_ids[] = { + { "optoe1", ONE_ADDR }, + { "optoe2", TWO_ADDR }, + { "sff8436", ONE_ADDR }, + { "24c04", TWO_ADDR }, + { /* END OF LIST */ } +}; +MODULE_DEVICE_TABLE(i2c, optoe_ids); + +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both single address (eg QSFP) and two address (eg SFP). + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ + +static uint8_t optoe_translate_offset(struct optoe_data *optoe, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = optoe->client[0]; + + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (optoe->dev_class == TWO_ADDR) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = optoe->client[1]; + *offset -= 256; + } + } + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < OPTOE_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = OPTOE_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t optoe_eeprom_read(struct optoe_data *optoe, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t optoe_eeprom_write(struct optoe_data *optoe, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > optoe->write_max) + count = optoe->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, OPTOE_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = optoe->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe, + char *buf, loff_t off, + size_t count, optoe_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + uint8_t page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = optoe_translate_offset(optoe, &phy_offset, &client); + dev_dbg(&client->dev, + "optoe_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = optoe_eeprom_write(optoe, client, &page, + OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == OPTOE_READ_OP) { + status = optoe_eeprom_read(optoe, client, + buf, phy_offset, count); + } else { + status = optoe_eeprom_write(optoe, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = optoe_eeprom_write(optoe, client, &page, + OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to 0 failed:%d!\n", ret); + /* error only if nothing has been transferred */ + if (retval == 0) retval = ret; + } + } + return retval; +} + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t optoe_page_legal(struct optoe_data *optoe, + loff_t off, size_t len) +{ + struct i2c_client *client = optoe->client[0]; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (optoe->dev_class == TWO_ADDR) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= TWO_ADDR_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= TWO_ADDR_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = optoe_eeprom_read(optoe, client, ®val, + TWO_ADDR_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & TWO_ADDR_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = TWO_ADDR_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= TWO_ADDR_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = TWO_ADDR_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } else { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= ONE_ADDR_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= ONE_ADDR_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = optoe_eeprom_read(optoe, client, ®val, + ONE_ADDR_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & ONE_ADDR_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + if (off >= ONE_ADDR_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = ONE_ADDR_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = ONE_ADDR_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + return len; +} + +static ssize_t optoe_read_write(struct optoe_data *optoe, + char *buf, loff_t off, size_t len, optoe_opcode_e opcode) +{ + struct i2c_client *client = optoe->client[0]; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + dev_dbg(&client->dev, + "optoe_read_write: off %lld len:%ld, opcode:%s\n", + off, (long int) len, (opcode == OPTOE_READ_OP) ? "r": "w"); + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&optoe->lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + status = optoe_page_legal(optoe, off, len); + if (status < 0) { + goto err; + } + len = status; + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * OPTOE_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + OPTOE_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = OPTOE_PAGE_SIZE - off; + } else { + chunk_offset = chunk_start_offset; + if (pending_len > OPTOE_PAGE_SIZE) + chunk_len = OPTOE_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = optoe_eeprom_update_client(optoe, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "optoe_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&optoe->lock); + + return retval; + +err: + mutex_unlock(&optoe->lock); + + return status; +} + +static ssize_t optoe_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = to_i2c_client(container_of(kobj, + struct device, kobj)); + struct optoe_data *optoe = i2c_get_clientdata(client); + + return optoe_read_write(optoe, buf, off, count, OPTOE_READ_OP); +} + + +static ssize_t optoe_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = to_i2c_client(container_of(kobj, + struct device, kobj)); + struct optoe_data *optoe = i2c_get_clientdata(client); + + return optoe_read_write(optoe, buf, off, count, OPTOE_WRITE_OP); +} +/*-------------------------------------------------------------------------*/ + +/* + * This lets other kernel code access the eeprom data. For example, it + * might hold a board's Ethernet address, or board-specific calibration + * data generated on the manufacturing floor. + */ + +static ssize_t optoe_macc_read(struct memory_accessor *macc, + char *buf, off_t offset, size_t count) +{ + struct optoe_data *optoe = container_of(macc, + struct optoe_data, macc); + + return optoe_read_write(optoe, buf, offset, count, OPTOE_READ_OP); +} + +static ssize_t optoe_macc_write(struct memory_accessor *macc, + const char *buf, off_t offset, size_t count) +{ + struct optoe_data *optoe = container_of(macc, + struct optoe_data, macc); + + return optoe_read_write(optoe, (char *) buf, offset, + count, OPTOE_WRITE_OP); +} + +/*-------------------------------------------------------------------------*/ + +static int optoe_remove(struct i2c_client *client) +{ + struct optoe_data *optoe; + int i; + + optoe = i2c_get_clientdata(client); + sysfs_remove_group(&client->dev.kobj, &optoe->attr_group); + sysfs_remove_bin_file(&client->dev.kobj, &optoe->bin); + + for (i = 1; i < optoe->num_addresses; i++) + i2c_unregister_device(optoe->client[i]); + +#ifdef EEPROM_CLASS + eeprom_device_unregister(optoe->eeprom_dev); +#endif + + kfree(optoe->writebuf); + kfree(optoe); + return 0; +} + +static ssize_t show_port_name(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + ssize_t count; + + mutex_lock(&optoe->lock); + count = sprintf(buf, "%s\n", optoe->port_name); + mutex_unlock(&optoe->lock); + + return count; +} + +static ssize_t set_port_name(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + char port_name[MAX_PORT_NAME_LEN]; + + /* no checking, this value is not used except by show_port_name */ + + if (sscanf(buf, "%19s", port_name) != 1) + return -EINVAL; + + mutex_lock(&optoe->lock); + strcpy(optoe->port_name, port_name); + mutex_unlock(&optoe->lock); + + return count; +} + +static DEVICE_ATTR(port_name, S_IRUGO | S_IWUSR, + show_port_name, set_port_name); + +static ssize_t show_dev_class(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + ssize_t count; + + mutex_lock(&optoe->lock); + count = sprintf(buf, "%d\n", optoe->dev_class); + mutex_unlock(&optoe->lock); + + return count; +} + +static ssize_t set_dev_class(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + int dev_class; + + /* + * dev_class is actually the number of sfp ports used, thus + * legal values are "1" (QSFP class) and "2" (SFP class) + */ + if (sscanf(buf, "%d", &dev_class) != 1 || + dev_class < 1 || dev_class > 2) + return -EINVAL; + + mutex_lock(&optoe->lock); + optoe->dev_class = dev_class; + mutex_unlock(&optoe->lock); + + return count; +} + +static DEVICE_ATTR(dev_class, S_IRUGO | S_IWUSR, + show_dev_class, set_dev_class); + +static struct attribute *optoe_attrs[] = { + &dev_attr_port_name.attr, + &dev_attr_dev_class.attr, + NULL, +}; + +static struct attribute_group optoe_attr_group = { + .attrs = optoe_attrs, +}; + +static int optoe_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int err; + int use_smbus = 0; + struct optoe_platform_data chip; + struct optoe_data *optoe; + int num_addresses = 0; + int i = 0; + + if (client->addr != 0x50) { + dev_dbg(&client->dev, "probe, bad i2c addr: 0x%x\n", + client->addr); + err = -EINVAL; + goto exit; + } + + if (client->dev.platform_data) { + chip = *(struct optoe_platform_data *)client->dev.platform_data; + dev_dbg(&client->dev, "probe, chip provided, flags:0x%x; name: %s\n", chip.flags, client->name); + } else { + if (!id->driver_data) { + err = -ENODEV; + goto exit; + } + dev_dbg(&client->dev, "probe, building chip\n"); + chip.flags = 0; + chip.setup = NULL; + chip.context = NULL; +#ifdef EEPROM_CLASS + chip.eeprom_data = NULL; +#endif + } + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + err = -EPFNOSUPPORT; + goto exit; + } + } + + + /* + * Make room for two i2c clients + */ + num_addresses = 2; + + optoe = kzalloc(sizeof(struct optoe_data) + + num_addresses * sizeof(struct i2c_client *), + GFP_KERNEL); + if (!optoe) { + err = -ENOMEM; + goto exit; + } + + mutex_init(&optoe->lock); + + /* determine whether this is a one-address or two-address module */ + if ((strcmp(client->name, "optoe1") == 0) || + (strcmp(client->name, "sff8436") == 0)) { + /* one-address (eg QSFP) family */ + optoe->dev_class = ONE_ADDR; + chip.byte_len = ONE_ADDR_EEPROM_SIZE; + num_addresses = 1; + } else if ((strcmp(client->name, "optoe2") == 0) || + (strcmp(client->name, "24c04") == 0)) { + /* SFP family */ + optoe->dev_class = TWO_ADDR; + chip.byte_len = TWO_ADDR_EEPROM_SIZE; + } else { /* those were the only two choices */ + err = -EINVAL; + goto exit; + } + + dev_dbg(&client->dev, "dev_class: %d\n", optoe->dev_class); + optoe->use_smbus = use_smbus; + optoe->chip = chip; + optoe->num_addresses = num_addresses; + + /* + * Use platform data to initial port name. + * Original port name is unitialized: strcpy(optoe->port_name, "unitialized"); + */ + sprintf(optoe->port_name, "%d", chip.oom_port_name); + + /* + * Export the EEPROM bytes through sysfs, since that's convenient. + * By default, only root should see the data (maybe passwords etc) + */ + sysfs_bin_attr_init(&optoe->bin); + optoe->bin.attr.name = "eeprom"; + optoe->bin.attr.mode = S_IRUGO; + optoe->bin.read = optoe_bin_read; + optoe->bin.size = chip.byte_len; + + optoe->macc.read = optoe_macc_read; + + if (!use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + optoe->macc.write = optoe_macc_write; + + optoe->bin.write = optoe_bin_write; + optoe->bin.attr.mode |= S_IWUSR; + + if (write_max > io_limit) + write_max = io_limit; + if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + optoe->write_max = write_max; + + /* buffer (data + address at the beginning) */ + optoe->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!optoe->writebuf) { + err = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + optoe->client[0] = client; + + /* use a dummy I2C device for two-address chips */ + for (i = 1; i < num_addresses; i++) { + optoe->client[i] = i2c_new_dummy(client->adapter, + client->addr + i); + if (!optoe->client[i]) { + dev_err(&client->dev, "address 0x%02x unavailable\n", + client->addr + i); + err = -EADDRINUSE; + goto err_struct; + } + } + + /* create the sysfs eeprom file */ + err = sysfs_create_bin_file(&client->dev.kobj, &optoe->bin); + if (err) + goto err_struct; + + optoe->attr_group = optoe_attr_group; + + err = sysfs_create_group(&client->dev.kobj, &optoe->attr_group); + if (err) { + dev_err(&client->dev, "failed to create sysfs attribute group.\n"); + goto err_struct; + } +#ifdef EEPROM_CLASS + optoe->eeprom_dev = eeprom_device_register(&client->dev, + chip.eeprom_data); + if (IS_ERR(optoe->eeprom_dev)) { + dev_err(&client->dev, "error registering eeprom device.\n"); + err = PTR_ERR(optoe->eeprom_dev); + goto err_sysfs_cleanup; + } +#endif + + i2c_set_clientdata(client, optoe); + + dev_info(&client->dev, "%zu byte %s EEPROM, %s\n", + optoe->bin.size, client->name, + optoe->bin.write ? "read/write" : "read-only"); + + if (use_smbus == I2C_SMBUS_WORD_DATA || + use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } + + if (chip.setup) + chip.setup(&optoe->macc, chip.context); + + return 0; + +#ifdef EEPROM_CLASS +err_sysfs_cleanup: + sysfs_remove_group(&client->dev.kobj, &optoe->attr_group); + sysfs_remove_bin_file(&client->dev.kobj, &optoe->bin); +#endif + +err_struct: + for (i = 1; i < num_addresses; i++) { + if (optoe->client[i]) + i2c_unregister_device(optoe->client[i]); + } + + kfree(optoe->writebuf); +exit_kfree: + kfree(optoe); +exit: + dev_dbg(&client->dev, "probe error %d\n", err); + + return err; +} + +/*-------------------------------------------------------------------------*/ + +static struct i2c_driver optoe_driver = { + .driver = { + .name = "optoe", + .owner = THIS_MODULE, + }, + .probe = optoe_probe, + .remove = optoe_remove, + .id_table = optoe_ids, +}; + +static int __init optoe_init(void) +{ + + if (!io_limit) { + pr_err("optoe: io_limit must not be 0!\n"); + return -EINVAL; + } + + io_limit = rounddown_pow_of_two(io_limit); + return i2c_add_driver(&optoe_driver); +} +module_init(optoe_init); + +static void __exit optoe_exit(void) +{ + i2c_del_driver(&optoe_driver); +} +module_exit(optoe_exit); + +MODULE_DESCRIPTION("Driver for optical transceiver (SFP, QSFP, ...) EEPROMs"); +MODULE_AUTHOR("Jonathan Tsai "); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/modules/builds/quanta_platform_ly8.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/modules/builds/quanta_platform_ly8.c old mode 100755 new mode 100644 index 30eb1679..d7e12b68 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/modules/builds/quanta_platform_ly8.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/modules/builds/quanta_platform_ly8.c @@ -52,6 +52,8 @@ enum i2c_types { i2c_type_24c02, i2c_type_emerson700, i2c_type_quanta_ly8_hwmon, + i2c_type_optoe1_QSFP, + i2c_type_optoe2_SFP, }; char *i2c_type_names[] = { @@ -65,6 +67,8 @@ char *i2c_type_names[] = { "24c02", "emerson700", "quanta_ly8_hwmon", + "optoe1", + "optoe2", }; struct i2c_init_data { @@ -72,8 +76,9 @@ struct i2c_init_data { int type; int addr; int busno; - int gpio_base; + int gpio_base; char name[I2C_NAME_SIZE]; + int oom_port_name; }; static struct i2c_init_data quanta_ly8_i2c_init_data[] = { @@ -94,54 +99,54 @@ static struct i2c_init_data quanta_ly8_i2c_init_data[] = { { .parent_bus = (0x10 + 0), .type = i2c_type_pca9554, .addr = 0x25, .name = "PCA9554(PCA9698INT)\0" }, { .parent_bus = (0x10 + 0), .type = i2c_type_pca9555, .addr = 0x24, .name = "PCA9555_3(FAN)\0" }, { .parent_bus = (0x10 + 0), .type = i2c_type_pca9555, .addr = 0x23, .name = "PCA9555_4(QSFP_EN)\0" }, - { .parent_bus = (0x20 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_1_EEPROM\0" }, - { .parent_bus = (0x20 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_2_EEPROM\0" }, - { .parent_bus = (0x20 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_3_EEPROM\0" }, - { .parent_bus = (0x20 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_4_EEPROM\0" }, - { .parent_bus = (0x20 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_5_EEPROM\0" }, - { .parent_bus = (0x20 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_6_EEPROM\0" }, - { .parent_bus = (0x20 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_7_EEPROM\0" }, - { .parent_bus = (0x20 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_8_EEPROM\0" }, - { .parent_bus = (0x28 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_9_EEPROM\0" }, - { .parent_bus = (0x28 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_10_EEPROM\0" }, - { .parent_bus = (0x28 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_11_EEPROM\0" }, - { .parent_bus = (0x28 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_12_EEPROM\0" }, - { .parent_bus = (0x28 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_13_EEPROM\0" }, - { .parent_bus = (0x28 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_14_EEPROM\0" }, - { .parent_bus = (0x28 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_15_EEPROM\0" }, - { .parent_bus = (0x28 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_16_EEPROM\0" }, - { .parent_bus = (0x30 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_17_EEPROM\0" }, - { .parent_bus = (0x30 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_18_EEPROM\0" }, - { .parent_bus = (0x30 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_19_EEPROM\0" }, - { .parent_bus = (0x30 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_20_EEPROM\0" }, - { .parent_bus = (0x30 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_21_EEPROM\0" }, - { .parent_bus = (0x30 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_22_EEPROM\0" }, - { .parent_bus = (0x30 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_23_EEPROM\0" }, - { .parent_bus = (0x30 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_24_EEPROM\0" }, - { .parent_bus = (0x38 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_25_EEPROM\0" }, - { .parent_bus = (0x38 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_26_EEPROM\0" }, - { .parent_bus = (0x38 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_27_EEPROM\0" }, - { .parent_bus = (0x38 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_28_EEPROM\0" }, - { .parent_bus = (0x38 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_29_EEPROM\0" }, - { .parent_bus = (0x38 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_30_EEPROM\0" }, - { .parent_bus = (0x38 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_31_EEPROM\0" }, - { .parent_bus = (0x38 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_32_EEPROM\0" }, - { .parent_bus = (0x40 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_33_EEPROM\0" }, - { .parent_bus = (0x40 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_34_EEPROM\0" }, - { .parent_bus = (0x40 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_35_EEPROM\0" }, - { .parent_bus = (0x40 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_36_EEPROM\0" }, - { .parent_bus = (0x40 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_37_EEPROM\0" }, - { .parent_bus = (0x40 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_38_EEPROM\0" }, - { .parent_bus = (0x40 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_39_EEPROM\0" }, - { .parent_bus = (0x40 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_40_EEPROM\0" }, - { .parent_bus = (0x48 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_41_EEPROM\0" }, - { .parent_bus = (0x48 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_42_EEPROM\0" }, - { .parent_bus = (0x48 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_43_EEPROM\0" }, - { .parent_bus = (0x48 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_44_EEPROM\0" }, - { .parent_bus = (0x48 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_45_EEPROM\0" }, - { .parent_bus = (0x48 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_46_EEPROM\0" }, - { .parent_bus = (0x48 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_47_EEPROM\0" }, - { .parent_bus = (0x48 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "SFP_48_EEPROM\0" }, + { .parent_bus = (0x20 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_1_EEPROM\0", .oom_port_name = 1 }, + { .parent_bus = (0x20 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_2_EEPROM\0", .oom_port_name = 2 }, + { .parent_bus = (0x20 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_3_EEPROM\0", .oom_port_name = 3 }, + { .parent_bus = (0x20 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_4_EEPROM\0", .oom_port_name = 4 }, + { .parent_bus = (0x20 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_5_EEPROM\0", .oom_port_name = 5 }, + { .parent_bus = (0x20 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_6_EEPROM\0", .oom_port_name = 6 }, + { .parent_bus = (0x20 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_7_EEPROM\0", .oom_port_name = 7 }, + { .parent_bus = (0x20 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_8_EEPROM\0", .oom_port_name = 8 }, + { .parent_bus = (0x28 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_9_EEPROM\0", .oom_port_name = 9 }, + { .parent_bus = (0x28 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_10_EEPROM\0", .oom_port_name = 10 }, + { .parent_bus = (0x28 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_11_EEPROM\0", .oom_port_name = 11 }, + { .parent_bus = (0x28 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_12_EEPROM\0", .oom_port_name = 12 }, + { .parent_bus = (0x28 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_13_EEPROM\0", .oom_port_name = 13 }, + { .parent_bus = (0x28 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_14_EEPROM\0", .oom_port_name = 14 }, + { .parent_bus = (0x28 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_15_EEPROM\0", .oom_port_name = 15 }, + { .parent_bus = (0x28 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_16_EEPROM\0", .oom_port_name = 16 }, + { .parent_bus = (0x30 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_17_EEPROM\0", .oom_port_name = 17 }, + { .parent_bus = (0x30 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_18_EEPROM\0", .oom_port_name = 18 }, + { .parent_bus = (0x30 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_19_EEPROM\0", .oom_port_name = 19 }, + { .parent_bus = (0x30 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_20_EEPROM\0", .oom_port_name = 20 }, + { .parent_bus = (0x30 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_21_EEPROM\0", .oom_port_name = 21 }, + { .parent_bus = (0x30 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_22_EEPROM\0", .oom_port_name = 22 }, + { .parent_bus = (0x30 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_23_EEPROM\0", .oom_port_name = 23 }, + { .parent_bus = (0x30 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_24_EEPROM\0", .oom_port_name = 24 }, + { .parent_bus = (0x38 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_25_EEPROM\0", .oom_port_name = 25 }, + { .parent_bus = (0x38 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_26_EEPROM\0", .oom_port_name = 26 }, + { .parent_bus = (0x38 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_27_EEPROM\0", .oom_port_name = 27 }, + { .parent_bus = (0x38 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_28_EEPROM\0", .oom_port_name = 28 }, + { .parent_bus = (0x38 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_29_EEPROM\0", .oom_port_name = 29 }, + { .parent_bus = (0x38 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_30_EEPROM\0", .oom_port_name = 30 }, + { .parent_bus = (0x38 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_31_EEPROM\0", .oom_port_name = 31 }, + { .parent_bus = (0x38 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_32_EEPROM\0", .oom_port_name = 32 }, + { .parent_bus = (0x40 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_33_EEPROM\0", .oom_port_name = 33 }, + { .parent_bus = (0x40 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_34_EEPROM\0", .oom_port_name = 34 }, + { .parent_bus = (0x40 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_35_EEPROM\0", .oom_port_name = 35 }, + { .parent_bus = (0x40 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_36_EEPROM\0", .oom_port_name = 36 }, + { .parent_bus = (0x40 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_37_EEPROM\0", .oom_port_name = 37 }, + { .parent_bus = (0x40 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_38_EEPROM\0", .oom_port_name = 38 }, + { .parent_bus = (0x40 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_39_EEPROM\0", .oom_port_name = 39 }, + { .parent_bus = (0x40 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_40_EEPROM\0", .oom_port_name = 40 }, + { .parent_bus = (0x48 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_41_EEPROM\0", .oom_port_name = 41 }, + { .parent_bus = (0x48 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_42_EEPROM\0", .oom_port_name = 42 }, + { .parent_bus = (0x48 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_43_EEPROM\0", .oom_port_name = 43 }, + { .parent_bus = (0x48 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_44_EEPROM\0", .oom_port_name = 44 }, + { .parent_bus = (0x48 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_45_EEPROM\0", .oom_port_name = 45 }, + { .parent_bus = (0x48 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_46_EEPROM\0", .oom_port_name = 46 }, + { .parent_bus = (0x48 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_47_EEPROM\0", .oom_port_name = 47 }, + { .parent_bus = (0x48 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_48_EEPROM\0", .oom_port_name = 48 }, { .parent_bus = (0x10 + 3), .type = i2c_type_pca9698, .addr = 0x23, .name = "PCA9698(SFP_1-8)\0" }, { .parent_bus = (0x10 + 3), .type = i2c_type_pca9698, .addr = 0x21, .name = "PCA9698(SFP_9-16)\0" }, @@ -151,10 +156,10 @@ static struct i2c_init_data quanta_ly8_i2c_init_data[] = { { .parent_bus = (0x10 + 4), .type = i2c_type_pca9698, .addr = 0x25, .name = "PCA9698(SFP_41-48)\0" }, { .parent_bus = (0x10 + 5), .type = i2c_type_pca9548, .addr = 0x76, .busno = 0x50, .name = "PCA9548_8\0" }, - { .parent_bus = (0x50 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_1_EEPROM\0" }, - { .parent_bus = (0x50 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_2_EEPROM\0" }, - { .parent_bus = (0x50 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_3_EEPROM\0" }, - { .parent_bus = (0x50 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_4_EEPROM\0" }, + { .parent_bus = (0x50 + 0), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_1_EEPROM\0", .oom_port_name = 49 }, + { .parent_bus = (0x50 + 1), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_2_EEPROM\0", .oom_port_name = 50 }, + { .parent_bus = (0x50 + 2), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_3_EEPROM\0", .oom_port_name = 51 }, + { .parent_bus = (0x50 + 3), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_4_EEPROM\0", .oom_port_name = 52 }, { .parent_bus = (0x10 + 5), .type = i2c_type_pca9555, .addr = 0x24, .name = "PCA9555_1(LED)\0" }, { .parent_bus = (0x10 + 6), .type = i2c_type_pca9555, .addr = 0x23, .name = "PCA9555_2(QSFP)\0" }, @@ -162,8 +167,8 @@ static struct i2c_init_data quanta_ly8_i2c_init_data[] = { /* QSFP+ DB */ { .parent_bus = (0x10 + 7), .type = i2c_type_pca9555, .addr = 0x23, .name = "PCA9555(QDB)\0" }, { .parent_bus = (0x10 + 7), .type = i2c_type_pca9546, .addr = 0x76, .busno = 0x58, .name = "PCA9546(QDB)\0" }, - { .parent_bus = (0x58 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QDB_QSFP_1_EEPROM\0" }, - { .parent_bus = (0x58 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QDB_QSFP_2_EEPROM\0" }, + { .parent_bus = (0x58 + 0), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QDB_QSFP_1_EEPROM\0", .oom_port_name = 53 }, + { .parent_bus = (0x58 + 1), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QDB_QSFP_2_EEPROM\0", .oom_port_name = 54 }, { .parent_bus = (0x00 + 0), .type = i2c_type_pca9546, .addr = 0x72, .busno = 0x18, .name = "PCA9546\0" }, { .parent_bus = (0x18 + 0), .type = i2c_type_emerson700, .addr = 0x6f, .name = "PSU_1\0" }, /* RPSU 1 */ @@ -244,9 +249,31 @@ static inline struct pca953x_platform_data *pca953x_platform_data_get(int type, return &platform_data; } +struct optoe_platform_data { + u32 byte_len; /* size (sum of all addr) */ + u16 page_size; /* for writes */ + u8 flags; + + void (*setup)(struct memory_accessor *, void *context); + void *context; + + int oom_port_name; +}; + +static inline struct optoe_platform_data *optoe_platform_data_get(int port_name) { + static struct optoe_platform_data platform_data; + + platform_data = (struct optoe_platform_data) { + .oom_port_name = port_name, + }; + + return &platform_data; +} + static inline struct i2c_board_info *i2c_board_info_get(struct i2c_init_data data) { struct pca954x_platform_data *mux_platform_data; struct pca953x_platform_data *gpio_platform_data; + struct optoe_platform_data *oom_platform_data; static struct i2c_board_info board_info; switch(data.type) { @@ -274,6 +301,17 @@ static inline struct i2c_board_info *i2c_board_info_get(struct i2c_init_data dat .platform_data = gpio_platform_data, }; break; + case i2c_type_optoe1_QSFP: + case i2c_type_optoe2_SFP: + oom_platform_data = optoe_platform_data_get(data.oom_port_name); + if(oom_platform_data == NULL) { + return (struct i2c_board_info *) NULL; + } + + board_info = (struct i2c_board_info) { + .platform_data = oom_platform_data, + }; + break; case i2c_type_rtc: case i2c_type_spd: diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sfpi.c old mode 100755 new mode 100644 index 236f1f82..9ee5fb0c --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sfpi.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/sfpi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "x86_64_quanta_ly8_rangeley_log.h" #include @@ -40,69 +41,84 @@ typedef struct sfpmap_s { int port; int present_gpio; const char* reset_gpio; - const char* eeprom; + const char* port_path; const char* dom; } sfpmap_t; static sfpmap_t sfpmap__[] = { - { 1, QUANTA_LY8_PCA9698_1_GPIO_SFP_1_PRSNT_N /* 168 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-32/32-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-32/32-0051/eeprom" }, - { 2, QUANTA_LY8_PCA9698_1_GPIO_SFP_2_PRSNT_N /* 172 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-33/33-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-33/33-0051/eeprom" }, - { 3, QUANTA_LY8_PCA9698_1_GPIO_SFP_3_PRSNT_N /* 176 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-34/34-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-34/34-0051/eeprom" }, - { 4, QUANTA_LY8_PCA9698_1_GPIO_SFP_4_PRSNT_N /* 180 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-35/35-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-35/35-0051/eeprom" }, - { 5, QUANTA_LY8_PCA9698_1_GPIO_SFP_5_PRSNT_N /* 184 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-36/36-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-36/36-0051/eeprom" }, - { 6, QUANTA_LY8_PCA9698_1_GPIO_SFP_6_PRSNT_N /* 188 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-37/37-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-37/37-0051/eeprom" }, - { 7, QUANTA_LY8_PCA9698_1_GPIO_SFP_7_PRSNT_N /* 192 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-38/38-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-38/38-0051/eeprom" }, - { 8, QUANTA_LY8_PCA9698_1_GPIO_SFP_8_PRSNT_N /* 196 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-39/39-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-39/39-0051/eeprom" }, - { 9, QUANTA_LY8_PCA9698_2_GPIO_SFP_9_PRSNT_N /* 208 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-40/40-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-40/40-0051/eeprom" }, - { 10, QUANTA_LY8_PCA9698_2_GPIO_SFP_10_PRSNT_N /* 212 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-41/41-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-41/41-0051/eeprom" }, - { 11, QUANTA_LY8_PCA9698_2_GPIO_SFP_11_PRSNT_N /* 216 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-42/42-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-42/42-0051/eeprom" }, - { 12, QUANTA_LY8_PCA9698_2_GPIO_SFP_12_PRSNT_N /* 220 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-43/43-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-43/43-0051/eeprom" }, - { 13, QUANTA_LY8_PCA9698_2_GPIO_SFP_13_PRSNT_N /* 224 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-44/44-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-44/44-0051/eeprom" }, - { 14, QUANTA_LY8_PCA9698_2_GPIO_SFP_14_PRSNT_N /* 228 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-45/45-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-45/45-0051/eeprom" }, - { 15, QUANTA_LY8_PCA9698_2_GPIO_SFP_15_PRSNT_N /* 232 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-46/46-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-46/46-0051/eeprom" }, - { 16, QUANTA_LY8_PCA9698_2_GPIO_SFP_16_PRSNT_N /* 236 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-47/47-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-47/47-0051/eeprom" }, - { 17, QUANTA_LY8_PCA9698_3_GPIO_SFP_17_PRSNT_N /* 248 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-48/48-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-48/48-0051/eeprom" }, - { 18, QUANTA_LY8_PCA9698_3_GPIO_SFP_18_PRSNT_N /* 252 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-49/49-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-49/49-0051/eeprom" }, - { 19, QUANTA_LY8_PCA9698_3_GPIO_SFP_19_PRSNT_N /* 256 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-50/50-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-50/50-0051/eeprom" }, - { 20, QUANTA_LY8_PCA9698_3_GPIO_SFP_20_PRSNT_N /* 260 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-51/51-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-51/51-0051/eeprom" }, - { 21, QUANTA_LY8_PCA9698_3_GPIO_SFP_21_PRSNT_N /* 264 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-52/52-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-52/52-0051/eeprom" }, - { 22, QUANTA_LY8_PCA9698_3_GPIO_SFP_22_PRSNT_N /* 268 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-53/53-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-53/53-0051/eeprom" }, - { 23, QUANTA_LY8_PCA9698_3_GPIO_SFP_23_PRSNT_N /* 272 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-54/54-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-54/54-0051/eeprom" }, - { 24, QUANTA_LY8_PCA9698_3_GPIO_SFP_24_PRSNT_N /* 276 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-55/55-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-55/55-0051/eeprom" }, - { 25, QUANTA_LY8_PCA9698_4_GPIO_SFP_25_PRSNT_N /* 288 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-56/56-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-56/56-0051/eeprom" }, - { 26, QUANTA_LY8_PCA9698_4_GPIO_SFP_26_PRSNT_N /* 292 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-57/57-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-57/57-0051/eeprom" }, - { 27, QUANTA_LY8_PCA9698_4_GPIO_SFP_27_PRSNT_N /* 296 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-58/58-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-58/58-0051/eeprom" }, - { 28, QUANTA_LY8_PCA9698_4_GPIO_SFP_28_PRSNT_N /* 300 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-59/59-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-59/59-0051/eeprom" }, - { 29, QUANTA_LY8_PCA9698_4_GPIO_SFP_29_PRSNT_N /* 304 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-60/60-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-60/60-0051/eeprom" }, - { 30, QUANTA_LY8_PCA9698_4_GPIO_SFP_30_PRSNT_N /* 308 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-61/61-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-61/61-0051/eeprom" }, - { 31, QUANTA_LY8_PCA9698_4_GPIO_SFP_31_PRSNT_N /* 312 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-62/62-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-62/62-0051/eeprom" }, - { 32, QUANTA_LY8_PCA9698_4_GPIO_SFP_32_PRSNT_N /* 316 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-63/63-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-63/63-0051/eeprom" }, - { 33, QUANTA_LY8_PCA9698_5_GPIO_SFP_33_PRSNT_N /* 328 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-64/64-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-64/64-0051/eeprom" }, - { 34, QUANTA_LY8_PCA9698_5_GPIO_SFP_34_PRSNT_N /* 332 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-65/65-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-65/65-0051/eeprom" }, - { 35, QUANTA_LY8_PCA9698_5_GPIO_SFP_35_PRSNT_N /* 336 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-66/66-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-66/66-0051/eeprom" }, - { 36, QUANTA_LY8_PCA9698_5_GPIO_SFP_36_PRSNT_N /* 340 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-67/67-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-67/67-0051/eeprom" }, - { 37, QUANTA_LY8_PCA9698_5_GPIO_SFP_37_PRSNT_N /* 344 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-68/68-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-68/68-0051/eeprom" }, - { 38, QUANTA_LY8_PCA9698_5_GPIO_SFP_38_PRSNT_N /* 348 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-69/69-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-69/69-0051/eeprom" }, - { 39, QUANTA_LY8_PCA9698_5_GPIO_SFP_39_PRSNT_N /* 352 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-70/70-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-70/70-0051/eeprom" }, - { 40, QUANTA_LY8_PCA9698_5_GPIO_SFP_40_PRSNT_N /* 356 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-71/71-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-71/71-0051/eeprom" }, - { 41, QUANTA_LY8_PCA9698_6_GPIO_SFP_41_PRSNT_N /* 368 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-72/72-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-72/72-0051/eeprom" }, - { 42, QUANTA_LY8_PCA9698_6_GPIO_SFP_42_PRSNT_N /* 372 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-73/73-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-73/73-0051/eeprom" }, - { 43, QUANTA_LY8_PCA9698_6_GPIO_SFP_43_PRSNT_N /* 376 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-74/74-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-74/74-0051/eeprom" }, - { 44, QUANTA_LY8_PCA9698_6_GPIO_SFP_44_PRSNT_N /* 380 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-75/75-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-75/75-0051/eeprom" }, - { 45, QUANTA_LY8_PCA9698_6_GPIO_SFP_45_PRSNT_N /* 384 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-76/76-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-76/76-0051/eeprom" }, - { 46, QUANTA_LY8_PCA9698_6_GPIO_SFP_46_PRSNT_N /* 388 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-77/77-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-77/77-0051/eeprom" }, - { 47, QUANTA_LY8_PCA9698_6_GPIO_SFP_47_PRSNT_N /* 392 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-78/78-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-78/78-0051/eeprom" }, - { 48, QUANTA_LY8_PCA9698_6_GPIO_SFP_48_PRSNT_N /* 396 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-79/79-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-79/79-0051/eeprom" }, - { 49, QUANTA_LY8_QSFP_GPIO_PRSNT_49_N /* 426 */, "/sys/class/gpio/gpio424/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-80/80-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-80/80-0051/eeprom" }, - { 50, QUANTA_LY8_QSFP_GPIO_PRSNT_50_N /* 430 */, "/sys/class/gpio/gpio428/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-81/81-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-81/81-0051/eeprom" }, - { 51, QUANTA_LY8_QSFP_GPIO_PRSNT_51_N /* 434 */, "/sys/class/gpio/gpio432/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-82/82-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-82/82-0051/eeprom" }, - { 52, QUANTA_LY8_QSFP_GPIO_PRSNT_52_N /* 438 */, "/sys/class/gpio/gpio436/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-83/83-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-83/83-0051/eeprom" }, - { 69, QUANTA_LY8_QSFP_QDB_GPIO_PRSNT_69_N /* 442 */, "/sys/class/gpio/gpio442/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-88/88-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-88/88-0051/eeprom" }, - { 70, QUANTA_LY8_QSFP_QDB_GPIO_PRSNT_70_N /* 446 */, "/sys/class/gpio/gpio446/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-89/89-0050/eeprom", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-89/89-0051/eeprom" }, + { }, /* Not used */ + { 1, QUANTA_LY8_PCA9698_1_GPIO_SFP_1_PRSNT_N /* 168 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-32/32-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-32/32-0051/eeprom" }, + { 2, QUANTA_LY8_PCA9698_1_GPIO_SFP_2_PRSNT_N /* 172 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-33/33-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-33/33-0051/eeprom" }, + { 3, QUANTA_LY8_PCA9698_1_GPIO_SFP_3_PRSNT_N /* 176 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-34/34-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-34/34-0051/eeprom" }, + { 4, QUANTA_LY8_PCA9698_1_GPIO_SFP_4_PRSNT_N /* 180 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-35/35-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-35/35-0051/eeprom" }, + { 5, QUANTA_LY8_PCA9698_1_GPIO_SFP_5_PRSNT_N /* 184 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-36/36-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-36/36-0051/eeprom" }, + { 6, QUANTA_LY8_PCA9698_1_GPIO_SFP_6_PRSNT_N /* 188 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-37/37-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-37/37-0051/eeprom" }, + { 7, QUANTA_LY8_PCA9698_1_GPIO_SFP_7_PRSNT_N /* 192 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-38/38-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-38/38-0051/eeprom" }, + { 8, QUANTA_LY8_PCA9698_1_GPIO_SFP_8_PRSNT_N /* 196 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-39/39-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-39/39-0051/eeprom" }, + { 9, QUANTA_LY8_PCA9698_2_GPIO_SFP_9_PRSNT_N /* 208 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-40/40-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-40/40-0051/eeprom" }, + { 10, QUANTA_LY8_PCA9698_2_GPIO_SFP_10_PRSNT_N /* 212 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-41/41-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-41/41-0051/eeprom" }, + { 11, QUANTA_LY8_PCA9698_2_GPIO_SFP_11_PRSNT_N /* 216 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-42/42-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-42/42-0051/eeprom" }, + { 12, QUANTA_LY8_PCA9698_2_GPIO_SFP_12_PRSNT_N /* 220 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-43/43-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-43/43-0051/eeprom" }, + { 13, QUANTA_LY8_PCA9698_2_GPIO_SFP_13_PRSNT_N /* 224 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-44/44-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-44/44-0051/eeprom" }, + { 14, QUANTA_LY8_PCA9698_2_GPIO_SFP_14_PRSNT_N /* 228 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-45/45-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-45/45-0051/eeprom" }, + { 15, QUANTA_LY8_PCA9698_2_GPIO_SFP_15_PRSNT_N /* 232 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-46/46-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-46/46-0051/eeprom" }, + { 16, QUANTA_LY8_PCA9698_2_GPIO_SFP_16_PRSNT_N /* 236 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-47/47-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-47/47-0051/eeprom" }, + { 17, QUANTA_LY8_PCA9698_3_GPIO_SFP_17_PRSNT_N /* 248 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-48/48-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-48/48-0051/eeprom" }, + { 18, QUANTA_LY8_PCA9698_3_GPIO_SFP_18_PRSNT_N /* 252 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-49/49-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-49/49-0051/eeprom" }, + { 19, QUANTA_LY8_PCA9698_3_GPIO_SFP_19_PRSNT_N /* 256 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-50/50-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-50/50-0051/eeprom" }, + { 20, QUANTA_LY8_PCA9698_3_GPIO_SFP_20_PRSNT_N /* 260 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-51/51-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-51/51-0051/eeprom" }, + { 21, QUANTA_LY8_PCA9698_3_GPIO_SFP_21_PRSNT_N /* 264 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-52/52-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-52/52-0051/eeprom" }, + { 22, QUANTA_LY8_PCA9698_3_GPIO_SFP_22_PRSNT_N /* 268 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-53/53-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-53/53-0051/eeprom" }, + { 23, QUANTA_LY8_PCA9698_3_GPIO_SFP_23_PRSNT_N /* 272 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-54/54-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-54/54-0051/eeprom" }, + { 24, QUANTA_LY8_PCA9698_3_GPIO_SFP_24_PRSNT_N /* 276 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-55/55-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-55/55-0051/eeprom" }, + { 25, QUANTA_LY8_PCA9698_4_GPIO_SFP_25_PRSNT_N /* 288 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-56/56-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-56/56-0051/eeprom" }, + { 26, QUANTA_LY8_PCA9698_4_GPIO_SFP_26_PRSNT_N /* 292 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-57/57-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-57/57-0051/eeprom" }, + { 27, QUANTA_LY8_PCA9698_4_GPIO_SFP_27_PRSNT_N /* 296 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-58/58-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-58/58-0051/eeprom" }, + { 28, QUANTA_LY8_PCA9698_4_GPIO_SFP_28_PRSNT_N /* 300 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-59/59-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-59/59-0051/eeprom" }, + { 29, QUANTA_LY8_PCA9698_4_GPIO_SFP_29_PRSNT_N /* 304 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-60/60-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-60/60-0051/eeprom" }, + { 30, QUANTA_LY8_PCA9698_4_GPIO_SFP_30_PRSNT_N /* 308 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-61/61-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-61/61-0051/eeprom" }, + { 31, QUANTA_LY8_PCA9698_4_GPIO_SFP_31_PRSNT_N /* 312 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-62/62-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-62/62-0051/eeprom" }, + { 32, QUANTA_LY8_PCA9698_4_GPIO_SFP_32_PRSNT_N /* 316 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-63/63-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-63/63-0051/eeprom" }, + { 33, QUANTA_LY8_PCA9698_5_GPIO_SFP_33_PRSNT_N /* 328 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-64/64-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-64/64-0051/eeprom" }, + { 34, QUANTA_LY8_PCA9698_5_GPIO_SFP_34_PRSNT_N /* 332 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-65/65-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-65/65-0051/eeprom" }, + { 35, QUANTA_LY8_PCA9698_5_GPIO_SFP_35_PRSNT_N /* 336 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-66/66-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-66/66-0051/eeprom" }, + { 36, QUANTA_LY8_PCA9698_5_GPIO_SFP_36_PRSNT_N /* 340 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-67/67-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-67/67-0051/eeprom" }, + { 37, QUANTA_LY8_PCA9698_5_GPIO_SFP_37_PRSNT_N /* 344 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-68/68-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-68/68-0051/eeprom" }, + { 38, QUANTA_LY8_PCA9698_5_GPIO_SFP_38_PRSNT_N /* 348 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-69/69-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-69/69-0051/eeprom" }, + { 39, QUANTA_LY8_PCA9698_5_GPIO_SFP_39_PRSNT_N /* 352 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-70/70-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-70/70-0051/eeprom" }, + { 40, QUANTA_LY8_PCA9698_5_GPIO_SFP_40_PRSNT_N /* 356 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-71/71-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-71/71-0051/eeprom" }, + { 41, QUANTA_LY8_PCA9698_6_GPIO_SFP_41_PRSNT_N /* 368 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-72/72-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-72/72-0051/eeprom" }, + { 42, QUANTA_LY8_PCA9698_6_GPIO_SFP_42_PRSNT_N /* 372 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-73/73-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-73/73-0051/eeprom" }, + { 43, QUANTA_LY8_PCA9698_6_GPIO_SFP_43_PRSNT_N /* 376 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-74/74-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-74/74-0051/eeprom" }, + { 44, QUANTA_LY8_PCA9698_6_GPIO_SFP_44_PRSNT_N /* 380 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-75/75-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-75/75-0051/eeprom" }, + { 45, QUANTA_LY8_PCA9698_6_GPIO_SFP_45_PRSNT_N /* 384 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-76/76-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-76/76-0051/eeprom" }, + { 46, QUANTA_LY8_PCA9698_6_GPIO_SFP_46_PRSNT_N /* 388 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-77/77-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-77/77-0051/eeprom" }, + { 47, QUANTA_LY8_PCA9698_6_GPIO_SFP_47_PRSNT_N /* 392 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-78/78-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-78/78-0051/eeprom" }, + { 48, QUANTA_LY8_PCA9698_6_GPIO_SFP_48_PRSNT_N /* 396 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-79/79-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-79/79-0051/eeprom" }, + { 49, QUANTA_LY8_QSFP_GPIO_PRSNT_49_N /* 426 */, "/sys/class/gpio/gpio424/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-80/80-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-80/80-0051/eeprom" }, + { 50, QUANTA_LY8_QSFP_GPIO_PRSNT_50_N /* 430 */, "/sys/class/gpio/gpio428/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-81/81-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-81/81-0051/eeprom" }, + { 51, QUANTA_LY8_QSFP_GPIO_PRSNT_51_N /* 434 */, "/sys/class/gpio/gpio432/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-82/82-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-82/82-0051/eeprom" }, + { 52, QUANTA_LY8_QSFP_GPIO_PRSNT_52_N /* 438 */, "/sys/class/gpio/gpio436/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-83/83-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-83/83-0051/eeprom" }, + { 69, QUANTA_LY8_QSFP_QDB_GPIO_PRSNT_69_N /* 442 */, "/sys/class/gpio/gpio442/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-88/88-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-88/88-0051/eeprom" }, + { 70, QUANTA_LY8_QSFP_QDB_GPIO_PRSNT_70_N /* 446 */, "/sys/class/gpio/gpio446/value", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-89/89-0050/%s", "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-89/89-0051/eeprom" }, }; #define SFP_GET(_port) (sfpmap__ + _port) +#define SFP_MAX_PORT_NUM 48 +#define QSFP_MAX_PORT_NUM 6 +#define MAX_PORT_NUM SFP_MAX_PORT_NUM + QSFP_MAX_PORT_NUM +#define MAX_SFP_PATH 128 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +static char*sfp_get_port_path(int port, char *node_name) +{ + sfpmap_t* sfp = SFP_GET(port); + + sprintf(sfp_node_path, sfp->port_path, node_name); + + return sfp_node_path; +} int onlp_sfpi_init(void) @@ -126,8 +142,8 @@ onlp_sfpi_init(void) } } - for(i = 0; i < 54; i++) { - sfp = SFP_GET(i); + for(i = 0; i < MAX_PORT_NUM; i++) { + sfp = SFP_GET(i + 1); onlp_gpio_export(sfp->present_gpio, ONLP_GPIO_DIRECTION_IN); } @@ -137,10 +153,12 @@ onlp_sfpi_init(void) int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) { - int p; + int i, port_name; - for(p = 0; p < 54; p++) { - AIM_BITMAP_SET(bmap, p); + for(i = 0; i < MAX_PORT_NUM; i++) { + if(onlp_file_read_int(&port_name, sfp_get_port_path(i + 1, "port_name")) == 0) { + AIM_BITMAP_SET(bmap, port_name); + } } return ONLP_STATUS_OK; @@ -162,7 +180,7 @@ onlp_sfpi_is_present(int port) * If we can open and read a byte from the EEPROM file * then we consider it present. */ - int fd = open(sfp->eeprom, O_RDONLY); + int fd = open(sfp_get_port_path(port, "eeprom"), O_RDONLY); if (fd < 0) { /* Not Present */ return 0; @@ -186,8 +204,7 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - sfpmap_t* sfp = SFP_GET(port); - return onlplib_sfp_eeprom_read_file(sfp->eeprom, data); + return onlplib_sfp_eeprom_read_file(sfp_get_port_path(port, "eeprom"), data); } int diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py old mode 100755 new mode 100644 index 8a203a5e..268c0d5f --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py @@ -18,6 +18,7 @@ class OnlPlatform_x86_64_quanta_ly8_rangeley_r0(OnlPlatformQuanta, def baseconfig(self): self.insmod("emerson700") self.insmod("quanta_hwmon_ly_series") + self.insmod("optoe") self.insmod("quanta_platform_ly8") # make ds1339 as default rtc From 446d38ac8cf60bc42e0f824181c4bb4df22b82fd Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 12 Dec 2017 11:40:07 +0800 Subject: [PATCH 087/244] [as5822-54x] Fix PSU un-recognized issue --- .../builds/x86-64-accton-as5822-54x-psu.c | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c index 8bc4398d..4d2e8a28 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c @@ -224,6 +224,55 @@ static struct i2c_driver as5822_54x_psu_driver = { .address_list = normal_i2c, }; +static int as5822_54x_psu_read_byte(struct i2c_client *client, u8 command, u8 *data) +{ + int status = 0; + int retry_count = 5; + + while (retry_count) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(10); + retry_count--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + +abort: + return status; +} + +static int as5822_54x_psu_read_bytes(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int ret = 0; + + while (data_len) { + ssize_t status; + + status = as5822_54x_psu_read_byte(client, command, data); + if (status <= 0) { + ret = status; + break; + } + + data += 1; + command += 1; + data_len -= 1; + } + + return ret; +} + static int as5822_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len) { @@ -284,7 +333,7 @@ static struct as5822_54x_psu_data *as5822_54x_psu_update_device(struct device *d if (IS_PRESENT(data->index, data->status)) { /* Read model name */ - status = as5822_54x_psu_read_block(client, MODEL_NAME_REG_OFFSET, data->model_name, + status = as5822_54x_psu_read_bytes(client, MODEL_NAME_REG_OFFSET, data->model_name, ARRAY_SIZE(data->model_name)-1); if (status < 0) { @@ -300,7 +349,7 @@ static struct as5822_54x_psu_data *as5822_54x_psu_update_device(struct device *d } /* Read serial number */ - status = as5822_54x_psu_read_block(client, SERIAL_NUM_REG_OFFSET, data->serial, + status = as5822_54x_psu_read_bytes(client, SERIAL_NUM_REG_OFFSET, data->serial, ARRAY_SIZE(data->serial)-1); if (status < 0) { From 18bf47b63d51cd805ee36cae3798bab258e97302 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 12 Dec 2017 20:52:47 +0000 Subject: [PATCH 088/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 90a1d56c..fc3dc6c3 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 90a1d56c57385e5206c8452ef155b92bba06e26b +Subproject commit fc3dc6c3c3989d5fd7b78b3b53074ddf2b1ee194 From e474ad2175ea86ae999f1019eec62084a3ccaaf3 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 14 Dec 2017 14:52:09 +0000 Subject: [PATCH 089/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index fc3dc6c3..03cd2a46 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit fc3dc6c3c3989d5fd7b78b3b53074ddf2b1ee194 +Subproject commit 03cd2a4666ac46b68234b2a9976bcdfe30dfbb4a From e70f4cea37502bf977f3643c79f6c59e738910ab Mon Sep 17 00:00:00 2001 From: chenglin-tsai Date: Fri, 15 Dec 2017 11:25:35 +0800 Subject: [PATCH 090/244] Add new platform: AGC5648S --- .../x86-64/x86-64-delta-agc5648s/.gitignore | 3 + .../x86-64/x86-64-delta-agc5648s/Makefile | 1 + .../x86-64-delta-agc5648s/modules/Makefile | 1 + .../x86-64-delta-agc5648s/modules/PKG.yml | 1 + .../x86-64-delta-agc5648s/onlp/Makefile | 1 + .../x86-64/x86-64-delta-agc5648s/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 +++ .../lib/libonlp-x86-64-delta-agc5648s-r0.mk | 10 + .../onlp/builds/onlpdump/Makefile | 46 +++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 10 + .../onlp/builds/src/module/auto/make.mk | 10 + .../src/module/auto/x86_64_delta_agc5648s.yml | 55 +++ .../x86_64_delta_agc5648s.x | 16 + .../x86_64_delta_agc5648s_config.h | 155 ++++++++ .../x86_64_delta_agc5648s_dox.h | 26 ++ .../x86_64_delta_agc5648s_porting.h | 107 ++++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 12 + .../onlp/builds/src/module/src/fani.c | 301 ++++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 331 ++++++++++++++++++ .../onlp/builds/src/module/src/make.mk | 11 + .../onlp/builds/src/module/src/platform_lib.c | 238 +++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 190 ++++++++++ .../onlp/builds/src/module/src/psui.c | 154 ++++++++ .../onlp/builds/src/module/src/sfpi.c | 295 ++++++++++++++++ .../onlp/builds/src/module/src/sysi.c | 235 +++++++++++++ .../onlp/builds/src/module/src/thermali.c | 143 ++++++++ .../module/src/x86_64_delta_agc5648s_config.c | 93 +++++ .../module/src/x86_64_delta_agc5648s_enums.c | 12 + .../module/src/x86_64_delta_agc5648s_int.h | 13 + .../module/src/x86_64_delta_agc5648s_log.c | 21 ++ .../module/src/x86_64_delta_agc5648s_log.h | 14 + .../module/src/x86_64_delta_agc5648s_module.c | 26 ++ .../module/src/x86_64_delta_agc5648s_ucli.c | 64 ++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 2 + .../r0/src/lib/x86-64-delta-agc5648s-r0.yml | 30 ++ .../x86_64_delta_agc5648s_r0/__init__.py | 18 + 41 files changed, 2706 insertions(+) create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/.gitignore create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/libonlp-x86-64-delta-agc5648s-r0.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/onlpdump/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.module create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/x86_64_delta_agc5648s.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s.x create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_dox.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_porting.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_enums.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_int.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_module.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_ucli.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/lib/x86-64-delta-agc5648s-r0.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/.gitignore new file mode 100755 index 00000000..3fa87cc2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/.gitignore @@ -0,0 +1,3 @@ +*x86*64*delta*agc5648s.mk +onlpdump.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/PKG.yml new file mode 100755 index 00000000..b918bbd6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-agc5648s diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/PKG.yml new file mode 100755 index 00000000..d917901b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-delta-agc5648s ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/Makefile new file mode 100755 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/Makefile new file mode 100755 index 00000000..ece5857b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-delta-agc5648s +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_delta_agc5648s onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-delta-agc5648s.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/libonlp-x86-64-delta-agc5648s-r0.mk b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/libonlp-x86-64-delta-agc5648s-r0.mk new file mode 100755 index 00000000..533c62ac --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/lib/libonlp-x86-64-delta-agc5648s-r0.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-delta-agc5648s-r0 module. +# +# Autogenerated 2016-03-16 22:11:47.698846 +# +############################################################################### +libonlp-x86-64-delta-agc5648s-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..dedb03d0 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_delta_agc5648s onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.module b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.module new file mode 100755 index 00000000..98a3219f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_delta_agc5648s diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/Makefile new file mode 100755 index 00000000..a0899de2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/Makefile @@ -0,0 +1,10 @@ +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.mk + +MODULE := x86_64_delta_agc5648s +AUTOMODULE := x86_64_delta_agc5648s +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/make.mk new file mode 100755 index 00000000..5e12c831 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# x86_64_delta_agc5648s Autogeneration +# +############################################################################### + +x86_64_delta_agc5648s_AUTO_DEFS := module/auto/x86_64_delta_agc5648s.yml +x86_64_delta_agc5648s_AUTO_DIRS := module/inc/x86_64_delta_agc5648s module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/x86_64_delta_agc5648s.yml b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/x86_64_delta_agc5648s.yml new file mode 100755 index 00000000..1a141796 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/auto/x86_64_delta_agc5648s.yml @@ -0,0 +1,55 @@ +############################################################################### +# +# x86_64_delta_agc5648s Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB +- X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 +- X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT: + doc: "SFP port numbers." + default: 4 +- X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX: + doc: "Max fan speed." + default: 18000 + +definitions: + cdefs: + X86_64_DELTA_AGC5648S_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_delta_agc5648s_config + + portingmacro: + X86_64_DELTA_AGC5648S: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s.x b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s.x new file mode 100755 index 00000000..a6f0585f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s.x @@ -0,0 +1,16 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h new file mode 100755 index 00000000..84a12c42 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h @@ -0,0 +1,155 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_AGC5648S Configuration Header + * + * @addtogroup x86_64_delta_AGC5648S-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AGC5648S_CONFIG_H__ +#define __X86_64_DELTA_AGC5648S_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_DELTA_AGC5648S_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING +#define X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT +#define X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI +#define X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT + * + * SFP port numbers. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT +#define X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT 54 +#endif + +/** + * X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX + * + * Max fan speed. */ + + +#ifndef X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX +#define X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX 23000 +#endif + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_delta_agc5648s_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_delta_agc5648s_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_delta_agc5648s_config_settings table. */ +extern x86_64_delta_agc5648s_config_settings_t x86_64_delta_agc5648s_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_delta_agc5648s_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_delta_agc5648s_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_delta_agc5648s_porting.h" + +#endif /* __X86_64_DELTA_AGC5648S_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_dox.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_dox.h new file mode 100755 index 00000000..67e8b30f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_delta_agc5648s Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AGC5648S_DOX_H__ +#define _X86_64_DELTA_AGC5648S_DOX_H__ + +/** + * @defgroup x86_64_delta_agc5648s x86_64_delta_agc5648s - x86_64_delta_agc5648s Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_delta_agc5648s-x86_64_delta_agc5648s Public Interface + * @defgroup x86_64_delta_agc5648s-config Compile Time Configuration + * @defgroup x86_64_delta_agc5648s-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_DELTA_AGC5648S_DOX_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_porting.h new file mode 100755 index 00000000..a6a63870 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_wb2448 Porting Macros. + * + * @addtogroup x86_64_delta_wb2448-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AGC5648S_PORTING_H__ +#define __X86_64_DELTA_AGC5648S_PORTING_H__ + + +/* */ +#if X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_DELTA_AGC5648S_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_DELTA_AGC5648S_MALLOC GLOBAL_MALLOC + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_MALLOC malloc + #else + #error The macro X86_64_DELTA_AGC5648S_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_FREE + #if defined(GLOBAL_FREE) + #define X86_64_DELTA_AGC5648S_FREE GLOBAL_FREE + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_FREE free + #else + #error The macro X86_64_DELTA_AGC5648S_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_DELTA_AGC5648S_MEMSET GLOBAL_MEMSET + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_MEMSET memset + #else + #error The macro X86_64_DELTA_AGC5648S_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_DELTA_AGC5648S_MEMCPY GLOBAL_MEMCPY + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_MEMCPY memcpy + #else + #error The macro X86_64_DELTA_AGC5648S_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_DELTA_AGC5648S_STRNCPY GLOBAL_STRNCPY + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_STRNCPY strncpy + #else + #error The macro X86_64_DELTA_AGC5648S_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_DELTA_AGC5648S_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_VSNPRINTF vsnprintf + #else + #error The macro X86_64_DELTA_AGC5648S_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_DELTA_AGC5648S_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_SNPRINTF snprintf + #else + #error The macro X86_64_DELTA_AGC5648S_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AGC5648S_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_DELTA_AGC5648S_STRLEN GLOBAL_STRLEN + #elif X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC5648S_STRLEN strlen + #else + #error The macro X86_64_DELTA_AGC5648S_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_DELTA_AGC5648S_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/make.mk new file mode 100755 index 00000000..9c18c642 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_delta_agc5648s_INCLUDES := -I $(THIS_DIR)inc +x86_64_delta_agc5648s_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_delta_agc5648s_DEPENDMODULE_ENTRIES := init:x86_64_delta_agc5648s ucli:x86_64_delta_agc5648s + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/Makefile new file mode 100755 index 00000000..894fa746 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/Makefile @@ -0,0 +1,12 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + + +include ../../../../init.mk + +ucli: + $(SUBMODULE_BIGCODE)/tools/uclihandlers.py x86_64_delta_agc5648s_ucli.c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c new file mode 100755 index 00000000..39f24a7f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c @@ -0,0 +1,301 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include "x86_64_delta_agc5648s_int.h" + +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_FAN(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* Static values */ +static onlp_fan_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_FAN_ID_CREATE(FAN_1_ON_FAN_BOARD), "Chassis Fan 1", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_2_ON_FAN_BOARD), "Chassis Fan 2", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_3_ON_FAN_BOARD), "Chassis Fan 3", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_4_ON_FAN_BOARD), "Chassis Fan 4", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_5_ON_FAN_BOARD), "Chassis Fan 5", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_6_ON_FAN_BOARD), "Chassis Fan 6", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_7_ON_FAN_BOARD), "Chassis Fan 7", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_8_ON_FAN_BOARD), "Chassis Fan 8", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_9_ON_FAN_BOARD), "Chassis Fan 9", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_10_ON_FAN_BOARD), "Chassis Fan 10", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_ON_PSU1), "FAN ON PSU1", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_ON_PSU2), "FAN ON PSU2", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, +}; + +int onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +static int ifnLinearDataToDecimal(uint16_t u16Value, uint16_t u16ManLen, uint16_t u16ExpLen) +{ + uint8_t index; + uint16_t ManMask = 1; + uint16_t ExpMask = 1; + uint16_t Mantissa, Exponent; + + for(index = 1; index < u16ManLen; index++) + { + ManMask <<= 1; + ManMask |= 0x1; + } + + for(index = 1; index < u16ExpLen; index++) + { + ExpMask <<= 1; + ExpMask |= 0x1; + } + + /* Didn't check the negative bit */ + Mantissa = u16Value & ManMask; + Exponent = u16Value >> u16ManLen; + + for(index = 0; index < Exponent; index++) + { + Mantissa *= 2; + } + + return Mantissa; +} + + +static int dni_fani_info_get_on_fanboard(int local_id, onlp_fan_info_t* info) +{ + int rv = ONLP_STATUS_OK; + uint32_t FanSpeed = 0; + + switch(local_id) + { + case FAN_1_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_1", &FanSpeed); + break; + + case FAN_2_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_2", &FanSpeed); + break; + + case FAN_3_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_3", &FanSpeed); + break; + + case FAN_4_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_4", &FanSpeed); + break; + + case FAN_5_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_5", &FanSpeed); + break; + + case FAN_6_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_6", &FanSpeed); + break; + + case FAN_7_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_7", &FanSpeed); + break; + + case FAN_8_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_8", &FanSpeed); + break; + + case FAN_9_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_9", &FanSpeed); + break; + + case FAN_10_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_10", &FanSpeed); + break; + + default: + AIM_LOG_ERROR("Invalid Fan ID!!\n"); + rv = ONLP_STATUS_E_INVALID; + } + + if(rv == ONLP_STATUS_OK) + { + info->rpm = FanSpeed; + info->percentage = (info->rpm * 100) / X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX; + } + + return ONLP_STATUS_OK; +} + + +static int dni_fani_info_get_on_psu(int local_id, onlp_fan_info_t* info) +{ + int rv = ONLP_STATUS_OK; + uint32_t FanSpeed = 0; + + switch(local_id) + { + case FAN_ON_PSU1: + ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_3, SWPLD_1_ADDR, PSU_I2C_MUX_ADDR, PSU1_EEPORM_CHANNEL, DATA_LEN); + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_2, FAN_ON_PSU1_ADDR, PMBUS_FAN_SPEED, &FanSpeed, 2); + break; + + case FAN_ON_PSU2: + ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_3, SWPLD_1_ADDR, PSU_I2C_MUX_ADDR, PSU2_EEPORM_CHANNEL << 4, DATA_LEN); + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_2, FAN_ON_PSU2_ADDR, PMBUS_FAN_SPEED, &FanSpeed, 2); + break; + + default: + AIM_LOG_ERROR("Invalid Fan ID!!\n"); + return ONLP_STATUS_E_INVALID; + } + + if(rv == ONLP_STATUS_OK) + { + FanSpeed = ((FanSpeed >> 8) | (FanSpeed << 8)); + FanSpeed = ifnLinearDataToDecimal( FanSpeed, 11, 5 ); + info->rpm = FanSpeed; + info->percentage = (info->rpm * 100) / X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX; + } + + return rv; +} + +int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + *info = linfo[ONLP_OID_ID_GET(id)]; + + switch(local_id) + { + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + case FAN_7_ON_FAN_BOARD: + case FAN_8_ON_FAN_BOARD: + case FAN_9_ON_FAN_BOARD: + case FAN_10_ON_FAN_BOARD: + rv = dni_fani_info_get_on_fanboard(local_id, info); + break; + + case FAN_ON_PSU1: + case FAN_ON_PSU2: + rv = dni_fani_info_get_on_psu(local_id, info); + break; + + default: + AIM_LOG_ERROR("Invalid Fan ID!!\n"); + rv = ONLP_STATUS_E_INVALID; + } + + return rv; +} + +int onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_fani_ioctl(onlp_oid_t fid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..a1450935 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,331 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + ***********************************************************/ +#include +#include "x86_64_delta_agc5648s_int.h" + +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_LED(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Get the information for the given LED OID. + */ + typedef struct led_light_mode_map +{ + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = +{ + {LED_PSU, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_PSU, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_PSU, LED_MODE_YELLOW, ONLP_LED_MODE_YELLOW}, + {LED_PSU, LED_MODE_YELLOW_BLINK, ONLP_LED_MODE_YELLOW_BLINKING}, + {LED_SYS, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_SYS, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_SYS, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_SYS, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, + {LED_FAN_TRAY_1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN_TRAY_1, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_1, LED_MODE_FAN_TRAY_RED, ONLP_LED_MODE_RED}, + {LED_FAN_TRAY_2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN_TRAY_2, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_2, LED_MODE_FAN_TRAY_RED, ONLP_LED_MODE_RED}, + {LED_FAN_TRAY_3, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN_TRAY_3, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_3, LED_MODE_FAN_TRAY_RED, ONLP_LED_MODE_RED}, + {LED_FAN_TRAY_4, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN_TRAY_4, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_4, LED_MODE_FAN_TRAY_RED, ONLP_LED_MODE_RED}, + {LED_FAN_TRAY_5, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN_TRAY_5, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_5, LED_MODE_FAN_TRAY_RED, ONLP_LED_MODE_RED} +}; + +static onlp_led_info_t linfo[] = +{ + { }, + { + { ONLP_LED_ID_CREATE(LED_PSU), "PSU LED (FRONT)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_YELLOW | ONLP_LED_CAPS_YELLOW_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_SYS), "SYSTEM LED (FRONT)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "FAN LED (FRONT)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_1), "FAN TRAY 1", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_2), "FAN TRAY 2", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_3), "FAN TRAY 3", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_4), "FAN TRAY 4", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_5), "FAN TRAY 5", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +int onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + uint32_t LedMode = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + *info = linfo[local_id]; + + /* Get LED mode */ + switch(local_id) + { + case LED_PSU: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_PSU_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 6 ) & 0x03; + break; + + case LED_SYS: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_SYS_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 4) & 0x03; + break; + + case LED_FAN: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_FAN_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 2) & 0x03; + break; + + case LED_FAN_TRAY_1: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_FAN_TRAY_1_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 6 ) & 0x03; + break; + + case LED_FAN_TRAY_2: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_FAN_TRAY_2_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 4) & 0x03; + break; + + case LED_FAN_TRAY_3: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_FAN_TRAY_3_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 2) & 0x03; + break; + + case LED_FAN_TRAY_4: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_FAN_TRAY_4_REGISTER, &LedMode, DATA_LEN); + LedMode = LedMode & 0x03; + break; + + case LED_FAN_TRAY_5: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, LED_FAN_TRAY_5_REGISTER, &LedMode, DATA_LEN); + LedMode = (LedMode >> 6) & 0x03; + break; + + default: + AIM_LOG_ERROR("Invalid LED ID!!\n"); + rv = ONLP_STATUS_E_PARAM; + } + + if( rv == ONLP_STATUS_OK) + { + info->mode = driver_to_onlp_led_mode(local_id, LedMode); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) + { + info->status |= ONLP_LED_STATUS_ON; + } + } + + return rv; +} + +int onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) + { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + uint32_t Addr = 0; + uint32_t NewLedMode = 0; + uint32_t OldLedMode = 0; + onlp_led_mode_t driver_led_mode = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + driver_led_mode = onlp_to_driver_led_mode(local_id, mode); + + switch(local_id) + { + case LED_PSU: + AIM_LOG_ERROR("PSU LED (FRONT) is read only!!\n"); + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + + case LED_SYS: + Addr = LED_SYS_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0xCF) | ((driver_led_mode << 4) & 0x30) ); + break; + + case LED_FAN: + Addr = LED_FAN_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0xF3) | ((driver_led_mode << 2) & 0x0C) ); + break; + + case LED_FAN_TRAY_1: + Addr = LED_FAN_TRAY_1_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0x3F) | ((driver_led_mode << 6) & 0xC0) ); + break; + + case LED_FAN_TRAY_2: + Addr = LED_FAN_TRAY_2_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0xCF) | ((driver_led_mode << 4) & 0x30) ); + break; + + case LED_FAN_TRAY_3: + Addr = LED_FAN_TRAY_3_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0xF3) | ((driver_led_mode << 2) & 0x0C) ); + break; + + case LED_FAN_TRAY_4: + Addr = LED_FAN_TRAY_4_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0xFC) | (driver_led_mode & 0x03) ); + break; + + case LED_FAN_TRAY_5: + Addr = LED_FAN_TRAY_5_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, &OldLedMode, DATA_LEN); + NewLedMode = ( (OldLedMode & 0x3F) | ((driver_led_mode << 6) & 0xC0) ); + break; + + default: + rv = ONLP_STATUS_E_PARAM; + AIM_LOG_ERROR("Invalid LED ID!!\n"); + } + + if(rv == ONLP_STATUS_OK) + { + rv = ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_3, SWPLD_1_ADDR, Addr, NewLedMode, DATA_LEN); + } + + return rv; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/make.mk new file mode 100755 index 00000000..8c169ca4 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/make.mk @@ -0,0 +1,11 @@ +############################################################################### +# +# +# +############################################################################### + + +LIBRARY := x86_64_delta_agc5648s +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +#$(LIBRARY)_LAST := 1 +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c new file mode 100755 index 00000000..4c6b211c --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,238 @@ +/************************************************************ + * + * + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + + +int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t *rdata, uint8_t datalen) +{ + int rv = ONLP_STATUS_OK; + int dIndex = 1; + char *pch = NULL; + FILE *pFd = NULL; + int tmp_data[OS_MAX_MSG_SIZE] = {0}; + char ipmi_cmd[OS_MAX_MSG_SIZE] = {0}; + char cmd_rdata[OS_MAX_MSG_SIZE] = {0}; + + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x2 %d %d %d %d", bus, dev, reg, datalen); + + pFd = popen(ipmi_cmd, "r"); + + if(pFd != NULL) + { + if (fgets(cmd_rdata, OS_MAX_MSG_SIZE, pFd) != NULL) + { + memset(tmp_data, 0x0, sizeof(tmp_data)); + + for(dIndex = 1; dIndex <= datalen; dIndex++) + { + if(dIndex == 1) + { + pch = strtok(cmd_rdata," "); + } + else + { + pch = strtok(NULL," "); + } + + if(!pch) + { + AIM_LOG_ERROR("Command \"%s\": Extract Data Failed (ret: %d)", ipmi_cmd, ONLP_STATUS_E_INTERNAL); + return ONLP_STATUS_E_INTERNAL; + } + else + { /* cut newline char */ + if( pch[strlen(pch)-1] == '\n') + { + pch[strlen(pch)-1] = 0x0; + } + } + + tmp_data[dIndex] = xtoi(pch); + } + + switch (datalen) + { + case 1: + *rdata = tmp_data[1]; + break; + case 2: + *rdata = (tmp_data[1] << 8) | (tmp_data[2]); + break; + default: + if( (datalen > 2) && (datalen < 64) ) + { + for(dIndex = 1; dIndex <= datalen; dIndex++) + { + rdata[dIndex - 1] = tmp_data[dIndex]; + } + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Command \"%s\": data length out of range (ret: %d)", ipmi_cmd, rv); + } + } + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Command \"%s\": Get Data Failed (ret: %d)", ipmi_cmd, rv); + } + + pclose(pFd); + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv); + } + + return rv; +} + +int ifnOS_LINUX_BmcI2CSet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t u4Data, uint8_t datalen) +{ + int rv = ONLP_STATUS_OK; + FILE *pFd = NULL; + char ipmi_cmd[OS_MAX_MSG_SIZE] = {0}; + + switch (datalen) + { + case 1: + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x3 %d %d %d %d", bus, dev, reg, u4Data); + break; + case 2: + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x4 %d %d %d %d %d", bus, dev, reg, + ((u4Data & 0xFF00) >> 8), (u4Data & 0xFF)); + break; + case 4: + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x5 %d %d %d %d %d %d %d", bus, dev, reg, + ((u4Data & 0xFF000000) >> 24), ((u4Data & 0xFF0000) >> 16), ((u4Data & 0xFF00) >> 8), (u4Data & 0xFF)); + break; + default: + AIM_LOG_ERROR("ERR: Unsupported data length: %d", datalen); + } + + pFd = popen(ipmi_cmd, "r"); + + if (pFd != NULL) + { + pclose(pFd); + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv); + } + + return rv; +} + +int ifnOS_LINUX_BmcGetDataByName(char *devname, uint32_t *rdata) +{ + int rv = ONLP_STATUS_OK; + char *temp_data = NULL; + FILE *pFd = NULL; + uint32_t devdata = 0; + char ipmi_cmd [OS_MAX_MSG_SIZE] = {0}; + char cmd_rdata[OS_MAX_MSG_SIZE] = {0}; + + sprintf(ipmi_cmd, "ipmitool sdr get %s | grep 'Sensor Reading'", devname); + + pFd = popen(ipmi_cmd, "r"); + + if(pFd != NULL) + { + if (fgets(cmd_rdata, OS_MAX_MSG_SIZE, pFd) != NULL) + { + temp_data = strchr(cmd_rdata, ':'); + temp_data = strtok(temp_data, "("); + + do + { + devdata += strtol(temp_data, &temp_data, 10); + }while (*temp_data++); + + *rdata = devdata; + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Command \"%s\": Get Data Failed (ret: %d)", ipmi_cmd, rv); + } + + pclose(pFd); + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv); + } + + return rv; +} + +uint32_t xtoi(const char* str) +{ + int digit = 0; + uint32_t x = 0; + + if ((*str == '0') && (*(str+1) == 'x')) str += 2; + + while (*str) + { + if ((*str >= '0') && (*str <= '9')) + { + digit = *str - '0'; + } + else if ((*str >= 'A') && (*str <= 'F')) + { + digit = 10 + *str - 'A'; + } + else if ((*str >= 'a') && (*str <= 'f')) + { + digit = 10 + *str - 'a'; + } + else + { + break; + } + + x *= 16; + x += digit; + str++; + } + + return x; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..53375752 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,190 @@ +/************************************************************ + * + * + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_delta_agc5648s_log.h" + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0053/eeprom" +#define OS_MAX_MSG_SIZE 100 + +#define I2C_BMC_BUS_1 0x01 +#define I2C_BMC_BUS_2 0x02 +#define I2C_BMC_BUS_3 0x03 +#define I2C_BMC_BUS_5 0x05 +#define I2C_BUS_1 0x00 +#define I2C_BUS_2 0x01 +#define SWPLD_1_ADDR 0x31 +#define SWPLD_2_ADDR 0x32 +#define SWPLD_3_ADDR 0x33 + +#define NUM_OF_THERMAL_ON_MAIN_BROAD 6 +#define NUM_OF_LED_ON_MAIN_BROAD 8 +#define NUM_OF_PSU_ON_MAIN_BROAD 2 +#define NUM_OF_FAN_ON_MAIN_BROAD 10 +#define NUM_OF_FAN_ON_PSU_BROAD 2 +#define NUM_OF_FAN NUM_OF_FAN_ON_MAIN_BROAD + NUM_OF_FAN_ON_PSU_BROAD + +#define CPLD_VERSION_REGISTER 0x01 +#define CPLD_VERSION_OFFSET 4 + +#define PSU_PRESENT_REGISTER 0x52 +#define PSU_STATUS_REGISTER 0x14 +#define PSU_POWER_GOOD_STATUS 0x01 +#define PSU_PRESENT_STATUS 0x00 + +#define PSU_I2C_MUX_ADDR 0x50 +#define PSU1_EEPORM_CHANNEL 0x00 +#define PSU2_EEPORM_CHANNEL 0x02 + +#define PMBUS_FAN_SPEED 0x90 +#define FAN_ON_PSU1_ADDR 0x58 +#define FAN_ON_PSU2_ADDR 0x58 + +#define LED_PSU_REGISTER 0x40 +#define LED_SYS_REGISTER 0x40 +#define LED_FAN_REGISTER 0x40 +#define LED_FAN_TRAY_1_REGISTER 0x41 +#define LED_FAN_TRAY_2_REGISTER 0x41 +#define LED_FAN_TRAY_3_REGISTER 0x41 +#define LED_FAN_TRAY_4_REGISTER 0x41 +#define LED_FAN_TRAY_5_REGISTER 0x42 + +#define SFP_PLUS_MIN_PORT 1 +#define SFP_PLUS_MAX_PORT 48 +#define QSFP_MIN_PORT 49 +#define QSFP_MAX_PORT 54 + +#define SFP_EEPROM_ADDR 0x50 +#define SFP_1_TO_8_PRESENT_REG 0x70 +#define SFP_9_TO_16_PRESENT_REG 0x71 +#define SFP_17_TO_24_PRESENT_REG 0x72 +#define SFP_25_TO_32_PRESENT_REG 0x73 +#define SFP_33_TO_36_PRESENT_REG 0x74 +#define SFP_37_TO_44_PRESENT_REG 0x90 +#define SFP_45_TO_48_PRESENT_REG 0x91 +#define QSFP_49_TO_54_PRESENT_REG 0xB2 + +#define SFP_1_8_RX_LOS_REG 0x75 +#define SFP_9_16_RX_LOS_REG 0x76 +#define SFP_17_24_RX_LOS_REG 0x77 +#define SFP_25_32_RX_LOS_REG 0x78 +#define SFP_33_36_RX_LOS_REG 0x79 +#define SFP_37_44_RX_LOS_REG 0x95 +#define SFP_45_48_RX_LOS_REG 0x96 + +#define SFP_1_8_TX_DISABLE_REG 0x80 +#define SFP_9_16_TX_DISABLE_REG 0x81 +#define SFP_17_24_TX_DISABLE_REG 0x82 +#define SFP_25_32_TX_DISABLE_REG 0x83 +#define SFP_33_36_TX_DISABLE_REG 0x84 +#define SFP_37_44_TX_DISABLE_REG 0xA0 +#define SFP_45_48_TX_DISABLE_REG 0xA1 + +#define INVALID_ADDR 0xFF +#define INVALID_REG 0xFF +#define INVALID_REG_BIT 0xFF + +#define THERMAL_CPU_ADDR 0x4D +#define THERMAL_FAN_ADDR 0x4F +#define THERMAL_AMBI_ADDR 0x48 +#define THERMAL_KBP1_ADDR 0x4E +#define THERMAL_KBP2_ADDR 0x4F +#define THERMAL_JER1_ADDR 0x4C +#define THERMAL_JER2_ADDR 0x4D +#define THERMAL_REGISTER 0x00 + +#define DATA_LEN 0x01 + +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_PSU, + LED_SYS, + LED_FAN, + LED_FAN_TRAY_1, + LED_FAN_TRAY_2, + LED_FAN_TRAY_3, + LED_FAN_TRAY_4, + LED_FAN_TRAY_5 +}; + +enum onlp_fan_id +{ + FAN_RESERVED = 0, + FAN_1_ON_FAN_BOARD, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_7_ON_FAN_BOARD, + FAN_8_ON_FAN_BOARD, + FAN_9_ON_FAN_BOARD, + FAN_10_ON_FAN_BOARD, + FAN_ON_PSU1, + FAN_ON_PSU2 +}; + +enum onlp_psu_id +{ + PSU_RESERVED = 0, + PSU_1, + PSU_2, +}; + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_AMBI_ON_MAIN_BOARD, + THERMAL_KBP1_ON_MAIN_BOARD, + THERMAL_KBP2_ON_MAIN_BOARD, + THERMAL_JER1_ON_MAIN_BOARD, + THERMAL_JER2_ON_MAIN_BOARD, +}; + +enum led_light_mode +{ + LED_MODE_OFF = 0, + LED_MODE_GREEN = 1, + LED_MODE_RED = 3, + LED_MODE_AMBER = 2, + LED_MODE_YELLOW = 2, + LED_MODE_GREEN_BLINK = 2, + LED_MODE_AMBER_BLINK = 2, + LED_MODE_YELLOW_BLINK = 3, + LED_MODE_FAN_TRAY_RED = 2, + LED_MODE_FAN_TRAY_GREEN = 1, + LED_MODE_UNKNOWN +}; + +int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t *data, uint8_t datalen); +int ifnOS_LINUX_BmcI2CSet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t data, uint8_t datalen); +int ifnOS_LINUX_BmcGetDataByName(char *FanName, uint32_t *data); +uint32_t xtoi(const char* str); + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c new file mode 100755 index 00000000..1bdcb574 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c @@ -0,0 +1,154 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_delta_agc5648s_int.h" + +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_PSU(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU_1), "PSU 1", 0 }, + {"DPS-1600AB-13 A"}, + }, + { + { ONLP_PSU_ID_CREATE(PSU_2), "PSU 2", 0 }, + {"DPS-1600AB-13 A"}, + } +}; + +int onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + uint32_t PSUStatus = 0; + uint32_t PSUIsPresent = 0; + uint32_t PSUIsGood = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + *info = pinfo[local_id]; + + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, PSU_PRESENT_REGISTER, &PSUStatus, DATA_LEN); + + if(rv == ONLP_STATUS_OK) + { + switch(local_id) + { + case PSU_1: + PSUIsPresent = PSUStatus >> 7; + break; + + case PSU_2: + PSUIsPresent = (PSUStatus >> 6) & 0x01; + break; + + default: + AIM_LOG_ERROR("Invalid PSU ID!!\n"); + return ONLP_STATUS_E_PARAM; + } + + if (PSUIsPresent != PSU_PRESENT_STATUS) + { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + else + { + info->status |= ONLP_PSU_STATUS_PRESENT; + } + } + else + { + AIM_LOG_ERROR("Unable to read PSU present status: %d\r\n", rv); + return ONLP_STATUS_E_INVALID; + } + + PSUStatus = 0; + + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &PSUStatus, DATA_LEN); + + if(rv == ONLP_STATUS_OK) + { + switch(local_id) + { + case PSU_1: + PSUIsGood = PSUStatus >> 7; + break; + + case PSU_2: + PSUIsGood = (PSUStatus >> 6) & 0x01; + break; + + default: + AIM_LOG_ERROR("Invalid PSU ID!!\n"); + return ONLP_STATUS_E_PARAM; + } + + if (PSUIsGood != PSU_POWER_GOOD_STATUS) + { + info->status |= ONLP_PSU_STATUS_FAILED; + } + } + else + { + AIM_LOG_ERROR("Unable to read PSU good status: %d\r\n", rv); + return ONLP_STATUS_E_INVALID; + } + + return rv; +} + +int onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c new file mode 100755 index 00000000..a21d82cd --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,295 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + ***********************************************************/ +#include +#include +#include "x86_64_delta_agc5648s_log.h" + +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define reverseBits(b) b = ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; + +struct portCtrl +{ + int portId; + int swpldAddr; + int presentReg; + int presentRegBit; + int rxLosReg; + int rxLosRegBit; + int txDisableReg; + int txDisableRegBit; + +}; + +static struct portCtrl gPortCtrl[] = +{ + {}, + {1, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 7, SFP_1_8_RX_LOS_REG, 7, SFP_1_8_TX_DISABLE_REG, 0}, + {2, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 6, SFP_1_8_RX_LOS_REG, 6, SFP_1_8_TX_DISABLE_REG, 1}, + {3, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 5, SFP_1_8_RX_LOS_REG, 5, SFP_1_8_TX_DISABLE_REG, 2}, + {4, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 4, SFP_1_8_RX_LOS_REG, 4, SFP_1_8_TX_DISABLE_REG, 3}, + {5, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 3, SFP_1_8_RX_LOS_REG, 3, SFP_1_8_TX_DISABLE_REG, 4}, + {6, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 2, SFP_1_8_RX_LOS_REG, 2, SFP_1_8_TX_DISABLE_REG, 5}, + {7, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 1, SFP_1_8_RX_LOS_REG, 1, SFP_1_8_TX_DISABLE_REG, 6}, + {8, SWPLD_2_ADDR, SFP_1_TO_8_PRESENT_REG, 0, SFP_1_8_RX_LOS_REG, 0, SFP_1_8_TX_DISABLE_REG, 7}, + + {9, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 7, SFP_9_16_RX_LOS_REG, 7, SFP_9_16_TX_DISABLE_REG, 0}, + {10, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 6, SFP_9_16_RX_LOS_REG, 6, SFP_9_16_TX_DISABLE_REG, 1}, + {11, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 5, SFP_9_16_RX_LOS_REG, 5, SFP_9_16_TX_DISABLE_REG, 2}, + {12, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 4, SFP_9_16_RX_LOS_REG, 4, SFP_9_16_TX_DISABLE_REG, 3}, + {13, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 3, SFP_9_16_RX_LOS_REG, 3, SFP_9_16_TX_DISABLE_REG, 4}, + {14, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 2, SFP_9_16_RX_LOS_REG, 2, SFP_9_16_TX_DISABLE_REG, 5}, + {15, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 1, SFP_9_16_RX_LOS_REG, 1, SFP_9_16_TX_DISABLE_REG, 6}, + {16, SWPLD_2_ADDR, SFP_9_TO_16_PRESENT_REG, 0, SFP_9_16_RX_LOS_REG, 0, SFP_9_16_TX_DISABLE_REG, 7}, + + {17, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 7, SFP_17_24_RX_LOS_REG, 7, SFP_17_24_TX_DISABLE_REG, 0}, + {18, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 6, SFP_17_24_RX_LOS_REG, 6, SFP_17_24_TX_DISABLE_REG, 1}, + {19, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 5, SFP_17_24_RX_LOS_REG, 5, SFP_17_24_TX_DISABLE_REG, 2}, + {20, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 4, SFP_17_24_RX_LOS_REG, 4, SFP_17_24_TX_DISABLE_REG, 3}, + {21, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 3, SFP_17_24_RX_LOS_REG, 3, SFP_17_24_TX_DISABLE_REG, 4}, + {22, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 2, SFP_17_24_RX_LOS_REG, 2, SFP_17_24_TX_DISABLE_REG, 5}, + {23, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 1, SFP_17_24_RX_LOS_REG, 1, SFP_17_24_TX_DISABLE_REG, 6}, + {24, SWPLD_2_ADDR, SFP_17_TO_24_PRESENT_REG, 0, SFP_17_24_RX_LOS_REG, 0, SFP_17_24_TX_DISABLE_REG, 7}, + + {25, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 7, SFP_25_32_RX_LOS_REG, 7, SFP_25_32_TX_DISABLE_REG, 0}, + {26, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 6, SFP_25_32_RX_LOS_REG, 6, SFP_25_32_TX_DISABLE_REG, 1}, + {27, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 5, SFP_25_32_RX_LOS_REG, 5, SFP_25_32_TX_DISABLE_REG, 2}, + {28, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 4, SFP_25_32_RX_LOS_REG, 4, SFP_25_32_TX_DISABLE_REG, 3}, + {29, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 3, SFP_25_32_RX_LOS_REG, 3, SFP_25_32_TX_DISABLE_REG, 4}, + {30, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 2, SFP_25_32_RX_LOS_REG, 2, SFP_25_32_TX_DISABLE_REG, 5}, + {31, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 1, SFP_25_32_RX_LOS_REG, 1, SFP_25_32_TX_DISABLE_REG, 6}, + {32, SWPLD_2_ADDR, SFP_25_TO_32_PRESENT_REG, 0, SFP_25_32_RX_LOS_REG, 0, SFP_25_32_TX_DISABLE_REG, 7}, + + {33, SWPLD_2_ADDR, SFP_33_TO_36_PRESENT_REG, 7, SFP_33_36_RX_LOS_REG, 7, SFP_33_36_TX_DISABLE_REG, 0}, + {34, SWPLD_2_ADDR, SFP_33_TO_36_PRESENT_REG, 6, SFP_33_36_RX_LOS_REG, 6, SFP_33_36_TX_DISABLE_REG, 1}, + {35, SWPLD_2_ADDR, SFP_33_TO_36_PRESENT_REG, 5, SFP_33_36_RX_LOS_REG, 5, SFP_33_36_TX_DISABLE_REG, 2}, + {36, SWPLD_2_ADDR, SFP_33_TO_36_PRESENT_REG, 4, SFP_33_36_RX_LOS_REG, 4, SFP_33_36_TX_DISABLE_REG, 3}, + + {37, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 7, SFP_37_44_RX_LOS_REG, 7, SFP_37_44_TX_DISABLE_REG, 0}, + {38, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 6, SFP_37_44_RX_LOS_REG, 6, SFP_37_44_TX_DISABLE_REG, 1}, + {39, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 5, SFP_37_44_RX_LOS_REG, 5, SFP_37_44_TX_DISABLE_REG, 2}, + {40, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 4, SFP_37_44_RX_LOS_REG, 4, SFP_37_44_TX_DISABLE_REG, 3}, + {41, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 3, SFP_37_44_RX_LOS_REG, 3, SFP_37_44_TX_DISABLE_REG, 4}, + {42, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 2, SFP_37_44_RX_LOS_REG, 2, SFP_37_44_TX_DISABLE_REG, 5}, + {43, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 1, SFP_37_44_RX_LOS_REG, 1, SFP_37_44_TX_DISABLE_REG, 6}, + {44, SWPLD_3_ADDR, SFP_37_TO_44_PRESENT_REG, 0, SFP_37_44_RX_LOS_REG, 0, SFP_37_44_TX_DISABLE_REG, 7}, + + {45, SWPLD_3_ADDR, SFP_45_TO_48_PRESENT_REG, 7, SFP_45_48_RX_LOS_REG, 7, SFP_45_48_TX_DISABLE_REG, 0}, + {46, SWPLD_3_ADDR, SFP_45_TO_48_PRESENT_REG, 6, SFP_45_48_RX_LOS_REG, 6, SFP_45_48_TX_DISABLE_REG, 1}, + {47, SWPLD_3_ADDR, SFP_45_TO_48_PRESENT_REG, 5, SFP_45_48_RX_LOS_REG, 5, SFP_45_48_TX_DISABLE_REG, 2}, + {48, SWPLD_3_ADDR, SFP_45_TO_48_PRESENT_REG, 4, SFP_45_48_RX_LOS_REG, 4, SFP_45_48_TX_DISABLE_REG, 3}, + + {49, SWPLD_3_ADDR, QSFP_49_TO_54_PRESENT_REG, 7, INVALID_REG, 7, INVALID_REG_BIT, 0}, + {50, SWPLD_3_ADDR, QSFP_49_TO_54_PRESENT_REG, 6, INVALID_REG, 6, INVALID_REG_BIT, 1}, + {51, SWPLD_3_ADDR, QSFP_49_TO_54_PRESENT_REG, 5, INVALID_REG, 5, INVALID_REG_BIT, 2}, + {52, SWPLD_3_ADDR, QSFP_49_TO_54_PRESENT_REG, 4, INVALID_REG, 4, INVALID_REG_BIT, 3}, + {53, SWPLD_3_ADDR, QSFP_49_TO_54_PRESENT_REG, 3, INVALID_REG, 3, INVALID_REG_BIT, 4}, + {54, SWPLD_3_ADDR, QSFP_49_TO_54_PRESENT_REG, 2, INVALID_REG, 2, INVALID_REG_BIT, 5}, + + {0xFFFF, INVALID_ADDR , INVALID_REG, 0, INVALID_REG, 0, INVALID_REG_BIT, 0}, +}; + +static int port_to_presence_all_bitmap(int portstart, int portend, uint64_t* presence_all) +{ + int i = 0, j =0; + int rv = ONLP_STATUS_OK; + uint8_t present_bit = 0; + + for (i = portstart; i <= portend; i += 8) + { + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, gPortCtrl[i].swpldAddr, gPortCtrl[i].presentReg, (uint32_t*)(&present_bit), DATA_LEN); + + if (rv != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", i, rv); + return ONLP_STATUS_E_INTERNAL; + } + + present_bit = ~(present_bit) & 0xFF; + + if(portend <= 32) + { + reverseBits(present_bit); + *presence_all |= ((uint64_t)(present_bit)) << (((i - 1)/ 8) * 8); + } + else + { + for ( j = portstart; j <= portend ; j ++) + { + *presence_all |= ((uint64_t)((present_bit >> gPortCtrl[j].presentRegBit ) & 0x01) << (j-1)); + } + } + } + + return 0; +} + +int onlp_sfpi_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + + AIM_BITMAP_CLR_ALL(bmap); + + for(p = SFP_PLUS_MIN_PORT; p <= QSFP_MAX_PORT; p++) + { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int onlp_sfpi_is_present(int port) +{ + int rv = ONLP_STATUS_OK; + uint32_t present_bit = 0, IsPresent = 0; + + if( (port >= SFP_PLUS_MIN_PORT) && (port <= QSFP_MAX_PORT) ) + { + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, gPortCtrl[port].swpldAddr, gPortCtrl[port].presentReg, &present_bit, DATA_LEN); + + if (rv == ONLP_STATUS_OK) + { + present_bit = (present_bit >> gPortCtrl[port].presentRegBit ) & 0x01; + + /* From sfp_is_present value, + * return 0 = The module is preset + * return 1 = The module is NOT present + */ + if(present_bit == 0) + { + IsPresent = 1; + } + else if (present_bit == 1) + { + IsPresent = 0; + } + else + { + AIM_LOG_ERROR("Error to present status from port(%d)\r\n", port); + IsPresent = -1; + } + + return IsPresent; + } + else + { + AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", port, rv); + return ONLP_STATUS_E_INTERNAL; + } + + } + else + { + AIM_LOG_ERROR("The port %d is invalid \r\n", port); + return ONLP_STATUS_E_UNSUPPORTED; + } +} + +int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int i = 0; + uint64_t presence_all = 0; + + AIM_BITMAP_CLR_ALL(dst); + + port_to_presence_all_bitmap(1, 32, &presence_all); + port_to_presence_all_bitmap(33, 36, &presence_all); + port_to_presence_all_bitmap(37, 44, &presence_all); + port_to_presence_all_bitmap(45, 48, &presence_all); + port_to_presence_all_bitmap(49, 54, &presence_all); + + /* Populate bitmap */ + for(i = SFP_PLUS_MIN_PORT; presence_all; i++) + { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + uint32_t i = 0, MuxDevAddr[] = {0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77}; + uint8_t u4Data = 0, u4Addr = 0; + + /* Clear Mux */ + for(i = 0; i < (sizeof(MuxDevAddr)/sizeof(uint32_t)); i++) + { + if(onlp_i2c_read(I2C_BUS_2, MuxDevAddr[i], 0x0, 1, &u4Data, 0) != 0) + { + AIM_LOG_ERROR("ERROR: unable to write mux device (0x%2x)\n", MuxDevAddr[i]); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Set Mux */ + u4Addr = 1 << ((port-1) % 8); + if(onlp_i2c_read(I2C_BUS_2, MuxDevAddr[(port-1)/8], u4Addr, 1, &u4Data, 0) != 0) + { + AIM_LOG_ERROR("ERROR: unable to write mux device (0x%2x)\n", MuxDevAddr[(port-1)/8]); + return ONLP_STATUS_E_INTERNAL; + } + + memset(data, 0 ,256); + + /* Read eeprom information into data[] */ + if (onlp_i2c_read(I2C_BUS_2, SFP_EEPROM_ADDR, 0, 256, data, 0) != 0) + { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + + return onlp_sfpi_eeprom_read( port, data); +} + +int onlp_sfpi_ioctl(int port, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..7e59f575 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,235 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "x86_64_delta_agc5648s_log.h" +#include "platform_lib.h" + +const char* onlp_sysi_platform_get(void) +{ + return "x86-64-delta-agc5648s-r0"; +} + +int onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) + { + if(*size == 256) + { + *data = rdata; + 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 rv = ONLP_STATUS_OK; + uint32_t u4Data = 0; + + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, CPLD_VERSION_REGISTER, &u4Data, DATA_LEN); + + if(rv == ONLP_STATUS_OK) + { + u4Data = u4Data >> CPLD_VERSION_OFFSET; + + pi->cpld_versions = aim_fstrdup("%d", u4Data); + } + + return rv; +} + +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) +{ + int i = 0; + onlp_oid_t* e = table; + + memset(table, 0, max*sizeof(onlp_oid_t)); + + for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_FAN; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int onlp_sysi_platform_manage_leds(void) +{ + int i = 0, rc = ONLP_STATUS_OK; + onlp_fan_info_t fan_info; + onlp_led_mode_t fan_new_mode; + onlp_led_mode_t fan_tray_new_mode[NUM_OF_FAN_ON_MAIN_BROAD]; + onlp_psu_info_t psu_info[NUM_OF_PSU_ON_MAIN_BROAD]; + onlp_led_mode_t psu_new_mode; + onlp_led_mode_t sys_new_mode; + + /* FAN LED */ + for(i = 0; i < NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fan_info); + + if ( (rc != ONLP_STATUS_OK) || !(fan_info.status & ONLP_FAN_STATUS_PRESENT) ) + { + fan_tray_new_mode[i] = ONLP_LED_MODE_OFF; + continue; + } + else + { + if(fan_info.status & ONLP_FAN_STATUS_FAILED) + { + fan_tray_new_mode[i] = ONLP_LED_MODE_RED; + continue; + } + } + + fan_tray_new_mode[i] = ONLP_LED_MODE_GREEN; + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_1), fan_tray_new_mode[0]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_2), fan_tray_new_mode[1]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_3), fan_tray_new_mode[2]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_4), fan_tray_new_mode[3]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_5), fan_tray_new_mode[4]); + + if((fan_tray_new_mode[0] == ONLP_LED_MODE_GREEN) && (fan_tray_new_mode[1] == ONLP_LED_MODE_GREEN) && + (fan_tray_new_mode[2] == ONLP_LED_MODE_GREEN) && (fan_tray_new_mode[3] == ONLP_LED_MODE_GREEN) && + (fan_tray_new_mode[4] == ONLP_LED_MODE_GREEN) ) + { + fan_new_mode = ONLP_LED_MODE_GREEN; + } + else if((fan_tray_new_mode[0] == ONLP_LED_MODE_OFF) || (fan_tray_new_mode[1] == ONLP_LED_MODE_OFF) || + (fan_tray_new_mode[2] == ONLP_LED_MODE_OFF) || (fan_tray_new_mode[3] == ONLP_LED_MODE_OFF) || + (fan_tray_new_mode[4] == ONLP_LED_MODE_OFF) ) + { + fan_new_mode = ONLP_LED_MODE_OFF; + } + else + { + fan_new_mode = ONLP_LED_MODE_ORANGE; + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), fan_new_mode); + + /* PSU1 and PSU2 LED */ + for( i = 0; i < NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + rc = onlp_psui_info_get(ONLP_PSU_ID_CREATE(i+1), &psu_info[i]); + + if (rc != ONLP_STATUS_OK) + { + psu_new_mode = ONLP_LED_MODE_OFF; + goto SET_PSU_LED; + } + } + + if((psu_info[0].status & ONLP_PSU_STATUS_PRESENT) && (psu_info[1].status & ONLP_PSU_STATUS_PRESENT)) + { + if(!(psu_info[0].status & ONLP_PSU_STATUS_FAILED) && !(psu_info[1].status & ONLP_PSU_STATUS_FAILED)) + { + psu_new_mode = ONLP_LED_MODE_GREEN; + } + else if(!(psu_info[0].status & ONLP_PSU_STATUS_FAILED) || !(psu_info[1].status & ONLP_PSU_STATUS_FAILED)) + { + psu_new_mode = ONLP_LED_MODE_YELLOW_BLINKING; + } + else + { + psu_new_mode = ONLP_LED_MODE_OFF; + } + } + else if((psu_info[0].status & ONLP_PSU_STATUS_PRESENT) || (psu_info[1].status & ONLP_PSU_STATUS_PRESENT)) + { + if(!(psu_info[0].status & ONLP_PSU_STATUS_FAILED) || !(psu_info[1].status & ONLP_PSU_STATUS_FAILED)) + { + psu_new_mode = ONLP_LED_MODE_YELLOW; + } + else + { + psu_new_mode = ONLP_LED_MODE_OFF; + } + } + else + { + psu_new_mode = ONLP_LED_MODE_OFF; + } + +SET_PSU_LED: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU), psu_new_mode); + + /* SYS LED */ + if((psu_new_mode == ONLP_LED_MODE_GREEN) && (fan_new_mode == ONLP_LED_MODE_GREEN)) + { + sys_new_mode = ONLP_LED_MODE_GREEN; + } + else + { + sys_new_mode = ONLP_LED_MODE_RED; + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), sys_new_mode); + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c new file mode 100755 index 00000000..28dda750 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,143 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include "x86_64_delta_agc5648s_log.h" + +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_THERMAL(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { + { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_AMBI_ON_MAIN_BOARD), "Thermal Sensor (AMBI)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_KBP1_ON_MAIN_BOARD), "Thermal Sensor (KBP1)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_KBP2_ON_MAIN_BOARD), "Thermal Sensor (KBP2)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_JER1_ON_MAIN_BOARD), "Thermal Sensor (JER1)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_JER2_ON_MAIN_BOARD), "Thermal Sensor (JER2)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, +}; + +int onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + int temp_base = 1000; + uint32_t temp_data = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + *info = linfo[local_id]; + + switch(local_id) + { + case THERMAL_CPU_CORE: + rv = onlp_i2c_read(I2C_BUS_1, THERMAL_CPU_ADDR, THERMAL_REGISTER, DATA_LEN, (uint8_t*)&temp_data, 0); + break; + + case THERMAL_AMBI_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_1", &temp_data); + break; + + case THERMAL_KBP1_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_2", &temp_data); + break; + + case THERMAL_KBP2_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_3", &temp_data); + break; + + case THERMAL_JER1_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_4", &temp_data); + break; + + case THERMAL_JER2_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_5", &temp_data); + break; + + default: + AIM_LOG_ERROR("Invalid Thermal ID!!\n"); + return ONLP_STATUS_E_PARAM; + } + + if(rv == ONLP_STATUS_OK) + { + info->mcelsius = temp_data * temp_base; + } + + return rv; +} + +int +onlp_thermali_ioctl(int id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c new file mode 100755 index 00000000..8b9a6d22 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c @@ -0,0 +1,93 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* */ +#define __x86_64_delta_agc5648s_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(_x) __x86_64_delta_agc5648s_config_STRINGIFY_NAME(_x) +x86_64_delta_agc5648s_config_settings_t x86_64_delta_agc5648s_config_settings[] = +{ +#ifdef X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_LOGGING(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_PORTING_STDLIB(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX + { __x86_64_delta_agc5648s_config_STRINGIFY_NAME(X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX), __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX) }, +#else +{ X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX(__x86_64_delta_agc5648s_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_delta_agc5648s_config_STRINGIFY_VALUE +#undef __x86_64_delta_agc5648s_config_STRINGIFY_NAME + +const char* +x86_64_delta_agc5648s_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_delta_agc5648s_config_settings[i].name; i++) { + if(strcmp(x86_64_delta_agc5648s_config_settings[i].name, setting)) { + return x86_64_delta_agc5648s_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_delta_agc5648s_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_delta_agc5648s_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_delta_agc5648s_config_settings[i].name, x86_64_delta_agc5648s_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_enums.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_enums.c new file mode 100755 index 00000000..a2da6deb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_enums.c @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_int.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_int.h new file mode 100755 index 00000000..e075a26b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_int.h @@ -0,0 +1,13 @@ +/**************************************************************************//** + * + * x86_64_delta_agc5648s Internal Header + * + *****************************************************************************/ + +#ifndef __X86_64_DELTA_AGC5648S_INT_H__ +#define __X86_64_DELTA_AGC5648S_INT_H__ + +#include + + +#endif /* __X86_64_DELTA_AGC5648S_INT_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.c new file mode 100755 index 00000000..fcc24edf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.c @@ -0,0 +1,21 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +#include "x86_64_delta_agc5648s_log.h" +/* + * x86_64_delta_agc5648s log struct. + */ +AIM_LOG_STRUCT_DEFINE +( + X86_64_DELTA_AGC5648S_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_DELTA_AGC5648S_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_DELTA_AGC5648S_CONFIG_LOG_CUSTOM_BITS_DEFAULT +); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.h new file mode 100755 index 00000000..ed3ff3f1 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_log.h @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#ifndef __X86_64_DELTA_AGC5648S_LOG_H__ +#define __X86_64_DELTA_AGC5648S_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_delta_agc5648s +#include + +#endif /* __X86_64_DELTA_AGC5648S_LOG_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_module.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_module.c new file mode 100755 index 00000000..778ec0f3 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_module.c @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +#include "x86_64_delta_agc5648s_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_DELTA_AGC5648S_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_delta_agc5648s_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_ucli.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_ucli.c new file mode 100755 index 00000000..97ee1627 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_ucli.c @@ -0,0 +1,64 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +#if X86_64_DELTA_AGC5648S_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_delta_agc5648s_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_delta_agc5648s) +} + +/* */ +/****************************************************************************** + * + * These handler table(s) were autogenerated from the symbols in this + * source file. + * + *****************************************************************************/ +static ucli_command_handler_f x86_64_delta_agc5648s_ucli_ucli_handlers__[] = +{ + x86_64_delta_agc5648s_ucli_ucli__config__, + NULL +}; +/******************************************************************************/ +/* */ + +static ucli_module_t +x86_64_delta_agc5648s_ucli_module__ = +{ + "x86_64_delta_agc5648s_ucli", + NULL, + x86_64_delta_agc5648s_ucli_ucli_handlers__, + NULL, + NULL, +}; + +ucli_node_t* +x86_64_delta_agc5648s_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_delta_agc5648s_ucli_module__); + n = ucli_node_create("x86_64_delta_agc5648s", NULL, &x86_64_delta_agc5648s_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_delta_agc5648s")); + return n; +} + +#else +void* +x86_64_delta_agc5648s_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/PKG.yml new file mode 100755 index 00000000..2fbee2fd --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-agc5648s REVISION=r0 + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/lib/x86-64-delta-agc5648s-r0.yml b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/lib/x86-64-delta-agc5648s-r0.yml new file mode 100755 index 00000000..529792bb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/lib/x86-64-delta-agc5648s-r0.yml @@ -0,0 +1,30 @@ +--- + +###################################################################### +# +# platform-config for DELTA agc5648s +###################################################################### + +x86-64-delta-agc5648s-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py new file mode 100755 index 00000000..ba5a1c85 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py @@ -0,0 +1,18 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_x86_64_delta_agc5648s_r0(OnlPlatformDelta, + OnlPlatformPortConfig_48x1_4x10): + PLATFORM='x86-64-delta-agc5648s-r0' + MODEL="agc5648s" + SYS_OBJECT_ID=".5658.1" + + def baseconfig(self): + + # initiate eeprom + self.new_i2c_device('24c02', 0x53, 0) + + self.insmod('i2c-mei') + + return True + From b502c9edb4fad6d6211d780b6b494c71cad216d8 Mon Sep 17 00:00:00 2001 From: chenglin-tsai Date: Fri, 15 Dec 2017 14:21:26 +0800 Subject: [PATCH 091/244] Align the source code. --- .../onlp/builds/src/module/src/fani.c | 17 +++--- .../onlp/builds/src/module/src/ledi.c | 5 +- .../onlp/builds/src/module/src/platform_lib.c | 4 +- .../onlp/builds/src/module/src/platform_lib.h | 56 +++++++++---------- .../onlp/builds/src/module/src/psui.c | 3 +- .../onlp/builds/src/module/src/sfpi.c | 12 ++-- .../onlp/builds/src/module/src/sysi.c | 24 ++++---- .../onlp/builds/src/module/src/thermali.c | 7 +-- .../x86_64_delta_agc5648s_r0/__init__.py | 2 +- 9 files changed, 62 insertions(+), 68 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c index 39f24a7f..47176afe 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/fani.c @@ -42,17 +42,17 @@ return ONLP_STATUS_E_INVALID; \ } \ } while(0) - + /* Static values */ static onlp_fan_info_t linfo[] = { - { }, /* Not used */ - { + { }, /* Not used */ + { { ONLP_FAN_ID_CREATE(FAN_1_ON_FAN_BOARD), "Chassis Fan 1", 0}, ONLP_FAN_STATUS_PRESENT, ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, }, - { + { { ONLP_FAN_ID_CREATE(FAN_2_ON_FAN_BOARD), "Chassis Fan 2", 0}, ONLP_FAN_STATUS_PRESENT, ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, @@ -97,7 +97,7 @@ static onlp_fan_info_t linfo[] = ONLP_FAN_STATUS_PRESENT, ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, }, - { + { { ONLP_FAN_ID_CREATE(FAN_ON_PSU1), "FAN ON PSU1", 0}, ONLP_FAN_STATUS_PRESENT, ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, @@ -188,8 +188,8 @@ static int dni_fani_info_get_on_fanboard(int local_id, onlp_fan_info_t* info) case FAN_9_ON_FAN_BOARD: rv = ifnOS_LINUX_BmcGetDataByName("Fan_9", &FanSpeed); break; - - case FAN_10_ON_FAN_BOARD: + + case FAN_10_ON_FAN_BOARD: rv = ifnOS_LINUX_BmcGetDataByName("Fan_10", &FanSpeed); break; @@ -249,8 +249,7 @@ int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - - *info = linfo[ONLP_OID_ID_GET(id)]; + *info = linfo[ONLP_OID_ID_GET(id)]; switch(local_id) { diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c index a1450935..04c99b94 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/ledi.c @@ -164,15 +164,14 @@ int onlp_ledi_init(void) int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { - int rv = ONLP_STATUS_OK; + int rv = ONLP_STATUS_OK; int local_id = 0; uint32_t LedMode = 0; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - - *info = linfo[local_id]; + *info = linfo[local_id]; /* Get LED mode */ switch(local_id) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c index 4c6b211c..fcb04b7d 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.c @@ -55,7 +55,7 @@ int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t *rdat memset(tmp_data, 0x0, sizeof(tmp_data)); for(dIndex = 1; dIndex <= datalen; dIndex++) - { + { if(dIndex == 1) { pch = strtok(cmd_rdata," "); @@ -234,5 +234,5 @@ uint32_t xtoi(const char* str) str++; } - return x; + return x; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h index 53375752..63b5c4f7 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/platform_lib.h @@ -87,19 +87,19 @@ #define SFP_45_TO_48_PRESENT_REG 0x91 #define QSFP_49_TO_54_PRESENT_REG 0xB2 -#define SFP_1_8_RX_LOS_REG 0x75 -#define SFP_9_16_RX_LOS_REG 0x76 -#define SFP_17_24_RX_LOS_REG 0x77 -#define SFP_25_32_RX_LOS_REG 0x78 -#define SFP_33_36_RX_LOS_REG 0x79 -#define SFP_37_44_RX_LOS_REG 0x95 -#define SFP_45_48_RX_LOS_REG 0x96 +#define SFP_1_8_RX_LOS_REG 0x75 +#define SFP_9_16_RX_LOS_REG 0x76 +#define SFP_17_24_RX_LOS_REG 0x77 +#define SFP_25_32_RX_LOS_REG 0x78 +#define SFP_33_36_RX_LOS_REG 0x79 +#define SFP_37_44_RX_LOS_REG 0x95 +#define SFP_45_48_RX_LOS_REG 0x96 -#define SFP_1_8_TX_DISABLE_REG 0x80 -#define SFP_9_16_TX_DISABLE_REG 0x81 +#define SFP_1_8_TX_DISABLE_REG 0x80 +#define SFP_9_16_TX_DISABLE_REG 0x81 #define SFP_17_24_TX_DISABLE_REG 0x82 -#define SFP_25_32_TX_DISABLE_REG 0x83 -#define SFP_33_36_TX_DISABLE_REG 0x84 +#define SFP_25_32_TX_DISABLE_REG 0x83 +#define SFP_33_36_TX_DISABLE_REG 0x84 #define SFP_37_44_TX_DISABLE_REG 0xA0 #define SFP_45_48_TX_DISABLE_REG 0xA1 @@ -107,15 +107,15 @@ #define INVALID_REG 0xFF #define INVALID_REG_BIT 0xFF -#define THERMAL_CPU_ADDR 0x4D -#define THERMAL_FAN_ADDR 0x4F -#define THERMAL_AMBI_ADDR 0x48 -#define THERMAL_KBP1_ADDR 0x4E -#define THERMAL_KBP2_ADDR 0x4F -#define THERMAL_JER1_ADDR 0x4C -#define THERMAL_JER2_ADDR 0x4D -#define THERMAL_REGISTER 0x00 - +#define THERMAL_CPU_ADDR 0x4D +#define THERMAL_FAN_ADDR 0x4F +#define THERMAL_AMBI_ADDR 0x48 +#define THERMAL_KBP1_ADDR 0x4E +#define THERMAL_KBP2_ADDR 0x4F +#define THERMAL_JER1_ADDR 0x4C +#define THERMAL_JER2_ADDR 0x4D +#define THERMAL_REGISTER 0x00 + #define DATA_LEN 0x01 enum onlp_led_id @@ -168,17 +168,17 @@ enum onlp_thermal_id enum led_light_mode { - LED_MODE_OFF = 0, - LED_MODE_GREEN = 1, - LED_MODE_RED = 3, + LED_MODE_OFF = 0, + LED_MODE_GREEN = 1, + LED_MODE_RED = 3, LED_MODE_AMBER = 2, - LED_MODE_YELLOW = 2, - LED_MODE_GREEN_BLINK = 2, - LED_MODE_AMBER_BLINK = 2, - LED_MODE_YELLOW_BLINK = 3, + LED_MODE_YELLOW = 2, + LED_MODE_GREEN_BLINK = 2, + LED_MODE_AMBER_BLINK = 2, + LED_MODE_YELLOW_BLINK = 3, LED_MODE_FAN_TRAY_RED = 2, LED_MODE_FAN_TRAY_GREEN = 1, - LED_MODE_UNKNOWN + LED_MODE_UNKNOWN }; int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t *data, uint8_t datalen); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c index 1bdcb574..e42fd948 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/psui.c @@ -76,8 +76,7 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) local_id = ONLP_OID_ID_GET(id); - *info = pinfo[local_id]; - + *info = pinfo[local_id]; rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_3, SWPLD_1_ADDR, PSU_PRESENT_REGISTER, &PSUStatus, DATA_LEN); if(rv == ONLP_STATUS_OK) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c index a21d82cd..7a3f65ee 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sfpi.c @@ -47,7 +47,6 @@ struct portCtrl int rxLosRegBit; int txDisableReg; int txDisableRegBit; - }; static struct portCtrl gPortCtrl[] = @@ -122,7 +121,7 @@ static int port_to_presence_all_bitmap(int portstart, int portend, uint64_t* pre { int i = 0, j =0; int rv = ONLP_STATUS_OK; - uint8_t present_bit = 0; + uint8_t present_bit = 0; for (i = portstart; i <= portend; i += 8) { @@ -210,13 +209,12 @@ int onlp_sfpi_is_present(int port) AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", port, rv); return ONLP_STATUS_E_INTERNAL; } - } - else + else { - AIM_LOG_ERROR("The port %d is invalid \r\n", port); - return ONLP_STATUS_E_UNSUPPORTED; - } + AIM_LOG_ERROR("The port %d is invalid \r\n", port); + return ONLP_STATUS_E_UNSUPPORTED; + } } int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c index 7e59f575..b38f2b1b 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/sysi.c @@ -119,14 +119,14 @@ int onlp_sysi_oids_get(onlp_oid_t* table, int max) int onlp_sysi_platform_manage_leds(void) { int i = 0, rc = ONLP_STATUS_OK; - onlp_fan_info_t fan_info; - onlp_led_mode_t fan_new_mode; + onlp_fan_info_t fan_info; + onlp_led_mode_t fan_new_mode; onlp_led_mode_t fan_tray_new_mode[NUM_OF_FAN_ON_MAIN_BROAD]; - onlp_psu_info_t psu_info[NUM_OF_PSU_ON_MAIN_BROAD]; - onlp_led_mode_t psu_new_mode; - onlp_led_mode_t sys_new_mode; + onlp_psu_info_t psu_info[NUM_OF_PSU_ON_MAIN_BROAD]; + onlp_led_mode_t psu_new_mode; + onlp_led_mode_t sys_new_mode; - /* FAN LED */ + /* FAN LED */ for(i = 0; i < NUM_OF_FAN_ON_MAIN_BROAD; i++) { rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fan_info); @@ -171,9 +171,9 @@ int onlp_sysi_platform_manage_leds(void) fan_new_mode = ONLP_LED_MODE_ORANGE; } - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), fan_new_mode); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), fan_new_mode); - /* PSU1 and PSU2 LED */ + /* PSU1 and PSU2 LED */ for( i = 0; i < NUM_OF_PSU_ON_MAIN_BROAD; i++) { rc = onlp_psui_info_get(ONLP_PSU_ID_CREATE(i+1), &psu_info[i]); @@ -215,12 +215,12 @@ int onlp_sysi_platform_manage_leds(void) { psu_new_mode = ONLP_LED_MODE_OFF; } - + SET_PSU_LED: - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU), psu_new_mode); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU), psu_new_mode); - /* SYS LED */ - if((psu_new_mode == ONLP_LED_MODE_GREEN) && (fan_new_mode == ONLP_LED_MODE_GREEN)) + /* SYS LED */ + if((psu_new_mode == ONLP_LED_MODE_GREEN) && (fan_new_mode == ONLP_LED_MODE_GREEN)) { sys_new_mode = ONLP_LED_MODE_GREEN; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c index 28dda750..a3e57277 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/thermali.c @@ -43,7 +43,7 @@ return ONLP_STATUS_E_INVALID; \ } \ } while(0) - + /* Static values */ static onlp_thermal_info_t linfo[] = { { }, /* Not used */ @@ -94,8 +94,7 @@ int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - - *info = linfo[local_id]; + *info = linfo[local_id]; switch(local_id) { @@ -113,7 +112,7 @@ int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) case THERMAL_KBP2_ON_MAIN_BOARD: rv = ifnOS_LINUX_BmcGetDataByName("Temp_3", &temp_data); - break; + break; case THERMAL_JER1_ON_MAIN_BOARD: rv = ifnOS_LINUX_BmcGetDataByName("Temp_4", &temp_data); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py index ba5a1c85..35e58a79 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py @@ -2,7 +2,7 @@ from onl.platform.base import * from onl.platform.delta import * class OnlPlatform_x86_64_delta_agc5648s_r0(OnlPlatformDelta, - OnlPlatformPortConfig_48x1_4x10): + OnlPlatformPortConfig_48x1_4x10): PLATFORM='x86-64-delta-agc5648s-r0' MODEL="agc5648s" SYS_OBJECT_ID=".5658.1" From 97b52ca0ad1a36be7e3090dc2f2f9f6951d0a3bf Mon Sep 17 00:00:00 2001 From: chenglin-tsai Date: Tue, 19 Dec 2017 16:20:49 +0800 Subject: [PATCH 092/244] Add new platform: AG9064. --- .../x86-64/x86-64-delta-ag9064/.gitignore | 3 + .../delta/x86-64/x86-64-delta-ag9064/Makefile | 1 + .../x86-64-delta-ag9064/modules/Makefile | 1 + .../x86-64-delta-ag9064/modules/PKG.yml | 1 + .../x86-64/x86-64-delta-ag9064/onlp/Makefile | 1 + .../x86-64/x86-64-delta-ag9064/onlp/PKG.yml | 1 + .../x86-64-delta-ag9064/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 +++ .../onlp/builds/onlpdump/Makefile | 46 +++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 10 + .../onlp/builds/src/module/auto/make.mk | 10 + .../src/module/auto/x86_64_delta_ag9064.yml | 55 +++ .../x86_64_delta_ag9064/x86_64_delta_ag9064.x | 16 + .../x86_64_delta_ag9064_config.h | 155 ++++++++ .../x86_64_delta_ag9064_dox.h | 26 ++ .../x86_64_delta_ag9064_porting.h | 107 ++++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 12 + .../onlp/builds/src/module/src/fani.c | 278 ++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 344 ++++++++++++++++++ .../onlp/builds/src/module/src/make.mk | 11 + .../onlp/builds/src/module/src/platform_lib.c | 238 ++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 173 +++++++++ .../onlp/builds/src/module/src/psui.c | 128 +++++++ .../onlp/builds/src/module/src/sfpi.c | 276 ++++++++++++++ .../onlp/builds/src/module/src/sysi.c | 214 +++++++++++ .../onlp/builds/src/module/src/thermali.c | 141 +++++++ .../module/src/x86_64_delta_ag9064_config.c | 93 +++++ .../module/src/x86_64_delta_ag9064_enums.c | 12 + .../src/module/src/x86_64_delta_ag9064_int.h | 13 + .../src/module/src/x86_64_delta_ag9064_log.c | 21 ++ .../src/module/src/x86_64_delta_ag9064_log.h | 14 + .../module/src/x86_64_delta_ag9064_module.c | 26 ++ .../src/module/src/x86_64_delta_ag9064_ucli.c | 64 ++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 2 + .../r0/src/lib/x86-64-delta-ag9064-r0.yml | 30 ++ .../python/x86_64_delta_ag9064_r0/__init__.py | 18 + 40 files changed, 2601 insertions(+) create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/.gitignore create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/lib/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/onlpdump/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.module create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/x86_64_delta_ag9064.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064.x create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_dox.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_porting.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/ledi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/psui.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sfpi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sysi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_enums.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_int.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_module.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_ucli.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/lib/x86-64-delta-ag9064-r0.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/.gitignore new file mode 100755 index 00000000..7e8d1a79 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/.gitignore @@ -0,0 +1,3 @@ +*x86*64*delta*ag9064*.mk +onlpdump.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml new file mode 100755 index 00000000..21c8ec67 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=delta BASENAME=x86-64-delta-ag9064 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/PKG.yml new file mode 100755 index 00000000..d38d1424 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-delta-ag9064 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/Makefile new file mode 100755 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/lib/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/lib/Makefile new file mode 100755 index 00000000..d9ab2f0b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-delta-ag9064 +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_delta_ag9064 onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-delta-ag9064.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..8cd72b47 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_delta_ag9064 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.module b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.module new file mode 100755 index 00000000..72495843 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_delta_ag9064 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/Makefile new file mode 100755 index 00000000..3b9d3ec3 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/Makefile @@ -0,0 +1,10 @@ +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.mk + +MODULE := x86_64_delta_ag9064 +AUTOMODULE := x86_64_delta_ag9064 +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/make.mk new file mode 100755 index 00000000..f549edc4 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# x86_64_delta_ag9064 Autogeneration +# +############################################################################### + +x86_64_delta_ag9064_AUTO_DEFS := module/auto/x86_64_delta_ag9064.yml +x86_64_delta_ag9064_AUTO_DIRS := module/inc/x86_64_delta_ag9064 module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/x86_64_delta_ag9064.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/x86_64_delta_ag9064.yml new file mode 100755 index 00000000..5d9ad4d7 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/auto/x86_64_delta_ag9064.yml @@ -0,0 +1,55 @@ +############################################################################### +# +# x86_64_delta_ag9064 Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB +- X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 +- X86_64_DELTA_AG9064_CONFIG_SFP_COUNT: + doc: "SFP port numbers." + default: 64 +- X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX: + doc: "Max fan speed." + default: 13000 + +definitions: + cdefs: + X86_64_DELTA_AG9064_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_delta_ag9064_config + + portingmacro: + X86_64_DELTA_AG9064: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064.x b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064.x new file mode 100755 index 00000000..4a1b3c11 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064.x @@ -0,0 +1,16 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h new file mode 100755 index 00000000..d05c32d5 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h @@ -0,0 +1,155 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_AG9064 Configuration Header + * + * @addtogroup x86_64_delta_AG9064-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG9064_CONFIG_H__ +#define __X86_64_DELTA_AG9064_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_DELTA_AG9064_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING +#define X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT +#define X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI +#define X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_SFP_COUNT + * + * SFP port numbers. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_SFP_COUNT +#define X86_64_DELTA_AG9064_CONFIG_SFP_COUNT 64 +#endif + +/** + * X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX + * + * Max fan speed. */ + + +#ifndef X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX +#define X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX 13000 +#endif + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_delta_ag9064_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_delta_ag9064_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_delta_ag9064_config_settings table. */ +extern x86_64_delta_ag9064_config_settings_t x86_64_delta_ag9064_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_delta_ag9064_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_delta_ag9064_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_delta_ag9064_porting.h" + +#endif /* __X86_64_DELTA_AG9064_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_dox.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_dox.h new file mode 100755 index 00000000..4a04c802 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_delta_ag9064 Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG9064_DOX_H__ +#define _X86_64_DELTA_AG9064_DOX_H__ + +/** + * @defgroup x86_64_delta_ag9064 x86_64_delta_ag9064 - x86_64_delta_ag9064 Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_delta_ag9064-x86_64_delta_ag9064 Public Interface + * @defgroup x86_64_delta_ag9064-config Compile Time Configuration + * @defgroup x86_64_delta_ag9064-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_DELTA_AG9064_DOX_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_porting.h new file mode 100755 index 00000000..fc56bd71 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_wb2448 Porting Macros. + * + * @addtogroup x86_64_delta_wb2448-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG9064_PORTING_H__ +#define __X86_64_DELTA_AG9064_PORTING_H__ + + +/* */ +#if X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_DELTA_AG9064_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_DELTA_AG9064_MALLOC GLOBAL_MALLOC + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_MALLOC malloc + #else + #error The macro X86_64_DELTA_AG9064_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_FREE + #if defined(GLOBAL_FREE) + #define X86_64_DELTA_AG9064_FREE GLOBAL_FREE + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_FREE free + #else + #error The macro X86_64_DELTA_AG9064_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_DELTA_AG9064_MEMSET GLOBAL_MEMSET + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_MEMSET memset + #else + #error The macro X86_64_DELTA_AG9064_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_DELTA_AG9064_MEMCPY GLOBAL_MEMCPY + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_MEMCPY memcpy + #else + #error The macro X86_64_DELTA_AG9064_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_DELTA_AG9064_STRNCPY GLOBAL_STRNCPY + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_STRNCPY strncpy + #else + #error The macro X86_64_DELTA_AG9064_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_DELTA_AG9064_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_VSNPRINTF vsnprintf + #else + #error The macro X86_64_DELTA_AG9064_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_DELTA_AG9064_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_SNPRINTF snprintf + #else + #error The macro X86_64_DELTA_AG9064_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_DELTA_AG9064_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_DELTA_AG9064_STRLEN GLOBAL_STRLEN + #elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AG9064_STRLEN strlen + #else + #error The macro X86_64_DELTA_AG9064_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_DELTA_AG9064_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/make.mk new file mode 100755 index 00000000..8ca1a104 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_delta_ag9064_INCLUDES := -I $(THIS_DIR)inc +x86_64_delta_ag9064_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_delta_ag9064_DEPENDMODULE_ENTRIES := init:x86_64_delta_ag9064 ucli:x86_64_delta_ag9064 + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/Makefile new file mode 100755 index 00000000..1b10cd97 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/Makefile @@ -0,0 +1,12 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + + +include ../../../../init.mk + +ucli: + $(SUBMODULE_BIGCODE)/tools/uclihandlers.py x86_64_delta_ag9064_ucli.c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/fani.c new file mode 100755 index 00000000..d577156f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/fani.c @@ -0,0 +1,278 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include "x86_64_delta_ag9064_int.h" + +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_FAN(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* Static values */ +static onlp_fan_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_FAN_ID_CREATE(FAN_1_ON_FAN_BOARD), "Chassis Fan 4 front", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_2_ON_FAN_BOARD), "Chassis Fan 3 front", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_3_ON_FAN_BOARD), "Chassis Fan 2 front", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_4_ON_FAN_BOARD), "Chassis Fan 1 front", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_6_ON_FAN_BOARD), "Chassis Fan 4 rear", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_7_ON_FAN_BOARD), "Chassis Fan 3 rear", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_8_ON_FAN_BOARD), "Chassis Fan 2 rear", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_9_ON_FAN_BOARD), "Chassis Fan 1 rear", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_ON_PSU1), "FAN ON PSU1", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, + { + { ONLP_FAN_ID_CREATE(FAN_ON_PSU2), "FAN ON PSU2", 0}, + ONLP_FAN_STATUS_PRESENT, + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID, + }, +}; + +int onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +static int ifnLinearDataToDecimal(uint16_t u16Value, uint16_t u16ManLen, uint16_t u16ExpLen) +{ + uint16_t ManMask = 1; + uint16_t ExpMask = 1; + uint16_t Mantissa, Exponent; + uint8_t index; + + for(index = 1; index < u16ManLen; index++) + { + ManMask <<= 1; + ManMask |= 0x1; + } + + for(index = 1; index < u16ExpLen; index++) + { + ExpMask <<= 1; + ExpMask |= 0x1; + } + + /* Didn't check the negative bit */ + Mantissa = u16Value & ManMask; + Exponent = u16Value >> u16ManLen; + + for(index = 0; index < Exponent; index++) + { + Mantissa *= 2; + } + + return Mantissa; +} + + +static int dni_fani_info_get_on_fanboard(int local_id, onlp_fan_info_t* info) +{ + int rv = ONLP_STATUS_OK; + uint32_t FanSpeed = 0; + + switch(local_id) + { + case FAN_1_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_1", &FanSpeed); + break; + + case FAN_2_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_2", &FanSpeed); + break; + + case FAN_3_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_3", &FanSpeed); + break; + + case FAN_4_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_4", &FanSpeed); + break; + + case FAN_6_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_6", &FanSpeed); + break; + + case FAN_7_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_7", &FanSpeed); + break; + + case FAN_8_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_8", &FanSpeed); + break; + + case FAN_9_ON_FAN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Fan_9", &FanSpeed); + break; + + default: + AIM_LOG_ERROR("Invalid Fan ID!!\n"); + rv = ONLP_STATUS_E_INVALID; + } + + if(rv == ONLP_STATUS_OK) + { + info->rpm = FanSpeed; + info->percentage = (info->rpm * 100) / X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX; + } + + return ONLP_STATUS_OK; +} + + +static int dni_fani_info_get_on_psu(int local_id, onlp_fan_info_t* info) +{ + int rv = ONLP_STATUS_OK; + uint32_t FanSpeed = 0; + + switch(local_id) + { + case FAN_ON_PSU1: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_1, FAN_ON_PSU1_ADDR, FAN_SPEED_PMBUS, &FanSpeed, 2); + break; + + case FAN_ON_PSU2: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_1, FAN_ON_PSU2_ADDR, FAN_SPEED_PMBUS, &FanSpeed, 2); + break; + + default: + AIM_LOG_ERROR("Invalid Fan ID!!\n"); + return ONLP_STATUS_E_INVALID; + } + + if(rv == ONLP_STATUS_OK) + { + FanSpeed = ((FanSpeed >> 8) | (FanSpeed << 8)); + FanSpeed = ifnLinearDataToDecimal( FanSpeed, 11, 5 ); + info->rpm = FanSpeed; + info->percentage = (info->rpm * 100) / X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX; + } + + return rv; +} + +int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = linfo[ONLP_OID_ID_GET(id)]; + + switch(local_id) + { + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + case FAN_7_ON_FAN_BOARD: + case FAN_8_ON_FAN_BOARD: + case FAN_9_ON_FAN_BOARD: + rv = dni_fani_info_get_on_fanboard(local_id, info); + break; + + case FAN_ON_PSU1: + case FAN_ON_PSU2: + rv = dni_fani_info_get_on_psu(local_id, info); + break; + + default: + AIM_LOG_ERROR("Invalid Fan ID!!\n"); + rv = ONLP_STATUS_E_INVALID; + } + + return rv; +} + +int onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_fani_ioctl(onlp_oid_t fid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..5e830388 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,344 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + ***********************************************************/ +#include +#include "x86_64_delta_ag9064_int.h" + +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_LED(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Get the information for the given LED OID. + */ + typedef struct led_light_mode_map +{ + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = +{ + {LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_SYS, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_SYS, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_SYS, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_SYS, LED_MODE_SYS_RED, ONLP_LED_MODE_RED}, + {LED_PSU2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_PSU2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_PSU2, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_PSU1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_PSU1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_PSU1, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN_TRAY_1, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE}, + {LED_FAN_TRAY_1, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_2, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE}, + {LED_FAN_TRAY_2, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_3, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE}, + {LED_FAN_TRAY_3, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN_TRAY_4, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE}, + {LED_FAN_TRAY_4, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN}, +}; + +static onlp_led_info_t linfo[] = +{ + { }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "FAN LED (FRONT PANEL)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_SYS), "SYSTEM LED (FRONT PANEL)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "PSU1 LED (FRONT PANEL)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "PSU2 LED (FRONT PANEL)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_1), "FAN TRAY 1", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_2), "FAN TRAY 2", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_3), "FAN TRAY 3", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY_4), "FAN TRAY 4", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +int onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + uint32_t LedMode = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = linfo[local_id]; + + /* Get LED mode */ + switch(local_id) + { + case LED_FAN: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_SYS_FRONT_REGISTER, &LedMode, 1); + LedMode = ((LedMode >> LED_FAN_FRONT_BIT) & 0x03); + break; + + case LED_SYS: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_SYS_FRONT_REGISTER, &LedMode, 1); + LedMode = ((LedMode >> LED_SYS_FRONT_BIT) & 0x03); + break; + + case LED_PSU1: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &LedMode, 1); + + if ( ((LedMode >> PSU1_INT_BIT) & 0x01) == PSU_INT_HAPPEN_STATUS ) + { + LedMode = LED_MODE_RED; + } + else if( ((LedMode >> PSU1_POWER_GOOD_BIT) & 0x01) == PSU_POWER_GOOD_STATUS ) + { + LedMode = LED_MODE_GREEN; + } + else + { + LedMode = LED_MODE_OFF; + } + break; + + case LED_PSU2: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &LedMode, 1); + + if ( ((LedMode >> PSU2_INT_BIT) & 0x01) == PSU_INT_HAPPEN_STATUS ) + { + LedMode = LED_MODE_RED; + } + else if( ((LedMode >> PSU2_POWER_GOOD_BIT) & 0x01) == PSU_POWER_GOOD_STATUS ) + { + LedMode = LED_MODE_GREEN; + } + else + { + LedMode = LED_MODE_OFF; + } + break; + + case LED_FAN_TRAY_1: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1); + LedMode = (LedMode >> LED_FAN_TRAY_1_BIT ) & 0x01; + break; + + case LED_FAN_TRAY_2: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1); + LedMode = (LedMode >> LED_FAN_TRAY_2_BIT) & 0x01; + break; + + case LED_FAN_TRAY_3: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1); + LedMode = (LedMode >> LED_FAN_TRAY_3_BIT) & 0x01; + break; + + case LED_FAN_TRAY_4: + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1); + LedMode = (LedMode >> LED_FAN_TRAY_4_BIT) & 0x01; + break; + + default: + AIM_LOG_ERROR("Invalid LED ID!!\n"); + rv = ONLP_STATUS_E_PARAM; + } + + if( rv == ONLP_STATUS_OK) + { + info->mode = driver_to_onlp_led_mode(local_id, LedMode); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) + { + info->status |= ONLP_LED_STATUS_ON; + } + } + + return rv; +} + +int onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) + { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + uint32_t LEDAddr = 0; + uint32_t NewLedMode = 0; + uint32_t OldLedMode = 0; + onlp_led_mode_t driver_led_mode = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + driver_led_mode = onlp_to_driver_led_mode(local_id, mode); + + switch(local_id) + { + case LED_FAN: + LEDAddr = LED_FAN_SYS_FRONT_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1); + NewLedMode = ( (OldLedMode & 0x3F) | ((driver_led_mode << 6) & 0xC0) ); + break; + + case LED_SYS: + LEDAddr = LED_FAN_SYS_FRONT_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1); + NewLedMode = ( (OldLedMode & 0xCF) | ((driver_led_mode << 4) & 0x30) ); + break; + + case LED_PSU1: + case LED_PSU2: + AIM_LOG_ERROR("PSU LED (FRONT) is read only!!\n"); + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + + case LED_FAN_TRAY_1: + LEDAddr = LED_FAN_TRAY_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1); + NewLedMode = ( (OldLedMode & 0x7F) | ((driver_led_mode << 7) & 0x01) ); + break; + + case LED_FAN_TRAY_2: + LEDAddr = LED_FAN_TRAY_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1); + NewLedMode = ( (OldLedMode & 0xBF) | ((driver_led_mode << 6) & 0x01) ); + break; + + case LED_FAN_TRAY_3: + LEDAddr = LED_FAN_TRAY_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1); + NewLedMode = ( (OldLedMode & 0xDF) | ((driver_led_mode << 5) & 0x01) ); + break; + + case LED_FAN_TRAY_4: + LEDAddr = LED_FAN_TRAY_REGISTER; + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1); + NewLedMode = ( (OldLedMode & 0xEF) | ((driver_led_mode << 4) & 0x01) ); + break; + + default: + rv = ONLP_STATUS_E_PARAM; + AIM_LOG_ERROR("Invalid LED ID!!\n"); + } + + if(rv == ONLP_STATUS_OK) + { + rv = ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, NewLedMode, 1); + } + + return rv; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/make.mk new file mode 100755 index 00000000..2e2ec4c4 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/make.mk @@ -0,0 +1,11 @@ +############################################################################### +# +# +# +############################################################################### + + +LIBRARY := x86_64_delta_ag9064 +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +#$(LIBRARY)_LAST := 1 +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.c new file mode 100755 index 00000000..fcb04b7d --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,238 @@ +/************************************************************ + * + * + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + + +int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t *rdata, uint8_t datalen) +{ + int rv = ONLP_STATUS_OK; + int dIndex = 1; + char *pch = NULL; + FILE *pFd = NULL; + int tmp_data[OS_MAX_MSG_SIZE] = {0}; + char ipmi_cmd[OS_MAX_MSG_SIZE] = {0}; + char cmd_rdata[OS_MAX_MSG_SIZE] = {0}; + + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x2 %d %d %d %d", bus, dev, reg, datalen); + + pFd = popen(ipmi_cmd, "r"); + + if(pFd != NULL) + { + if (fgets(cmd_rdata, OS_MAX_MSG_SIZE, pFd) != NULL) + { + memset(tmp_data, 0x0, sizeof(tmp_data)); + + for(dIndex = 1; dIndex <= datalen; dIndex++) + { + if(dIndex == 1) + { + pch = strtok(cmd_rdata," "); + } + else + { + pch = strtok(NULL," "); + } + + if(!pch) + { + AIM_LOG_ERROR("Command \"%s\": Extract Data Failed (ret: %d)", ipmi_cmd, ONLP_STATUS_E_INTERNAL); + return ONLP_STATUS_E_INTERNAL; + } + else + { /* cut newline char */ + if( pch[strlen(pch)-1] == '\n') + { + pch[strlen(pch)-1] = 0x0; + } + } + + tmp_data[dIndex] = xtoi(pch); + } + + switch (datalen) + { + case 1: + *rdata = tmp_data[1]; + break; + case 2: + *rdata = (tmp_data[1] << 8) | (tmp_data[2]); + break; + default: + if( (datalen > 2) && (datalen < 64) ) + { + for(dIndex = 1; dIndex <= datalen; dIndex++) + { + rdata[dIndex - 1] = tmp_data[dIndex]; + } + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Command \"%s\": data length out of range (ret: %d)", ipmi_cmd, rv); + } + } + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Command \"%s\": Get Data Failed (ret: %d)", ipmi_cmd, rv); + } + + pclose(pFd); + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv); + } + + return rv; +} + +int ifnOS_LINUX_BmcI2CSet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t u4Data, uint8_t datalen) +{ + int rv = ONLP_STATUS_OK; + FILE *pFd = NULL; + char ipmi_cmd[OS_MAX_MSG_SIZE] = {0}; + + switch (datalen) + { + case 1: + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x3 %d %d %d %d", bus, dev, reg, u4Data); + break; + case 2: + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x4 %d %d %d %d %d", bus, dev, reg, + ((u4Data & 0xFF00) >> 8), (u4Data & 0xFF)); + break; + case 4: + sprintf(ipmi_cmd, "ipmitool raw 0x38 0x5 %d %d %d %d %d %d %d", bus, dev, reg, + ((u4Data & 0xFF000000) >> 24), ((u4Data & 0xFF0000) >> 16), ((u4Data & 0xFF00) >> 8), (u4Data & 0xFF)); + break; + default: + AIM_LOG_ERROR("ERR: Unsupported data length: %d", datalen); + } + + pFd = popen(ipmi_cmd, "r"); + + if (pFd != NULL) + { + pclose(pFd); + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv); + } + + return rv; +} + +int ifnOS_LINUX_BmcGetDataByName(char *devname, uint32_t *rdata) +{ + int rv = ONLP_STATUS_OK; + char *temp_data = NULL; + FILE *pFd = NULL; + uint32_t devdata = 0; + char ipmi_cmd [OS_MAX_MSG_SIZE] = {0}; + char cmd_rdata[OS_MAX_MSG_SIZE] = {0}; + + sprintf(ipmi_cmd, "ipmitool sdr get %s | grep 'Sensor Reading'", devname); + + pFd = popen(ipmi_cmd, "r"); + + if(pFd != NULL) + { + if (fgets(cmd_rdata, OS_MAX_MSG_SIZE, pFd) != NULL) + { + temp_data = strchr(cmd_rdata, ':'); + temp_data = strtok(temp_data, "("); + + do + { + devdata += strtol(temp_data, &temp_data, 10); + }while (*temp_data++); + + *rdata = devdata; + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Command \"%s\": Get Data Failed (ret: %d)", ipmi_cmd, rv); + } + + pclose(pFd); + } + else + { + rv = ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv); + } + + return rv; +} + +uint32_t xtoi(const char* str) +{ + int digit = 0; + uint32_t x = 0; + + if ((*str == '0') && (*(str+1) == 'x')) str += 2; + + while (*str) + { + if ((*str >= '0') && (*str <= '9')) + { + digit = *str - '0'; + } + else if ((*str >= 'A') && (*str <= 'F')) + { + digit = 10 + *str - 'A'; + } + else if ((*str >= 'a') && (*str <= 'f')) + { + digit = 10 + *str - 'a'; + } + else + { + break; + } + + x *= 16; + x += digit; + str++; + } + + return x; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..0ad93e8b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,173 @@ +/************************************************************ + * + * + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_delta_ag9064_log.h" + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom" + +#define I2C_BMC_BUS_1 0x00 +#define I2C_BMC_BUS_3 0x02 +#define I2C_BMC_BUS_5 0x04 +#define I2C_BUS_1 0x00 +#define I2C_BUS_2 0x01 +#define I2C_BUS_3 0x02 + +#define SWPLD_1_ADDR 0x35 +#define SWPLD_2_ADDR 0x34 +#define SWPLD_3_ADDR 0x33 +#define SWPLD_4_ADDR 0x32 + +#define NUM_OF_THERMAL_ON_MAIN_BROAD 6 +#define NUM_OF_LED_ON_MAIN_BROAD 8 +#define NUM_OF_PSU_ON_MAIN_BROAD 2 +#define NUM_OF_FAN_ON_MAIN_BROAD 8 +#define NUM_OF_FAN_ON_PSU_BROAD 2 +#define NUM_OF_FAN NUM_OF_FAN_ON_MAIN_BROAD + NUM_OF_FAN_ON_PSU_BROAD + +#define CPLD_VERSION_REGISTER 0x00 +#define CPLD_VERSION_OFFSET 4 + +#define LED_FAN_SYS_FRONT_REGISTER 0x02 +#define LED_FAN_TRAY_REGISTER 0x1B +#define LED_FAN_FRONT_BIT 0x06 +#define LED_SYS_FRONT_BIT 0x04 +#define LED_FAN_TRAY_1_BIT 0x07 +#define LED_FAN_TRAY_2_BIT 0x06 +#define LED_FAN_TRAY_3_BIT 0x05 +#define LED_FAN_TRAY_4_BIT 0x04 + +#define PSU_STATUS_REGISTER 0x02 +#define PSU1_PRESENT_BIT 0x07 +#define PSU1_POWER_GOOD_BIT 0x06 +#define PSU1_INT_BIT 0x05 +#define PSU2_PRESENT_BIT 0x03 +#define PSU2_POWER_GOOD_BIT 0x02 +#define PSU2_INT_BIT 0x01 +#define PSU_INT_HAPPEN_STATUS 0x01 +#define PSU_POWER_GOOD_STATUS 0x00 +#define PSU_PRESENT_STATUS 0x00 + +#define FAN_SPEED_PMBUS 0x90 +#define FAN_ON_PSU1_ADDR 0x58 +#define FAN_ON_PSU2_ADDR 0x59 + +#define THERMAL_CPU_ADDR 0x4D +#define THERMAL_FAN_ADDR 0x4F +#define THERMAL_1_ADDR 0x4C +#define THERMAL_2_ADDR 0x4E +#define THERMAL_3_ADDR 0x4B +#define THERMAL_4_ADDR 0x4A +#define THERMAL_REGISTER 0x00 + +#define QSFP_MIN_PORT 1 +#define QSFP_MAX_PORT 64 + +#define PCA9548_I2C_MUX_ADDR 0x70 +#define QSFP_CHAN_ON_PCA9548 0x04 +#define QSFP_PORT_MUX_REG 0x13 +#define QSFP_EEPROM_ADDR 0x50 + +#define QSFP_1_TO_8_PRESENT_REG 0x03 +#define QSFP_9_TO_16_PRESENT_REG 0x03 +#define QSFP_17_TO_24_PRESENT_REG 0x24 +#define QSFP_25_TO_32_PRESENT_REG 0x24 +#define QSFP_33_TO_40_PRESENT_REG 0x04 +#define QSFP_41_TO_48_PRESENT_REG 0x04 +#define QSFP_49_TO_56_PRESENT_REG 0x25 +#define QSFP_57_TO_64_PRESENT_REG 0x25 + +#define OS_MAX_MSG_SIZE 100 + +#define INVALID_ADDR 0xFF +#define INVALID_REG 0xFF +#define INVALID_REG_BIT 0xFF + +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_FAN, + LED_SYS, + LED_PSU1, + LED_PSU2, + LED_FAN_TRAY_1, + LED_FAN_TRAY_2, + LED_FAN_TRAY_3, + LED_FAN_TRAY_4 +}; + +enum onlp_fan_id +{ + FAN_RESERVED = 0, + FAN_1_ON_FAN_BOARD, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_7_ON_FAN_BOARD, + FAN_8_ON_FAN_BOARD, + FAN_9_ON_FAN_BOARD, + FAN_ON_PSU1, + FAN_ON_PSU2 +}; + +enum onlp_psu_id +{ + PSU_RESERVED = 0, + PSU_1, + PSU_2, +}; + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_ON_FAN_BROAD, + THERMAL_1_ON_MAIN_BOARD, + THERMAL_2_ON_MAIN_BOARD, + THERMAL_3_ON_MAIN_BOARD, + THERMAL_4_ON_MAIN_BOARD, +}; + +enum led_light_mode +{ + LED_MODE_OFF = 0, + LED_MODE_GREEN = 1, + LED_MODE_RED = 2, + LED_MODE_FAN_TRAY_GREEN = 1, + LED_MODE_SYS_RED = 3, + LED_MODE_FAN_TRAY_AMBER = 0, + LED_MODE_GREEN_BLINK = 2, + LED_MODE_UNKNOWN +}; + +int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t *data, uint8_t datalen); +int ifnOS_LINUX_BmcI2CSet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t data, uint8_t datalen); +int ifnOS_LINUX_BmcGetDataByName(char *FanName, uint32_t *data); +uint32_t xtoi(const char* str); + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/psui.c new file mode 100755 index 00000000..07af7c81 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/psui.c @@ -0,0 +1,128 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_delta_ag9064_int.h" + +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_PSU(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU_1), "PSU 1", 0 }, + {"DPS-1300AB-6 D"}, + }, + { + { ONLP_PSU_ID_CREATE(PSU_2), "PSU 2", 0 }, + {"DPS-1300AB-6 D"}, + } +}; + +int onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + uint32_t PSUStatus = 0; + uint32_t PSUIsPresent = 0; + uint32_t PSUIsGood = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = pinfo[local_id]; + + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &PSUStatus, 1); + + if(rv == ONLP_STATUS_OK) + { + switch(local_id) + { + case PSU_1: + PSUIsPresent = PSUStatus >> PSU1_PRESENT_BIT; + PSUIsGood = (PSUStatus >> PSU1_POWER_GOOD_BIT) & 0x01; + break; + + case PSU_2: + PSUIsPresent = (PSUStatus >> PSU2_PRESENT_BIT) & 0x01; + PSUIsGood = (PSUStatus >> PSU2_POWER_GOOD_BIT) & 0x01; + break; + + default: + AIM_LOG_ERROR("Invalid PSU ID!!\n"); + return ONLP_STATUS_E_PARAM; + } + + if (PSUIsPresent != PSU_PRESENT_STATUS) + { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + else + { + info->status |= ONLP_PSU_STATUS_PRESENT; + } + + if (PSUIsGood != PSU_POWER_GOOD_STATUS) + { + info->status |= ONLP_PSU_STATUS_FAILED; + } + } + else + { + AIM_LOG_ERROR("Unable to read PSU present status: %d\r\n", rv); + return ONLP_STATUS_E_INVALID; + } + + return rv; +} + +int onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sfpi.c new file mode 100755 index 00000000..7fe9c226 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,276 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + ***********************************************************/ +#include +#include +#include "x86_64_delta_ag9064_log.h" + +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +struct portCtrl +{ + int portId; + int swpldAddr; + int presentReg; + int presentRegBit; + int rxLosReg; + int rxLosRegBit; + int txDisableReg; + int txDisableRegBit; +}; + +static struct portCtrl gPortCtrl[] = +{ + {}, + {1, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {2, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {3, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {4, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {5, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {6, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {7, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {8, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {9, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {10, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {11, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {12, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {13, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {14, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {15, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {16, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {17, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {18, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {19, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {20, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {21, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {22, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {23, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {24, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {25, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {26, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {27, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {28, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {29, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {30, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {31, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {32, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {33, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {34, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {35, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {36, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {37, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {38, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {39, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {40, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {41, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {42, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {43, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {44, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {45, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {46, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {47, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {48, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {49, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {50, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {51, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {52, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {53, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {54, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {55, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {56, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {57, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {58, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0}, + {59, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0}, + {60, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0}, + {61, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0}, + {62, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0}, + {63, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0}, + {64, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, INVALID_ADDR , INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, +}; + +static int port_to_presence_all_bitmap(int portstart, int portend, uint64_t* presence_all) +{ + int i = 0; + int rv = ONLP_STATUS_OK; + uint32_t present_bit = 0; + + for (i = portstart; i <= portend; i += 8) + { + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, gPortCtrl[i].swpldAddr, gPortCtrl[i].presentReg, &present_bit, 1); + + if (rv != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", i, rv); + return ONLP_STATUS_E_INTERNAL; + } + + present_bit = ~(present_bit) & 0xFF; + *presence_all |= ((uint64_t)(present_bit)) << (((i - 1)/ 8) * 8); + } + + return 0; +} + +int onlp_sfpi_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + + AIM_BITMAP_CLR_ALL(bmap); + + for(p = QSFP_MIN_PORT; p <= QSFP_MAX_PORT; p++) + { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int onlp_sfpi_is_present(int port) +{ + int rv = ONLP_STATUS_OK; + uint32_t present_bit = 0, IsPresent = 0; + + if( (port >= QSFP_MIN_PORT) && (port <= QSFP_MAX_PORT) ) + { + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, gPortCtrl[port].swpldAddr, gPortCtrl[port].presentReg, &present_bit, 1); + + if (rv == ONLP_STATUS_OK) + { + present_bit = (present_bit >> gPortCtrl[port].presentRegBit ) & 0x01; + + /* From sfp_is_present value, + * return 0 = The module is preset + * return 1 = The module is NOT present + */ + if(present_bit == 0) + { + IsPresent = 1; + } + else if (present_bit == 1) + { + IsPresent = 0; + } + else + { + AIM_LOG_ERROR("Error to present status from port(%d)\r\n", port); + IsPresent = -1; + } + + return IsPresent; + } + else + { + AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", port, rv); + return ONLP_STATUS_E_INTERNAL; + } + } + else + { + AIM_LOG_ERROR("The port %d is invalid \r\n", port); + return ONLP_STATUS_E_UNSUPPORTED; + } +} + +int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int i = 0; + uint64_t presence_all = 0; + + AIM_BITMAP_CLR_ALL(dst); + + port_to_presence_all_bitmap(1, 64, &presence_all); + + /* Populate bitmap */ + for(i = QSFP_MIN_PORT; presence_all; i++) + { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + if(onlp_i2c_writeb(I2C_BUS_3, PCA9548_I2C_MUX_ADDR, 0x00, QSFP_CHAN_ON_PCA9548, 0) != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("ERROR: unable to set QSFP channel on PCA9548\n"); + return ONLP_STATUS_E_INTERNAL; + } + + if(ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_5, SWPLD_2_ADDR, QSFP_PORT_MUX_REG, port, 1) != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("ERROR: unable to set QSFP port mux\n"); + return ONLP_STATUS_E_INTERNAL; + } + + memset(data, 0 ,256); + + /* Read eeprom information into data[] */ + if (onlp_i2c_read(I2C_BUS_3, QSFP_EEPROM_ADDR, 0x00, 256, data, 0) != 0) + { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + + return onlp_sfpi_eeprom_read( port, data); +} + +int onlp_sfpi_ioctl(int port, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..05e73f31 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,214 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * HardwareVersion: 02 + * + ***********************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "x86_64_delta_ag9064_log.h" +#include "platform_lib.h" + +const char* onlp_sysi_platform_get(void) +{ + return "x86-64-delta-ag9064-r0"; +} + +int onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) + { + if(*size == 256) + { + *data = rdata; + 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 rv = ONLP_STATUS_OK; + uint32_t u4Data = 0; + + rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, CPLD_VERSION_REGISTER, &u4Data, 1); + + if(rv == ONLP_STATUS_OK) + { + u4Data = u4Data >> CPLD_VERSION_OFFSET; + + pi->cpld_versions = aim_fstrdup("%d", u4Data); + } + + return rv; +} + +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) +{ + int i = 0; + onlp_oid_t* e = table; + + memset(table, 0, max*sizeof(onlp_oid_t)); + + for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_FAN; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int onlp_sysi_platform_manage_leds(void) +{ + int i = 0, rc = ONLP_STATUS_OK; + onlp_fan_info_t fan_info; + onlp_led_mode_t fan_new_mode; + onlp_led_mode_t fan_tray_new_mode[NUM_OF_FAN_ON_MAIN_BROAD]; + onlp_psu_info_t psu_info[NUM_OF_PSU_ON_MAIN_BROAD]; + onlp_led_mode_t psu_new_mode[NUM_OF_PSU_ON_MAIN_BROAD]; + onlp_led_mode_t sys_new_mode; + + /* FAN LED */ + for(i = 0; i < NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fan_info); + + if ( (rc != ONLP_STATUS_OK) || !(fan_info.status & ONLP_FAN_STATUS_PRESENT) ) + { + fan_tray_new_mode[i] = ONLP_LED_MODE_ORANGE; + continue; + } + else + { + if(fan_info.status & ONLP_FAN_STATUS_FAILED) + { + fan_tray_new_mode[i] = ONLP_LED_MODE_ORANGE; + continue; + } + } + + fan_tray_new_mode[i] = ONLP_LED_MODE_GREEN; + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_1), fan_tray_new_mode[0]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_2), fan_tray_new_mode[1]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_3), fan_tray_new_mode[2]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_4), fan_tray_new_mode[3]); + + if((fan_tray_new_mode[0] == ONLP_LED_MODE_GREEN) && (fan_tray_new_mode[1] == ONLP_LED_MODE_GREEN) && + (fan_tray_new_mode[2] == ONLP_LED_MODE_GREEN) && (fan_tray_new_mode[3] == ONLP_LED_MODE_GREEN)) + { + fan_new_mode = ONLP_LED_MODE_GREEN; + } + else + { + fan_new_mode = ONLP_LED_MODE_ORANGE; + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), fan_new_mode); + + /* PSU1 and PSU2 LED */ + for( i = 0; i < NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + rc = onlp_psui_info_get(ONLP_PSU_ID_CREATE(i+1), &psu_info[i]); + + if (rc != ONLP_STATUS_OK) + { + psu_new_mode[i] = ONLP_LED_MODE_OFF; + continue; + } + + if(psu_info[i].status & ONLP_PSU_STATUS_PRESENT) + { + if(psu_info[i].status & ONLP_PSU_STATUS_FAILED) + { + psu_new_mode[i] = ONLP_LED_MODE_RED; + } + else + { + psu_new_mode[i] = ONLP_LED_MODE_GREEN; + } + } + else + { + psu_new_mode[i] = ONLP_LED_MODE_OFF; + } + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1), psu_new_mode[0]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2), psu_new_mode[1]); + + /* SYS LED */ + if( ((psu_new_mode[0] == ONLP_LED_MODE_GREEN) || (psu_new_mode[1] == ONLP_LED_MODE_GREEN)) && + (fan_new_mode == ONLP_LED_MODE_GREEN)) + { + sys_new_mode = ONLP_LED_MODE_GREEN; + } + else + { + sys_new_mode = ONLP_LED_MODE_RED; + } + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), sys_new_mode); + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/thermali.c new file mode 100755 index 00000000..d75a4837 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include "x86_64_delta_ag9064_log.h" + +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do \ + { \ + if(!ONLP_OID_IS_THERMAL(_id)) \ + { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { + { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_ON_FAN_BROAD), "FAN Board", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BOARD), "Close to right case", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BOARD), "Placed between QSFP cage and MAC", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Close to left case", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { + { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Board sensor near MAC", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, +}; + +int onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id = 0; + int temp_base = 1000; + uint32_t temp_data = 0; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = linfo[local_id]; + + switch(local_id) + { + case THERMAL_CPU_CORE: + rv = onlp_i2c_read(I2C_BUS_2, THERMAL_CPU_ADDR, THERMAL_REGISTER, 1, (uint8_t*)&temp_data, 0); + break; + + case THERMAL_1_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_1", &temp_data); + break; + + case THERMAL_2_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_2", &temp_data); + break; + + case THERMAL_3_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_3", &temp_data); + break; + + case THERMAL_4_ON_MAIN_BOARD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_4", &temp_data); + break; + + case THERMAL_ON_FAN_BROAD: + rv = ifnOS_LINUX_BmcGetDataByName("Temp_5", &temp_data); + break; + + default: + AIM_LOG_ERROR("Invalid Thermal ID!!\n"); + return ONLP_STATUS_E_PARAM; + } + + if(rv == ONLP_STATUS_OK) + { + info->mcelsius = temp_data * temp_base; + } + + return rv; +} + +int onlp_thermali_ioctl(int id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c new file mode 100755 index 00000000..1f528e25 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c @@ -0,0 +1,93 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* */ +#define __x86_64_delta_ag9064_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_delta_ag9064_config_STRINGIFY_VALUE(_x) __x86_64_delta_ag9064_config_STRINGIFY_NAME(_x) +x86_64_delta_ag9064_config_settings_t x86_64_delta_ag9064_config_settings[] = +{ +#ifdef X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_SFP_COUNT + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_SFP_COUNT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_SFP_COUNT) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_SFP_COUNT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX + { __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX) }, +#else +{ X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_delta_ag9064_config_STRINGIFY_VALUE +#undef __x86_64_delta_ag9064_config_STRINGIFY_NAME + +const char* +x86_64_delta_ag9064_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_delta_ag9064_config_settings[i].name; i++) { + if(strcmp(x86_64_delta_ag9064_config_settings[i].name, setting)) { + return x86_64_delta_ag9064_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_delta_ag9064_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_delta_ag9064_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_delta_ag9064_config_settings[i].name, x86_64_delta_ag9064_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_enums.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_enums.c new file mode 100755 index 00000000..662adcb9 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_enums.c @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_int.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_int.h new file mode 100755 index 00000000..c732b470 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_int.h @@ -0,0 +1,13 @@ +/**************************************************************************//** + * + * x86_64_delta_ag9064 Internal Header + * + *****************************************************************************/ + +#ifndef __X86_64_DELTA_AG9064_INT_H__ +#define __X86_64_DELTA_AG9064_INT_H__ + +#include + + +#endif /* __X86_64_DELTA_AG9064_INT_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.c new file mode 100755 index 00000000..02075834 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.c @@ -0,0 +1,21 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +#include "x86_64_delta_ag9064_log.h" +/* + * x86_64_delta_ag9064 log struct. + */ +AIM_LOG_STRUCT_DEFINE +( + X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT +); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.h new file mode 100755 index 00000000..0af4324a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_log.h @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#ifndef __X86_64_DELTA_AG9064_LOG_H__ +#define __X86_64_DELTA_AG9064_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_delta_ag9064 +#include + +#endif /* __X86_64_DELTA_AG9064_LOG_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_module.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_module.c new file mode 100755 index 00000000..73e7e811 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_module.c @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +#include "x86_64_delta_ag9064_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_DELTA_AG9064_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_delta_ag9064_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_ucli.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_ucli.c new file mode 100755 index 00000000..a629b8b3 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_ucli.c @@ -0,0 +1,64 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +#if X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_delta_ag9064_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_delta_ag9064) +} + +/* */ +/****************************************************************************** + * + * These handler table(s) were autogenerated from the symbols in this + * source file. + * + *****************************************************************************/ +static ucli_command_handler_f x86_64_delta_ag9064_ucli_ucli_handlers__[] = +{ + x86_64_delta_ag9064_ucli_ucli__config__, + NULL +}; +/******************************************************************************/ +/* */ + +static ucli_module_t +x86_64_delta_ag9064_ucli_module__ = +{ + "x86_64_delta_ag9064_ucli", + NULL, + x86_64_delta_ag9064_ucli_ucli_handlers__, + NULL, + NULL, +}; + +ucli_node_t* +x86_64_delta_ag9064_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_delta_ag9064_ucli_module__); + n = ucli_node_create("x86_64_delta_ag9064", NULL, &x86_64_delta_ag9064_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_delta_ag9064")); + return n; +} + +#else +void* +x86_64_delta_ag9064_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/PKG.yml new file mode 100755 index 00000000..9ddbfd36 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-ag9064 REVISION=r0 + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/lib/x86-64-delta-ag9064-r0.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/lib/x86-64-delta-ag9064-r0.yml new file mode 100755 index 00000000..d60b5f90 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/lib/x86-64-delta-ag9064-r0.yml @@ -0,0 +1,30 @@ +--- + +###################################################################### +# +# platform-config for DELTA ag9064 +###################################################################### + +x86-64-delta-ag9064-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py new file mode 100755 index 00000000..d9083aca --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py @@ -0,0 +1,18 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_x86_64_delta_ag9064_r0(OnlPlatformDelta, + OnlPlatformPortConfig_64x100): + PLATFORM='x86-64-delta-ag9064-r0' + MODEL="ag9064" + SYS_OBJECT_ID=".9064.1" + + def baseconfig(self): + + # initiate eeprom + self.new_i2c_device('24c02', 0x56, 0) + + self.insmod('i2c-mei') + + return True + From 22bb3010e5fad43e8937553939467868650e31b3 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:47:11 -0800 Subject: [PATCH 093/244] Add installer support for using onie-sysinfo instead of /etc/machine.conf --- .../src/python/onl/install/App.py | 17 ++- .../src/python/onl/install/ShellApp.py | 106 +++++++++++++++++- .../src/python/onl/install/SystemInstall.py | 5 +- 3 files changed, 118 insertions(+), 10 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py index 69b83f8f..13465b90 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py @@ -17,7 +17,7 @@ import time from InstallUtils import InitrdContext from InstallUtils import SubprocessMixin from InstallUtils import ProcMountsParser -from ShellApp import OnieBootContext +from ShellApp import OnieBootContext, OnieSysinfo import ConfUtils, BaseInstall class App(SubprocessMixin, object): @@ -129,7 +129,7 @@ class App(SubprocessMixin, object): def runLocalOrChroot(self): if self.machineConf is None: - self.log.error("missing machine.conf") + self.log.error("missing onie-sysinfo or machine.conf") return 1 if self.installerConf is None: self.log.error("missing installer.conf") @@ -230,10 +230,17 @@ class App(SubprocessMixin, object): def runLocal(self): self.log.info("getting installer configuration") - if os.path.exists(ConfUtils.MachineConf.PATH): + osi = OnieSysinfo(log=self.log.getChild("onie-sysinfo")) + try: + halp = osi.help + except AttributeError: + halp = None + if halp is not None: + self.machineConf = osi + elif os.path.exists(ConfUtils.MachineConf.PATH): self.machineConf = ConfUtils.MachineConf() else: - self.log.warn("missing /etc/machine.conf from ONIE runtime") + self.log.warn("missing onie-sysinfo or /etc/machine.conf from ONIE runtime") self.machineConf = ConfUtils.MachineConf(path='/dev/null') self.installerConf = ConfUtils.InstallerConf() @@ -243,7 +250,7 @@ class App(SubprocessMixin, object): def findPlatform(self): plat = arch = None - if os.path.exists(ConfUtils.MachineConf.PATH): + if self.machineConf is not None: plat = getattr(self.machineConf, 'onie_platform', None) arch = getattr(self.machineConf, 'onie_arch', None) if plat and arch: diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py b/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py index 7c5f2c6c..fcf7f93d 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py @@ -15,9 +15,6 @@ from InstallUtils import ProcMountsParser, ProcMtdParser from InstallUtils import BlkidParser from InstallUtils import UbootInitrdContext -import onl.platform.current -from onl.sysconfig import sysconfig - class AppBase(SubprocessMixin, object): @property @@ -228,6 +225,105 @@ class Onie(AppBase): with OnieBootContext(log=self.log) as ctx: return self._runInitrdShell(ctx.initrd) +class OnieSysinfoApp(SubprocessMixin, object): + + PROG = "onie-sysinfo" + + def __init__(self, args=[], log=None): + + if log is not None: + self.log = log + else: + self.log = logging.getLogger(self.__class__.__name__) + self.args = args or ['-p',] + self.output = None + + def _runInitrdShell(self, initrd): + with InitrdContext(initrd=initrd, log=self.log) as ctx: + cmd = ['onie-sysinfo',] + cmd.extend(self.args) + cmd = ('chroot', ctx.dir, + '/bin/sh', '-c', 'IFS=;' + " ".join(cmd)) + try: + self.output = self.check_output(cmd) + ret = 0 + except subprocess.CalledProcessError, what: + self.log.error("failed command: %s", " ".join(what.cmd)) + for line in (what.output or "").splitlines(): + self.log.error(">>> %s", line) + ret = what.returncode + return ret + + def run(self): + with OnieBootContext(log=self.log) as ctx: + ret = self._runInitrdShell(ctx.initrd) + if self.output is not None: + sys.stdout.write(self.output) + return ret + + def shutdown(self): + pass + + @classmethod + def main(cls): + + logging.basicConfig() + logger = logging.getLogger(cls.PROG) + logger.setLevel(logging.INFO) + + args = list(sys.argv[1:]) + sysinfoArgs = [] + while args: + + if args[0] in ('-v', '--verbose',): + logger.setLevel(logging.DEBUG) + args.pop(0) + continue + + if args[0] in ('-q', '--quiet',): + logger.setLevel(logging.ERROR) + args.pop(0) + continue + + sysinfoArgs.append(args.pop(0)) + + app = cls(args=sysinfoArgs, log=logger) + try: + code = app.run() + except: + logger.exception("runner failed") + code = 1 + app.shutdown() + sys.exit(code) + +class OnieSysinfo(OnieSysinfoApp): + + def _runArgs(self, *args): + self.args = args + with OnieBootContext(log=self.log) as ctx: + ret = self._runInitrdShell(ctx.initrd) + if self.output is not None: + return self.output.rstrip() + raise AttributeError("cannot retrieve onie-sysinfo attribute via %s" % str(args)) + + @property + def help(self): + return self._runArgs('-h') + + @property + def onie_platform(self): + return self._runArgs('-p') + + @property + def onie_arch(self): + return self._runArgs('-c') + + @property + def onie_version(self): + return self._runArgs('-v') + + # XXX roth other switches too + class Loader(AppBase): """Application shell that uses the (installed) loader runtime.""" @@ -331,6 +427,7 @@ class Loader(AppBase): def run(self): + import onl.platform.current self.platform = onl.platform.current.OnlPlatform() self.pc = self.platform.platform_config @@ -353,6 +450,7 @@ class Upgrader(AppBase): def runGrub(self): + from onl.sysconfig import sysconfig d = sysconfig.upgrade.loader.package.dir for b in sysconfig.upgrade.loader.package.grub: p = os.path.join(d, b) @@ -365,6 +463,7 @@ class Upgrader(AppBase): def runUboot(self): + from onl.sysconfig import sysconfig d = sysconfig.upgrade.loader.package.dir for b in sysconfig.upgrade.loader.package.fit: p = os.path.join(d, b) @@ -377,6 +476,7 @@ class Upgrader(AppBase): def run(self): + import onl.platform.current self.platform = onl.platform.current.OnlPlatform() self.pc = self.platform.platform_config diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py index ad6ce72e..09348f52 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -60,8 +60,9 @@ class App(SubprocessMixin): src = os.path.join(octx.initrdDir, "etc/machine.conf") dst = os.path.join(ctx.dir, "etc/machine.conf") - self.log.debug("+ /bin/cp %s %s", src, dst) - shutil.copy2(src, dst) + if os.path.exists(src): + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) src = "/etc/fw_env.config" if os.path.exists(src): From feeb3c333060fa026f0f41862c74fc302ac6a4ac Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:47:35 -0800 Subject: [PATCH 094/244] Wrap access to ONIE's sysinfo tool --- packages/base/all/vendor-config-onl/src/bin/onie-sysinfo | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 packages/base/all/vendor-config-onl/src/bin/onie-sysinfo diff --git a/packages/base/all/vendor-config-onl/src/bin/onie-sysinfo b/packages/base/all/vendor-config-onl/src/bin/onie-sysinfo new file mode 100755 index 00000000..fabd2026 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/bin/onie-sysinfo @@ -0,0 +1,7 @@ +#!/usr/bin/python + +"""Run native onie-sysinfo +""" + +import onl.install.ShellApp +onl.install.ShellApp.OnieSysinfoApp.main() From 1fdf13b5067e7e6758671ecbe7adcfbabc773394 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:47:58 -0800 Subject: [PATCH 095/244] Loader should use onie-sysinfo --- .../vendor-config-onl/src/python/onl/upgrade/loader.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py index 29128db9..9ebec5b5 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py @@ -12,7 +12,7 @@ from onl.upgrade import ubase from onl.sysconfig import sysconfig from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite from onl.install import BaseInstall, ConfUtils, InstallUtils -from onl.install.ShellApp import OnieBootContext +from onl.install.ShellApp import OnieBootContext, OnieSysinfo import onl.platform.current import onl.versions @@ -83,8 +83,12 @@ class LoaderUpgrade_Fit(LoaderUpgradeBase): onlPlatform = onl.platform.current.OnlPlatform() with OnieBootContext(log=self.logger) as octx: - path = os.path.join(octx.initrdDir, "etc/machine.conf") - machineConf = ConfUtils.MachineConf(path=path) + if os.path.exists("/usr/bin/onie-shell"): + machineConf = OnieSysinfo(log=self.logger.getChild("onie-sysinfo")) + else: + path = os.path.join(octx.initrdDir, "etc/machine.conf") + if os.path.exists(path): + machineConf = ConfUtils.MachineConf(path=path) installerConf = ConfUtils.InstallerConf(path="/dev/null") # start with an empty installerConf, fill it in piece by piece From 7550367afb584aab6026c34034567006d80dbb95 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:48:08 -0800 Subject: [PATCH 096/244] Platform ident should use onie-sysinfo --- .../src/python/onl/platform/current.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py index bdf4c915..36e9e457 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py @@ -14,8 +14,9 @@ # platform-config packages. # ############################################################ -import os +import os, sys import importlib +import subprocess def platform_name_get(): # Determine the current platform name. @@ -23,6 +24,22 @@ def platform_name_get(): if os.path.exists("/etc/onl/platform"): with open("/etc/onl/platform", 'r') as f: platform=f.read().strip() + elif os.path.exists("/bin/onie-sysinfo"): + try: + platform = subprocess.check_output(('/bin/onie-sysinfo', '-p',)).strip() + except subprocess.CalledProcessError as what: + for line in (what.output or "").splitlines(): + sys.stderr.write(">>> %s\n" % line) + sys.stderr.write("onie-sysinfo failed with code %d\n" % what.returncode) + platform = None + elif os.path.exists("/usr/bin/onie-shell"): + try: + platform = subprocess.check_output(('/usr/bin/onie-shell', '-c', "onie-sysinfo -p",)).strip() + except subprocess.CalledProcessError as what: + for line in (what.output or "").splitlines(): + sys.stderr.write(">>> %s\n" % line) + sys.stderr.write("onie-sysinfo (onie-shell) failed with code %d\n" % what.returncode) + platform = None elif os.path.exists("/etc/machine.conf"): with open("/etc/machine.conf", 'r') as f: lines = f.readlines(False) From 8e1577f4cbe1662da47548fa2aaa709a3decf994 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:48:18 -0800 Subject: [PATCH 097/244] deprecated --- .../mellanox/vendor-config/src/python/mellanox/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py b/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py index 56cd4d71..db5e2d06 100644 --- a/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py +++ b/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py @@ -14,6 +14,7 @@ class OnlPlatformMellanox(OnlPlatformBase): print "Caching ONIE System EEPROM..." onie = self.onie_syseeprom_get() mc = self.onie_machine_get() + # XXX roth -- deprecated if 'onie_version' in mc: onie['0x29'] = mc['onie_version'] self.onie_syseeprom_set(onie) From 8e31b248e938c623a55982834e119d9ccb6764e6 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:48:26 -0800 Subject: [PATCH 098/244] Updated comment --- packages/base/all/vendor-config-onl/src/lib/install/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh index 0a5ea184..3835580f 100644 --- a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh +++ b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh @@ -122,7 +122,7 @@ installer_mkchroot() { mkdir -p "${rootdir}${TMPDIR}" fi - # export ONIE defines to the installer + # export ONIE defines to the installer, if they exist if test -r /etc/machine.conf; then cp /etc/machine.conf "${rootdir}/etc/machine.conf" fi From 19d289c45694468c655b4f92a6e60c286343f19b Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 26 Dec 2017 17:48:39 -0800 Subject: [PATCH 099/244] Use onie-sysinfo rather than /etc/machine.conf --- builds/any/installer/installer.sh.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/builds/any/installer/installer.sh.in b/builds/any/installer/installer.sh.in index e3d968aa..6711709d 100644 --- a/builds/any/installer/installer.sh.in +++ b/builds/any/installer/installer.sh.in @@ -144,7 +144,14 @@ if test "$installer_debug"; then fi # Pickup ONIE defines for this machine. -if test -r /etc/machine.conf; then +if test "$onie_platform"; then + : +else + onie_platform=$(onie-sysinfo -p 2>/dev/null) || : +fi +if test "$onie_platform"; then + : +elif test -r /etc/machine.conf; then . /etc/machine.conf fi @@ -252,7 +259,7 @@ if test "${onie_platform}"; then } else if test "$ARCH_X86"; then - echo "Missing onie_platform (invalid /etc/machine.conf)" 1>&2 + echo "Missing onie_platform (invalid or missing onie-sysinfo or /etc/machine.conf)" 1>&2 exit 1 fi # From 57195e97cad74fb03964fe18f7cb192738ddc164 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 27 Dec 2017 21:55:49 +0000 Subject: [PATCH 100/244] All editing of an existing json file. --- tools/sjson.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/sjson.py b/tools/sjson.py index 4c0543e9..4e3483b2 100755 --- a/tools/sjson.py +++ b/tools/sjson.py @@ -30,6 +30,7 @@ def setkeypath(d, kvt): ap=argparse.ArgumentParser(description="Simple JSON Generator.") +ap.add_argument("--in", metavar='FILENAME', help="Load json source data.", dest='_in') ap.add_argument("--kj", nargs=2, metavar=('KEY', 'FILE|STR'), help="Add json data.") ap.add_argument("--ky", nargs=2, metavar=('KEY', 'FILE|STR'), help="Add yaml jdata.") ap.add_argument("--kv", nargs=2, metavar=('KEY', 'VALUE'), help="Add key/value pair.") @@ -37,11 +38,18 @@ ap.add_argument("--kl", nargs='+', metavar=('KEY', 'ENTRY'), help="Add key/l ap.add_argument("--out", metavar='FILENAME', help="Write output to the given file. The default is stdout") ap.add_argument("--indent", nargs=1, help="Json output indentation value. Default is 2", default=2) ap.add_argument("--no-nl", action='store_true', help="No newline at the end of the output.") +ap.add_argument("--inout", metavar='FILENAME', help="Modify. Equivalent to --in FILENAME --out FILENAME") ops = ap.parse_args(); +if ops.inout: + ops._in = ops.inout + ops.out = ops.inout g_data={} +if ops._in: + g_data = json.load(open(ops._in)) + if ops.kj: (k, j) = ops.kj if os.path.exists(j): From b77d4dde8ea9855843b634a3d41be7b2dedc2dd3 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 28 Dec 2017 15:00:35 +0800 Subject: [PATCH 101/244] Revert "[as7712-32x] Enhance SFP driver to support multi-page reading of the eeprom for OOM" This reverts commit 5551c3111ab6906cef3ac725dc180995224c2a6b. --- .../builds/x86-64-accton-as7712-32x-sfp.c | 1137 ++++++----------- .../x86_64_accton_as7712_32x_r0/__init__.py | 64 +- 2 files changed, 450 insertions(+), 751 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c index 3ae35978..202d85a0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c @@ -48,10 +48,11 @@ #define EEPROM_SIZE 256 /* 256 byte eeprom */ #define BIT_INDEX(i) (1ULL << (i)) #define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ +#define I2C_RW_RETRY_COUNT 3 +#define I2C_RW_RETRY_INTERVAL 100 /* ms */ #define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) +#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) #define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 #define SFF8024_DEVICE_ID_SFP 0x3 @@ -59,73 +60,27 @@ #define SFF8024_DEVICE_ID_QSFP_PLUS 0xD #define SFF8024_DEVICE_ID_QSFP28 0x11 +#define SFF8472_DIAG_MON_TYPE_ADDR 92 +#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 +#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 +#define SFF8472_10G_BASE_MASK 0xF0 + #define SFF8436_RX_LOS_ADDR 3 #define SFF8436_TX_FAULT_ADDR 4 #define SFF8436_TX_DISABLE_ADDR 86 -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); enum sfp_sysfs_attributes { PRESENT, @@ -153,13 +108,14 @@ enum sfp_sysfs_attributes { /* SFP/QSFP common attributes for sysfs */ static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); /* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); @@ -174,6 +130,7 @@ static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); static struct attribute *qsfp_attributes[] = { &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_port_type.dev_attr.attr, &sensor_dev_attr_sfp_is_present.dev_attr.attr, &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, &sensor_dev_attr_sfp_rx_los.dev_attr.attr, @@ -194,56 +151,92 @@ static struct attribute *qsfp_attributes[] = { NULL }; +/* SFP msa attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); +static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); +static struct attribute *sfp_msa_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_port_type.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + NULL +}; + +/* SFP ddm attributes for sysfs */ +static struct attribute *sfp_ddm_attributes[] = { + NULL +}; + /* Platform dependent +++ */ #define CPLD_PORT_TO_FRONT_PORT(port) (port+1) enum port_numbers { -as7712_32x_port1, as7712_32x_port2, as7712_32x_port3, as7712_32x_port4, as7712_32x_port5, as7712_32x_port6, as7712_32x_port7, as7712_32x_port8, -as7712_32x_port9, as7712_32x_port10, as7712_32x_port11, as7712_32x_port12, as7712_32x_port13, as7712_32x_port14, as7712_32x_port15, as7712_32x_port16, -as7712_32x_port17, as7712_32x_port18, as7712_32x_port19, as7712_32x_port20, as7712_32x_port21, as7712_32x_port22, as7712_32x_port23, as7712_32x_port24, -as7712_32x_port25, as7712_32x_port26, as7712_32x_port27, as7712_32x_port28, as7712_32x_port29, as7712_32x_port30, as7712_32x_port31, as7712_32x_port32 +as7712_32x_sfp1, as7712_32x_sfp2, as7712_32x_sfp3, as7712_32x_sfp4, as7712_32x_sfp5, as7712_32x_sfp6, as7712_32x_sfp7, as7712_32x_sfp8, +as7712_32x_sfp9, as7712_32x_sfp10, as7712_32x_sfp11, as7712_32x_sfp12, as7712_32x_sfp13, as7712_32x_sfp14, as7712_32x_sfp15, as7712_32x_sfp16, +as7712_32x_sfp17, as7712_32x_sfp18, as7712_32x_sfp19, as7712_32x_sfp20, as7712_32x_sfp21, as7712_32x_sfp22, as7712_32x_sfp23, as7712_32x_sfp24, +as7712_32x_sfp25, as7712_32x_sfp26, as7712_32x_sfp27, as7712_32x_sfp28, as7712_32x_sfp29, as7712_32x_sfp30, as7712_32x_sfp31, as7712_32x_sfp32 }; #define I2C_DEV_ID(x) { #x, x} static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7712_32x_port1), -I2C_DEV_ID(as7712_32x_port2), -I2C_DEV_ID(as7712_32x_port3), -I2C_DEV_ID(as7712_32x_port4), -I2C_DEV_ID(as7712_32x_port5), -I2C_DEV_ID(as7712_32x_port6), -I2C_DEV_ID(as7712_32x_port7), -I2C_DEV_ID(as7712_32x_port8), -I2C_DEV_ID(as7712_32x_port9), -I2C_DEV_ID(as7712_32x_port10), -I2C_DEV_ID(as7712_32x_port11), -I2C_DEV_ID(as7712_32x_port12), -I2C_DEV_ID(as7712_32x_port13), -I2C_DEV_ID(as7712_32x_port14), -I2C_DEV_ID(as7712_32x_port15), -I2C_DEV_ID(as7712_32x_port16), -I2C_DEV_ID(as7712_32x_port17), -I2C_DEV_ID(as7712_32x_port18), -I2C_DEV_ID(as7712_32x_port19), -I2C_DEV_ID(as7712_32x_port20), -I2C_DEV_ID(as7712_32x_port21), -I2C_DEV_ID(as7712_32x_port22), -I2C_DEV_ID(as7712_32x_port23), -I2C_DEV_ID(as7712_32x_port24), -I2C_DEV_ID(as7712_32x_port25), -I2C_DEV_ID(as7712_32x_port26), -I2C_DEV_ID(as7712_32x_port27), -I2C_DEV_ID(as7712_32x_port28), -I2C_DEV_ID(as7712_32x_port29), -I2C_DEV_ID(as7712_32x_port30), -I2C_DEV_ID(as7712_32x_port31), -I2C_DEV_ID(as7712_32x_port32), +I2C_DEV_ID(as7712_32x_sfp1), +I2C_DEV_ID(as7712_32x_sfp2), +I2C_DEV_ID(as7712_32x_sfp3), +I2C_DEV_ID(as7712_32x_sfp4), +I2C_DEV_ID(as7712_32x_sfp5), +I2C_DEV_ID(as7712_32x_sfp6), +I2C_DEV_ID(as7712_32x_sfp7), +I2C_DEV_ID(as7712_32x_sfp8), +I2C_DEV_ID(as7712_32x_sfp9), +I2C_DEV_ID(as7712_32x_sfp10), +I2C_DEV_ID(as7712_32x_sfp11), +I2C_DEV_ID(as7712_32x_sfp12), +I2C_DEV_ID(as7712_32x_sfp13), +I2C_DEV_ID(as7712_32x_sfp14), +I2C_DEV_ID(as7712_32x_sfp15), +I2C_DEV_ID(as7712_32x_sfp16), +I2C_DEV_ID(as7712_32x_sfp17), +I2C_DEV_ID(as7712_32x_sfp18), +I2C_DEV_ID(as7712_32x_sfp19), +I2C_DEV_ID(as7712_32x_sfp20), +I2C_DEV_ID(as7712_32x_sfp21), +I2C_DEV_ID(as7712_32x_sfp22), +I2C_DEV_ID(as7712_32x_sfp23), +I2C_DEV_ID(as7712_32x_sfp24), +I2C_DEV_ID(as7712_32x_sfp25), +I2C_DEV_ID(as7712_32x_sfp26), +I2C_DEV_ID(as7712_32x_sfp27), +I2C_DEV_ID(as7712_32x_sfp28), +I2C_DEV_ID(as7712_32x_sfp29), +I2C_DEV_ID(as7712_32x_sfp30), +I2C_DEV_ID(as7712_32x_sfp31), +I2C_DEV_ID(as7712_32x_sfp32), { /* LIST END */ } }; MODULE_DEVICE_TABLE(i2c, sfp_device_id); /* Platform dependent --- */ +/* + * list of valid port types + * note OOM_PORT_TYPE_NOT_PRESENT to indicate no + * module is present in this port + */ +typedef enum oom_driver_port_type_e { + OOM_DRIVER_PORT_TYPE_INVALID, + OOM_DRIVER_PORT_TYPE_NOT_PRESENT, + OOM_DRIVER_PORT_TYPE_SFP, + OOM_DRIVER_PORT_TYPE_SFP_PLUS, + OOM_DRIVER_PORT_TYPE_QSFP, + OOM_DRIVER_PORT_TYPE_QSFP_PLUS, + OOM_DRIVER_PORT_TYPE_QSFP28 +} oom_driver_port_type_t; + enum driver_type_e { DRIVER_TYPE_SFP_MSA, DRIVER_TYPE_SFP_DDM, @@ -258,6 +251,24 @@ struct eeprom_data { struct bin_attribute bin; /* eeprom data */ }; +struct sfp_msa_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u64 status[6]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss + 3 => device id + 4 => 10G Ethernet Compliance Codes + to distinguish SFP or SFP+ + 5 => DIAGNOSTIC MONITORING TYPE */ + struct eeprom_data eeprom; +}; + +struct sfp_ddm_data { + struct eeprom_data eeprom; +}; + struct qsfp_data { char valid; /* !=0 if registers are valid */ unsigned long last_updated; /* In jiffies */ @@ -265,6 +276,7 @@ struct qsfp_data { /* index 0 => tx_fail 1 => tx_disable 2 => rx_loss */ + u8 device_id; struct eeprom_data eeprom; }; @@ -273,22 +285,16 @@ struct sfp_port_data { struct mutex update_lock; enum driver_type_e driver_type; int port; /* CPLD port index */ + oom_driver_port_type_t port_type; u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + struct sfp_msa_data *msa; + struct sfp_ddm_data *ddm; struct qsfp_data *qsfp; struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif }; -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf) { @@ -329,8 +335,26 @@ exit: return (status < 0) ? ERR_PTR(status) : data; } +static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) +{ + return NULL; +} + /* Platform dependent --- */ +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_set_tx_disable(dev, da, buf, count); + } + + return 0; +} + static int sfp_is_port_present(struct i2c_client *client, int port) { struct sfp_port_data *data = i2c_get_clientdata(client); @@ -382,6 +406,92 @@ static ssize_t show_present(struct device *dev, struct device_attribute *da, } /* Platform dependent --- */ +static struct sfp_port_data *sfp_update_port_type(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + u8 buf = 0; + int status; + + mutex_lock(&data->update_lock); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + { + status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); + if (unlikely(status < 0)) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + if (buf != SFF8024_DEVICE_ID_SFP) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); + if (unlikely(status < 0)) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); + data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; + break; + } + case DRIVER_TYPE_QSFP: + { + status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); + if (unlikely(status < 0)) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); + switch (buf) { + case SFF8024_DEVICE_ID_QSFP: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; + break; + case SFF8024_DEVICE_ID_QSFP_PLUS: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; + break; + case SFF8024_DEVICE_ID_QSFP28: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; + break; + default: + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + break; + } + default: + break; + } + + mutex_unlock(&data->update_lock); + return data; +} + +static ssize_t show_port_type(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + if (!present) { + return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); + } + + sfp_update_port_type(dev); + return sprintf(buf, "%d\n", data->port_type); +} + static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -544,6 +654,82 @@ static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute * return count; } +static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + char ddm; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (status == 0) { + /* port is not present */ + return -ENODEV; + } + + status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); + if (unlikely(status < 0)) { + return status; + } + + return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); +} + +/* Platform dependent +++ */ +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 val = 0, index = 0; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_show_tx_rx_status(dev, da, buf); + } + + data = sfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + if(attr->index == RX_LOS_ALL) { + int i = 0; + u8 values[6] = {0}; + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = (u8)(data->msa->status[2] >> (i * 8)); + } + + /** Return values 1 -> 48 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5]); + } + + switch (attr->index) { + case TX_FAULT: + index = 0; + break; + case TX_DISABLE: + index = 1; + break; + case RX_LOS: + index = 2; + break; + default: + return 0; + } + + val = !!(data->msa->status[index] & BIT_INDEX(data->port)); + return sprintf(buf, "%d\n", val); +} +/* Platform dependent --- */ static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, int data_len) { @@ -594,7 +780,6 @@ static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const cha } -#if (MULTIPAGE_SUPPORT == 0) static ssize_t sfp_port_write(struct sfp_port_data *data, const char *buf, loff_t off, size_t count) { @@ -629,7 +814,7 @@ static ssize_t sfp_port_write(struct sfp_port_data *data, mutex_unlock(&data->update_lock); return retval; } -#endif + static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -650,11 +835,7 @@ static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, return -ENODEV; } -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else return sfp_port_write(data, buf, off, count); -#endif } static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, @@ -717,495 +898,6 @@ abort: #endif } -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else static ssize_t sfp_port_read(struct sfp_port_data *data, char *buf, loff_t off, size_t count) { @@ -1243,7 +935,6 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, return retval; } -#endif static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, @@ -1252,8 +943,8 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, int present; struct sfp_port_data *data; DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); if (IS_ERR_VALUE(present)) { return present; @@ -1264,18 +955,10 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, return -ENODEV; } -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else return sfp_port_read(data, buf, off, count); -#endif } -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif { int err; @@ -1284,11 +967,7 @@ static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eep eeprom->attr.mode = S_IWUSR | S_IRUGO; eeprom->read = sfp_bin_read; eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else eeprom->size = EEPROM_SIZE; -#endif /* Create eeprom file */ err = sysfs_create_bin_file(kobj, eeprom); @@ -1305,8 +984,10 @@ static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute * return 0; } +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; -#if (MULTIPAGE_SUPPORT == 0) static int sfp_i2c_check_functionality(struct i2c_client *client) { #if USE_I2C_BLOCK_READ @@ -1315,8 +996,96 @@ static int sfp_i2c_check_functionality(struct i2c_client *client) return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); #endif } -#endif +static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_msa_data **data) +{ + int status; + struct sfp_msa_data *msa; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); + if (!msa) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = msa; + dev_info(&client->dev, "sfp msa '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); +exit_free: + kfree(msa); +exit: + + return status; +} + +static const struct attribute_group sfp_ddm_group = { + .attrs = sfp_ddm_attributes, +}; + +static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_ddm_data **data) +{ + int status; + struct sfp_ddm_data *ddm; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); + if (!ddm) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = ddm; + dev_info(&client->dev, "sfp ddm '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); +exit_free: + kfree(ddm); +exit: + + return status; +} static const struct attribute_group qsfp_group = { .attrs = qsfp_attributes, @@ -1328,12 +1097,10 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev int status; struct qsfp_data *qsfp; -#if (MULTIPAGE_SUPPORT == 0) if (!sfp_i2c_check_functionality(client)) { status = -EIO; goto exit; } -#endif qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); if (!qsfp) { @@ -1348,11 +1115,7 @@ static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev } /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif if (status) { goto exit_remove; } @@ -1375,108 +1138,44 @@ exit: static int sfp_device_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { - int ret = 0; struct sfp_port_data *data = NULL; - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as7712_32x_port1 || dev_id->driver_data > as7712_32x_port32) { - return -ENXIO; - } - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); if (!data) { return -ENOMEM; } -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - i2c_set_clientdata(client, data); mutex_init(&data->update_lock); data->port = dev_id->driver_data; data->client = client; - data->driver_type = DRIVER_TYPE_QSFP; - - ret = qsfp_probe(client, dev_id, &data->qsfp); - if (ret < 0) { - goto exit_kfree_buf; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; } - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; + + data->driver_type = DRIVER_TYPE_QSFP; + return qsfp_probe(client, dev_id, &data->qsfp); } /* Platform dependent --- */ -static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); + kfree(data); + return 0; +} + +static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); + kfree(data); + return 0; +} + +static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) { sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); sysfs_remove_group(&client->dev.kobj, &qsfp_group); @@ -1486,18 +1185,18 @@ static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) static int sfp_device_remove(struct i2c_client *client) { - int ret = 0; struct sfp_port_data *data = i2c_get_clientdata(client); -#if (MULTIPAGE_SUPPORT == 1) - kfree(data->writebuf); -#endif - if (data->driver_type == DRIVER_TYPE_QSFP) { - ret = qsfp_remove(client, data->qsfp); + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + return sfp_msa_remove(client, data->msa); + case DRIVER_TYPE_SFP_DDM: + return sfp_ddm_remove(client, data->ddm); + case DRIVER_TYPE_QSFP: + return qfp_remove(client, data->qsfp); } - kfree(data); - return ret; + return 0; } /* Addresses scanned diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py index 32ced71b..e460484f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py @@ -57,38 +57,38 @@ class OnlPlatform_x86_64_accton_as7712_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 self.new_i2c_devices([ - ('as7712_32x_port9', 0x50, 18), - ('as7712_32x_port10', 0x50, 19), - ('as7712_32x_port11', 0x50, 20), - ('as7712_32x_port12', 0x50, 21), - ('as7712_32x_port1', 0x50, 22), - ('as7712_32x_port2', 0x50, 23), - ('as7712_32x_port3', 0x50, 24), - ('as7712_32x_port4', 0x50, 25), - ('as7712_32x_port6', 0x50, 26), - ('as7712_32x_port5', 0x50, 27), - ('as7712_32x_port8', 0x50, 28), - ('as7712_32x_port7', 0x50, 29), - ('as7712_32x_port13', 0x50, 30), - ('as7712_32x_port14', 0x50, 31), - ('as7712_32x_port15', 0x50, 32), - ('as7712_32x_port16', 0x50, 33), - ('as7712_32x_port17', 0x50, 34), - ('as7712_32x_port18', 0x50, 35), - ('as7712_32x_port19', 0x50, 36), - ('as7712_32x_port20', 0x50, 37), - ('as7712_32x_port25', 0x50, 38), - ('as7712_32x_port26', 0x50, 39), - ('as7712_32x_port27', 0x50, 40), - ('as7712_32x_port28', 0x50, 41), - ('as7712_32x_port29', 0x50, 42), - ('as7712_32x_port30', 0x50, 43), - ('as7712_32x_port31', 0x50, 44), - ('as7712_32x_port32', 0x50, 45), - ('as7712_32x_port21', 0x50, 46), - ('as7712_32x_port22', 0x50, 47), - ('as7712_32x_port23', 0x50, 48), - ('as7712_32x_port24', 0x50, 49), + ('as7712_32x_sfp9', 0x50, 18), + ('as7712_32x_sfp10', 0x50, 19), + ('as7712_32x_sfp11', 0x50, 20), + ('as7712_32x_sfp12', 0x50, 21), + ('as7712_32x_sfp1', 0x50, 22), + ('as7712_32x_sfp2', 0x50, 23), + ('as7712_32x_sfp3', 0x50, 24), + ('as7712_32x_sfp4', 0x50, 25), + ('as7712_32x_sfp6', 0x50, 26), + ('as7712_32x_sfp5', 0x50, 27), + ('as7712_32x_sfp8', 0x50, 28), + ('as7712_32x_sfp7', 0x50, 29), + ('as7712_32x_sfp13', 0x50, 30), + ('as7712_32x_sfp14', 0x50, 31), + ('as7712_32x_sfp15', 0x50, 32), + ('as7712_32x_sfp16', 0x50, 33), + ('as7712_32x_sfp17', 0x50, 34), + ('as7712_32x_sfp18', 0x50, 35), + ('as7712_32x_sfp19', 0x50, 36), + ('as7712_32x_sfp20', 0x50, 37), + ('as7712_32x_sfp25', 0x50, 38), + ('as7712_32x_sfp26', 0x50, 39), + ('as7712_32x_sfp27', 0x50, 40), + ('as7712_32x_sfp28', 0x50, 41), + ('as7712_32x_sfp29', 0x50, 42), + ('as7712_32x_sfp30', 0x50, 43), + ('as7712_32x_sfp31', 0x50, 44), + ('as7712_32x_sfp32', 0x50, 45), + ('as7712_32x_sfp21', 0x50, 46), + ('as7712_32x_sfp22', 0x50, 47), + ('as7712_32x_sfp23', 0x50, 48), + ('as7712_32x_sfp24', 0x50, 49), ]) self.new_i2c_device('24c02', 0x57, 1) From cfdcc95d70cf4e1d493ed614505d86ebf8fdc680 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 28 Dec 2017 15:10:10 +0800 Subject: [PATCH 102/244] [as7712-32x] Add support for OOM --- .../accton/x86-64/modules/builds/optoe.c | 1148 +++++++++++++++ .../builds/x86-64-accton-as7712-32x-cpld1.c | 558 ++++++++ .../builds/x86-64-accton-as7712-32x-leds.c | 8 +- .../builds/x86-64-accton-as7712-32x-psu.c | 4 +- .../builds/x86-64-accton-as7712-32x-sfp.c | 1232 ----------------- .../onlp/builds/src/module/src/sfpi.c | 61 +- .../x86_64_accton_as7712_32x_r0/__init__.py | 102 +- 7 files changed, 1794 insertions(+), 1319 deletions(-) create mode 100644 packages/platforms/accton/x86-64/modules/builds/optoe.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-cpld1.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c diff --git a/packages/platforms/accton/x86-64/modules/builds/optoe.c b/packages/platforms/accton/x86-64/modules/builds/optoe.c new file mode 100644 index 00000000..16be2fef --- /dev/null +++ b/packages/platforms/accton/x86-64/modules/builds/optoe.c @@ -0,0 +1,1148 @@ +/* + * optoe.c - A driver to read and write the EEPROM on optical transceivers + * (SFP, QSFP and similar I2C based devices) + * + * Copyright (C) 2014 Cumulus networks Inc. + * Copyright (C) 2017 Finisar Corp. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Freeoftware Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +/* + * Description: + * a) Optical transceiver EEPROM read/write transactions are just like + * the at24 eeproms managed by the at24.c i2c driver + * b) The register/memory layout is up to 256 128 byte pages defined by + * a "pages valid" register and switched via a "page select" + * register as explained in below diagram. + * c) 256 bytes are mapped at a time. 'Lower page 00h' is the first 128 + * bytes of address space, and always references the same + * location, independent of the page select register. + * All mapped pages are mapped into the upper 128 bytes + * (offset 128-255) of the i2c address. + * d) Devices with one I2C address (eg QSFP) use I2C address 0x50 + * (A0h in the spec), and map all pages in the upper 128 bytes + * of that address. + * e) Devices with two I2C addresses (eg SFP) have 256 bytes of data + * at I2C address 0x50, and 256 bytes of data at I2C address + * 0x51 (A2h in the spec). Page selection and paged access + * only apply to this second I2C address (0x51). + * e) The address space is presented, by the driver, as a linear + * address space. For devices with one I2C client at address + * 0x50 (eg QSFP), offset 0-127 are in the lower + * half of address 50/A0h/client[0]. Offset 128-255 are in + * page 0, 256-383 are page 1, etc. More generally, offset + * 'n' resides in page (n/128)-1. ('page -1' is the lower + * half, offset 0-127). + * f) For devices with two I2C clients at address 0x50 and 0x51 (eg SFP), + * the address space places offset 0-127 in the lower + * half of 50/A0/client[0], offset 128-255 in the upper + * half. Offset 256-383 is in the lower half of 51/A2/client[1]. + * Offset 384-511 is in page 0, in the upper half of 51/A2/... + * Offset 512-639 is in page 1, in the upper half of 51/A2/... + * Offset 'n' is in page (n/128)-3 (for n > 383) + * + * One I2c addressed (eg QSFP) Memory Map + * + * 2-Wire Serial Address: 1010000x + * + * Lower Page 00h (128 bytes) + * ===================== + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * | | + * |Page Select Byte(127)| + * ===================== + * | + * | + * | + * | + * V + * ------------------------------------------------------------ + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * | | | | + * V V V V + * ------------ -------------- --------------- -------------- + * | | | | | | | | + * | Upper | | Upper | | Upper | | Upper | + * | Page 00h | | Page 01h | | Page 02h | | Page 03h | + * | | | (Optional) | | (Optional) | | (Optional | + * | | | | | | | for Cable | + * | | | | | | | Assemblies) | + * | ID | | AST | | User | | | + * | Fields | | Table | | EEPROM Data | | | + * | | | | | | | | + * | | | | | | | | + * | | | | | | | | + * ------------ -------------- --------------- -------------- + * + * The SFF 8436 (QSFP) spec only defines the 4 pages described above. + * In anticipation of future applications and devices, this driver + * supports access to the full architected range, 256 pages. + * + **/ + +/* #define DEBUG 1 */ + +#undef EEPROM_CLASS +#ifdef CONFIG_EEPROM_CLASS +#define EEPROM_CLASS +#endif +#ifdef CONFIG_EEPROM_CLASS_MODULE +#define EEPROM_CLASS +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * The optoe driver is for read/write access to the EEPROM on standard + * I2C based optical transceivers (SFP, QSFP, etc) + * + * While based on the at24 driver, it eliminates code that supports other + * types of I2C EEPROMs, and adds support for pages accessed through the + * page-select register at offset 127. + */ + +struct optoe_platform_data { + u32 byte_len; /* size (sum of all addr) */ + u16 page_size; /* for writes */ + u8 flags; + + void (*setup)(struct memory_accessor *, void *context); + void *context; +#ifdef EEPROM_CLASS + struct eeprom_platform_data *eeprom_data; /* extra data for the eeprom_class */ +#endif +}; + +#ifdef EEPROM_CLASS +#include +#endif + +#include + +/* fundamental unit of addressing for EEPROM */ +#define OPTOE_PAGE_SIZE 128 +/* + * Single address devices (eg QSFP) have 256 pages, plus the unpaged + * low 128 bytes. If the device does not support paging, it is + * only 2 'pages' long. + */ +#define OPTOE_ARCH_PAGES 256 +#define ONE_ADDR_EEPROM_SIZE ((1 + OPTOE_ARCH_PAGES) * OPTOE_PAGE_SIZE) +#define ONE_ADDR_EEPROM_UNPAGED_SIZE (2 * OPTOE_PAGE_SIZE) +/* + * Dual address devices (eg SFP) have 256 pages, plus the unpaged + * low 128 bytes, plus 256 bytes at 0x50. If the device does not + * support paging, it is 4 'pages' long. + */ +#define TWO_ADDR_EEPROM_SIZE ((3 + OPTOE_ARCH_PAGES) * OPTOE_PAGE_SIZE) +#define TWO_ADDR_EEPROM_UNPAGED_SIZE (4 * OPTOE_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define OPTOE_PAGE_SELECT_REG 0x7F +#define ONE_ADDR_PAGEABLE_REG 0x02 +#define ONE_ADDR_NOT_PAGEABLE (1<<2) +#define TWO_ADDR_PAGEABLE_REG 0x40 +#define TWO_ADDR_PAGEABLE (1<<4) +#define OPTOE_ID_REG 0 + +/* The maximum length of a port name */ +#define MAX_PORT_NAME_LEN 20 +struct optoe_data { + struct optoe_platform_data chip; + struct memory_accessor macc; + int use_smbus; + char port_name[MAX_PORT_NAME_LEN]; + + /* + * Lock protects against activities from other Linux tasks, + * but not from changes by other I2C masters. + */ + struct mutex lock; + struct bin_attribute bin; + struct attribute_group attr_group; + + u8 *writebuf; + unsigned write_max; + + unsigned num_addresses; + +#ifdef EEPROM_CLASS + struct eeprom_device *eeprom_dev; +#endif + + /* dev_class: ONE_ADDR (QSFP) or TWO_ADDR (SFP) */ + int dev_class; + + struct i2c_client *client[]; +}; + +typedef enum optoe_opcode { + OPTOE_READ_OP = 0, + OPTOE_WRITE_OP = 1 +} optoe_opcode_e; + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = OPTOE_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +/* + * flags to distinguish one-address (QSFP family) from two-address (SFP family) + * If the family is not known, figure it out when the device is accessed + */ +#define ONE_ADDR 1 +#define TWO_ADDR 2 + +static const struct i2c_device_id optoe_ids[] = { + { "optoe1", ONE_ADDR }, + { "optoe2", TWO_ADDR }, + { "sff8436", ONE_ADDR }, + { "24c04", TWO_ADDR }, + { /* END OF LIST */ } +}; +MODULE_DEVICE_TABLE(i2c, optoe_ids); + +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both single address (eg QSFP) and two address (eg SFP). + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ + +static uint8_t optoe_translate_offset(struct optoe_data *optoe, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = optoe->client[0]; + + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (optoe->dev_class == TWO_ADDR) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = optoe->client[1]; + *offset -= 256; + } + } + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < OPTOE_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = OPTOE_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t optoe_eeprom_read(struct optoe_data *optoe, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t optoe_eeprom_write(struct optoe_data *optoe, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > optoe->write_max) + count = optoe->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, OPTOE_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = optoe->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (optoe->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t optoe_eeprom_update_client(struct optoe_data *optoe, + char *buf, loff_t off, + size_t count, optoe_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + uint8_t page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = optoe_translate_offset(optoe, &phy_offset, &client); + dev_dbg(&client->dev, + "optoe_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = optoe_eeprom_write(optoe, client, &page, + OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == OPTOE_READ_OP) { + status = optoe_eeprom_read(optoe, client, + buf, phy_offset, count); + } else { + status = optoe_eeprom_write(optoe, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = optoe_eeprom_write(optoe, client, &page, + OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to 0 failed:%d!\n", ret); + /* error only if nothing has been transferred */ + if (retval == 0) retval = ret; + } + } + return retval; +} + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t optoe_page_legal(struct optoe_data *optoe, + loff_t off, size_t len) +{ + struct i2c_client *client = optoe->client[0]; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (optoe->dev_class == TWO_ADDR) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= TWO_ADDR_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= TWO_ADDR_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = optoe_eeprom_read(optoe, client, ®val, + TWO_ADDR_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & TWO_ADDR_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = TWO_ADDR_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= TWO_ADDR_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = TWO_ADDR_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } else { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= ONE_ADDR_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= ONE_ADDR_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = optoe_eeprom_read(optoe, client, ®val, + ONE_ADDR_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & ONE_ADDR_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + if (off >= ONE_ADDR_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = ONE_ADDR_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = ONE_ADDR_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + return len; +} + +static ssize_t optoe_read_write(struct optoe_data *optoe, + char *buf, loff_t off, size_t len, optoe_opcode_e opcode) +{ + struct i2c_client *client = optoe->client[0]; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + dev_dbg(&client->dev, + "optoe_read_write: off %lld len:%ld, opcode:%s\n", + off, (long int) len, (opcode == OPTOE_READ_OP) ? "r": "w"); + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&optoe->lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + status = optoe_page_legal(optoe, off, len); + if (status < 0) { + goto err; + } + len = status; + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * OPTOE_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + OPTOE_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = OPTOE_PAGE_SIZE - off; + } else { + chunk_offset = chunk_start_offset; + if (pending_len > OPTOE_PAGE_SIZE) + chunk_len = OPTOE_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = optoe_eeprom_update_client(optoe, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "optoe_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&optoe->lock); + + return retval; + +err: + mutex_unlock(&optoe->lock); + + return status; +} + +static ssize_t optoe_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = to_i2c_client(container_of(kobj, + struct device, kobj)); + struct optoe_data *optoe = i2c_get_clientdata(client); + + return optoe_read_write(optoe, buf, off, count, OPTOE_READ_OP); +} + + +static ssize_t optoe_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = to_i2c_client(container_of(kobj, + struct device, kobj)); + struct optoe_data *optoe = i2c_get_clientdata(client); + + return optoe_read_write(optoe, buf, off, count, OPTOE_WRITE_OP); +} +/*-------------------------------------------------------------------------*/ + +/* + * This lets other kernel code access the eeprom data. For example, it + * might hold a board's Ethernet address, or board-specific calibration + * data generated on the manufacturing floor. + */ + +static ssize_t optoe_macc_read(struct memory_accessor *macc, + char *buf, off_t offset, size_t count) +{ + struct optoe_data *optoe = container_of(macc, + struct optoe_data, macc); + + return optoe_read_write(optoe, buf, offset, count, OPTOE_READ_OP); +} + +static ssize_t optoe_macc_write(struct memory_accessor *macc, + const char *buf, off_t offset, size_t count) +{ + struct optoe_data *optoe = container_of(macc, + struct optoe_data, macc); + + return optoe_read_write(optoe, (char *) buf, offset, + count, OPTOE_WRITE_OP); +} + +/*-------------------------------------------------------------------------*/ + +static int optoe_remove(struct i2c_client *client) +{ + struct optoe_data *optoe; + int i; + + optoe = i2c_get_clientdata(client); + sysfs_remove_group(&client->dev.kobj, &optoe->attr_group); + sysfs_remove_bin_file(&client->dev.kobj, &optoe->bin); + + for (i = 1; i < optoe->num_addresses; i++) + i2c_unregister_device(optoe->client[i]); + +#ifdef EEPROM_CLASS + eeprom_device_unregister(optoe->eeprom_dev); +#endif + + kfree(optoe->writebuf); + kfree(optoe); + return 0; +} + +static ssize_t show_port_name(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + ssize_t count; + + mutex_lock(&optoe->lock); + count = sprintf(buf, "%s\n", optoe->port_name); + mutex_unlock(&optoe->lock); + + return count; +} + +static ssize_t set_port_name(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + char port_name[MAX_PORT_NAME_LEN]; + + /* no checking, this value is not used except by show_port_name */ + + if (sscanf(buf, "%19s", port_name) != 1) + return -EINVAL; + + mutex_lock(&optoe->lock); + strcpy(optoe->port_name, port_name); + mutex_unlock(&optoe->lock); + + return count; +} + +static DEVICE_ATTR(port_name, S_IRUGO | S_IWUSR, + show_port_name, set_port_name); + +static ssize_t show_dev_class(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + ssize_t count; + + mutex_lock(&optoe->lock); + count = sprintf(buf, "%d\n", optoe->dev_class); + mutex_unlock(&optoe->lock); + + return count; +} + +static ssize_t set_dev_class(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct optoe_data *optoe = i2c_get_clientdata(client); + int dev_class; + + /* + * dev_class is actually the number of sfp ports used, thus + * legal values are "1" (QSFP class) and "2" (SFP class) + */ + if (sscanf(buf, "%d", &dev_class) != 1 || + dev_class < 1 || dev_class > 2) + return -EINVAL; + + mutex_lock(&optoe->lock); + optoe->dev_class = dev_class; + mutex_unlock(&optoe->lock); + + return count; +} + +static DEVICE_ATTR(dev_class, S_IRUGO | S_IWUSR, + show_dev_class, set_dev_class); + +static struct attribute *optoe_attrs[] = { + &dev_attr_port_name.attr, + &dev_attr_dev_class.attr, + NULL, +}; + +static struct attribute_group optoe_attr_group = { + .attrs = optoe_attrs, +}; + +static int optoe_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int err; + int use_smbus = 0; + struct optoe_platform_data chip; + struct optoe_data *optoe; + int num_addresses = 0; + int i = 0; + + if (client->addr != 0x50) { + dev_dbg(&client->dev, "probe, bad i2c addr: 0x%x\n", + client->addr); + err = -EINVAL; + goto exit; + } + + if (client->dev.platform_data) { + chip = *(struct optoe_platform_data *)client->dev.platform_data; + dev_dbg(&client->dev, "probe, chip provided, flags:0x%x; name: %s\n", chip.flags, client->name); + } else { + if (!id->driver_data) { + err = -ENODEV; + goto exit; + } + dev_dbg(&client->dev, "probe, building chip\n"); + chip.flags = 0; + chip.setup = NULL; + chip.context = NULL; +#ifdef EEPROM_CLASS + chip.eeprom_data = NULL; +#endif + } + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + err = -EPFNOSUPPORT; + goto exit; + } + } + + + /* + * Make room for two i2c clients + */ + num_addresses = 2; + + optoe = kzalloc(sizeof(struct optoe_data) + + num_addresses * sizeof(struct i2c_client *), + GFP_KERNEL); + if (!optoe) { + err = -ENOMEM; + goto exit; + } + + mutex_init(&optoe->lock); + + /* determine whether this is a one-address or two-address module */ + if ((strcmp(client->name, "optoe1") == 0) || + (strcmp(client->name, "sff8436") == 0)) { + /* one-address (eg QSFP) family */ + optoe->dev_class = ONE_ADDR; + chip.byte_len = ONE_ADDR_EEPROM_SIZE; + num_addresses = 1; + } else if ((strcmp(client->name, "optoe2") == 0) || + (strcmp(client->name, "24c04") == 0)) { + /* SFP family */ + optoe->dev_class = TWO_ADDR; + chip.byte_len = TWO_ADDR_EEPROM_SIZE; + } else { /* those were the only two choices */ + err = -EINVAL; + goto exit; + } + + dev_dbg(&client->dev, "dev_class: %d\n", optoe->dev_class); + optoe->use_smbus = use_smbus; + optoe->chip = chip; + optoe->num_addresses = num_addresses; + strcpy(optoe->port_name, "unitialized"); + + /* + * Export the EEPROM bytes through sysfs, since that's convenient. + * By default, only root should see the data (maybe passwords etc) + */ + sysfs_bin_attr_init(&optoe->bin); + optoe->bin.attr.name = "eeprom"; + optoe->bin.attr.mode = S_IRUGO; + optoe->bin.read = optoe_bin_read; + optoe->bin.size = chip.byte_len; + + optoe->macc.read = optoe_macc_read; + + if (!use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + optoe->macc.write = optoe_macc_write; + + optoe->bin.write = optoe_bin_write; + optoe->bin.attr.mode |= S_IWUSR; + + if (write_max > io_limit) + write_max = io_limit; + if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + optoe->write_max = write_max; + + /* buffer (data + address at the beginning) */ + optoe->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!optoe->writebuf) { + err = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + optoe->client[0] = client; + + /* use a dummy I2C device for two-address chips */ + for (i = 1; i < num_addresses; i++) { + optoe->client[i] = i2c_new_dummy(client->adapter, + client->addr + i); + if (!optoe->client[i]) { + dev_err(&client->dev, "address 0x%02x unavailable\n", + client->addr + i); + err = -EADDRINUSE; + goto err_struct; + } + } + + /* create the sysfs eeprom file */ + err = sysfs_create_bin_file(&client->dev.kobj, &optoe->bin); + if (err) + goto err_struct; + + optoe->attr_group = optoe_attr_group; + + err = sysfs_create_group(&client->dev.kobj, &optoe->attr_group); + if (err) { + dev_err(&client->dev, "failed to create sysfs attribute group.\n"); + goto err_struct; + } +#ifdef EEPROM_CLASS + optoe->eeprom_dev = eeprom_device_register(&client->dev, + chip.eeprom_data); + if (IS_ERR(optoe->eeprom_dev)) { + dev_err(&client->dev, "error registering eeprom device.\n"); + err = PTR_ERR(optoe->eeprom_dev); + goto err_sysfs_cleanup; + } +#endif + + i2c_set_clientdata(client, optoe); + + dev_info(&client->dev, "%zu byte %s EEPROM, %s\n", + optoe->bin.size, client->name, + optoe->bin.write ? "read/write" : "read-only"); + + if (use_smbus == I2C_SMBUS_WORD_DATA || + use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } + + if (chip.setup) + chip.setup(&optoe->macc, chip.context); + + return 0; + +#ifdef EEPROM_CLASS +err_sysfs_cleanup: + sysfs_remove_group(&client->dev.kobj, &optoe->attr_group); + sysfs_remove_bin_file(&client->dev.kobj, &optoe->bin); +#endif + +err_struct: + for (i = 1; i < num_addresses; i++) { + if (optoe->client[i]) + i2c_unregister_device(optoe->client[i]); + } + + kfree(optoe->writebuf); +exit_kfree: + kfree(optoe); +exit: + dev_dbg(&client->dev, "probe error %d\n", err); + + return err; +} + +/*-------------------------------------------------------------------------*/ + +static struct i2c_driver optoe_driver = { + .driver = { + .name = "optoe", + .owner = THIS_MODULE, + }, + .probe = optoe_probe, + .remove = optoe_remove, + .id_table = optoe_ids, +}; + +static int __init optoe_init(void) +{ + + if (!io_limit) { + pr_err("optoe: io_limit must not be 0!\n"); + return -EINVAL; + } + + io_limit = rounddown_pow_of_two(io_limit); + return i2c_add_driver(&optoe_driver); +} +module_init(optoe_init); + +static void __exit optoe_exit(void) +{ + i2c_del_driver(&optoe_driver); +} +module_exit(optoe_exit); + +MODULE_DESCRIPTION("Driver for optical transceiver (SFP, QSFP, ...) EEPROMs"); +MODULE_AUTHOR("DON BOLLINGER "); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-cpld1.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-cpld1.c new file mode 100644 index 00000000..bb4db94e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-cpld1.c @@ -0,0 +1,558 @@ +/* + * A hwmon driver for the as7712_32x_cpld + * + * Copyright (C) 2013 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static ssize_t show_present(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7712_32x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7712_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +struct as7712_32x_cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/* Addresses scanned for as7712_32x_cpld + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index + +enum as7712_32x_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), +}; + +/* sysfs attributes for hwmon + */ + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_present, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); + +static struct attribute *as7712_32x_cpld_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_ATTR(1), + DECLARE_TRANSCEIVER_ATTR(2), + DECLARE_TRANSCEIVER_ATTR(3), + DECLARE_TRANSCEIVER_ATTR(4), + DECLARE_TRANSCEIVER_ATTR(5), + DECLARE_TRANSCEIVER_ATTR(6), + DECLARE_TRANSCEIVER_ATTR(7), + DECLARE_TRANSCEIVER_ATTR(8), + DECLARE_TRANSCEIVER_ATTR(9), + DECLARE_TRANSCEIVER_ATTR(10), + DECLARE_TRANSCEIVER_ATTR(11), + DECLARE_TRANSCEIVER_ATTR(12), + DECLARE_TRANSCEIVER_ATTR(13), + DECLARE_TRANSCEIVER_ATTR(14), + DECLARE_TRANSCEIVER_ATTR(15), + DECLARE_TRANSCEIVER_ATTR(16), + DECLARE_TRANSCEIVER_ATTR(17), + DECLARE_TRANSCEIVER_ATTR(18), + DECLARE_TRANSCEIVER_ATTR(19), + DECLARE_TRANSCEIVER_ATTR(20), + DECLARE_TRANSCEIVER_ATTR(21), + DECLARE_TRANSCEIVER_ATTR(22), + DECLARE_TRANSCEIVER_ATTR(23), + DECLARE_TRANSCEIVER_ATTR(24), + DECLARE_TRANSCEIVER_ATTR(25), + DECLARE_TRANSCEIVER_ATTR(26), + DECLARE_TRANSCEIVER_ATTR(27), + DECLARE_TRANSCEIVER_ATTR(28), + DECLARE_TRANSCEIVER_ATTR(29), + DECLARE_TRANSCEIVER_ATTR(30), + DECLARE_TRANSCEIVER_ATTR(31), + DECLARE_TRANSCEIVER_ATTR(32), + NULL +}; + +static const struct attribute_group as7712_32x_cpld_group = { + .attrs = as7712_32x_cpld_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x30, 0x31, 0x32, 0x33}; + struct i2c_client *client = to_i2c_client(dev); + struct as7712_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7712_32x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_present(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 as7712_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x31; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x33; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + default: + return 0; + } + + + mutex_lock(&data->update_lock); + status = as7712_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 reg = 0, mask = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7712_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + + switch (attr->index) { + case CPLD_VERSION: + reg = 0x1; + mask = 0xFF; + break; + default: + break; + } + + mutex_lock(&data->update_lock); + status = as7712_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%d\n", (status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7712_32x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7712_32x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static int as7712_32x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7712_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static void as7712_32x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7712_32x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static int as7712_32x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int status; + struct as7712_32x_cpld_data *data = NULL; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7712_32x_cpld_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7712_32x_cpld_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + as7712_32x_cpld_add_client(client); + + dev_info(&client->dev, "%s: cpld '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7712_32x_cpld_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7712_32x_cpld_remove(struct i2c_client *client) +{ + struct as7712_32x_cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7712_32x_cpld_group); + kfree(data); + as7712_32x_cpld_remove_client(client); + + return 0; +} + +int as7712_32x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7712_32x_cpld_read); + +int as7712_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7712_32x_cpld_write); + +static const struct i2c_device_id as7712_32x_cpld_id[] = { + { "as7712_32x_cpld1", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7712_32x_cpld_id); + +static struct i2c_driver as7712_32x_cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7712_32x_cpld1", + }, + .probe = as7712_32x_cpld_probe, + .remove = as7712_32x_cpld_remove, + .id_table = as7712_32x_cpld_id, + .address_list = normal_i2c, +}; + +static int __init as7712_32x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7712_32x_cpld_driver); +} + +static void __exit as7712_32x_cpld_exit(void) +{ + i2c_del_driver(&as7712_32x_cpld_driver); +} + +module_init(as7712_32x_cpld_init); +module_exit(as7712_32x_cpld_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7712_32x_cpld driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-leds.c index 747d39a7..0055708e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-leds.c @@ -30,8 +30,8 @@ #include #include -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as7712_32x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7712_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -175,12 +175,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as7712_32x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as7712_32x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as7712_32x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as7712_32x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as7712_32x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-psu.c index 65f7a16a..e3802603 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-psu.c @@ -41,7 +41,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static int as7712_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as7712_32x_cpld_read (unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -314,7 +314,7 @@ static struct as7712_32x_psu_data *as7712_32x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as7712_32x update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as7712_32x_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c deleted file mode 100644 index 202d85a0..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/modules/builds/x86-64-accton-as7712-32x-sfp.c +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * SFP driver for accton as7712 sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as7712_32x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 32 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as7712_32x_sfp1, as7712_32x_sfp2, as7712_32x_sfp3, as7712_32x_sfp4, as7712_32x_sfp5, as7712_32x_sfp6, as7712_32x_sfp7, as7712_32x_sfp8, -as7712_32x_sfp9, as7712_32x_sfp10, as7712_32x_sfp11, as7712_32x_sfp12, as7712_32x_sfp13, as7712_32x_sfp14, as7712_32x_sfp15, as7712_32x_sfp16, -as7712_32x_sfp17, as7712_32x_sfp18, as7712_32x_sfp19, as7712_32x_sfp20, as7712_32x_sfp21, as7712_32x_sfp22, as7712_32x_sfp23, as7712_32x_sfp24, -as7712_32x_sfp25, as7712_32x_sfp26, as7712_32x_sfp27, as7712_32x_sfp28, as7712_32x_sfp29, as7712_32x_sfp30, as7712_32x_sfp31, as7712_32x_sfp32 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7712_32x_sfp1), -I2C_DEV_ID(as7712_32x_sfp2), -I2C_DEV_ID(as7712_32x_sfp3), -I2C_DEV_ID(as7712_32x_sfp4), -I2C_DEV_ID(as7712_32x_sfp5), -I2C_DEV_ID(as7712_32x_sfp6), -I2C_DEV_ID(as7712_32x_sfp7), -I2C_DEV_ID(as7712_32x_sfp8), -I2C_DEV_ID(as7712_32x_sfp9), -I2C_DEV_ID(as7712_32x_sfp10), -I2C_DEV_ID(as7712_32x_sfp11), -I2C_DEV_ID(as7712_32x_sfp12), -I2C_DEV_ID(as7712_32x_sfp13), -I2C_DEV_ID(as7712_32x_sfp14), -I2C_DEV_ID(as7712_32x_sfp15), -I2C_DEV_ID(as7712_32x_sfp16), -I2C_DEV_ID(as7712_32x_sfp17), -I2C_DEV_ID(as7712_32x_sfp18), -I2C_DEV_ID(as7712_32x_sfp19), -I2C_DEV_ID(as7712_32x_sfp20), -I2C_DEV_ID(as7712_32x_sfp21), -I2C_DEV_ID(as7712_32x_sfp22), -I2C_DEV_ID(as7712_32x_sfp23), -I2C_DEV_ID(as7712_32x_sfp24), -I2C_DEV_ID(as7712_32x_sfp25), -I2C_DEV_ID(as7712_32x_sfp26), -I2C_DEV_ID(as7712_32x_sfp27), -I2C_DEV_ID(as7712_32x_sfp28), -I2C_DEV_ID(as7712_32x_sfp29), -I2C_DEV_ID(as7712_32x_sfp30), -I2C_DEV_ID(as7712_32x_sfp31), -I2C_DEV_ID(as7712_32x_sfp32), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0; - int status = -1; - u8 regs[] = {0x30, 0x31, 0x32, 0x33}; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 1~32 */ - data->present = 0; - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = accton_i2c_cpld_read(0x60, regs[i]); - - if (status < 0) { - DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); - data->present |= (u64)status << (i*8); - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - return NULL; -} - -/* Platform dependent --- */ - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - return 0; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[4] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7712_32x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/sfpi.c index 6c7f381b..e9847288 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/sfpi.c @@ -25,53 +25,24 @@ ***********************************************************/ #include -#include /* For O_RDWR && open */ -#include -#include -#include -#include #include +#include #include "platform_lib.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; - #define MUX_START_INDEX 18 #define NUM_OF_SFP_PORT 32 -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { +static const int port_bus_index[NUM_OF_SFP_PORT] = { 4, 5, 6, 7, 9, 8, 11, 10, 0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31, 20, 21, 22, 23, 24, 25, 26, 27 }; -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]+MUX_START_INDEX) +#define PORT_BUS_INDEX(port) (port_bus_index[port]+MUX_START_INDEX) +#define PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" -static int -as7512_32x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8]; - *value = 0; - - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as7512_32x_sfp_get_port_path(int port, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", - FRONT_PORT_TO_MUX_INDEX(port), - node_name); - - return sfp_node_path; -} +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/4-0060/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/4-0060/module_present_all" /************************************************************ * @@ -110,9 +81,8 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as7512_32x_sfp_get_port_path(port, "sfp_is_present"); - if (as7512_32x_sfp_node_read_int(path, &present, 0) != 0) { + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -124,11 +94,9 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; - char* path; FILE* fp; - path = as7512_32x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); @@ -167,17 +135,16 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + if(onlp_file_read(data, 256, &size, PORT_FORMAT, PORT_BUS_INDEX(port), "eeprom") != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -188,28 +155,28 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - int bus = FRONT_PORT_TO_MUX_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - int bus = FRONT_PORT_TO_MUX_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - int bus = FRONT_PORT_TO_MUX_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) { - int bus = FRONT_PORT_TO_MUX_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py index e460484f..6b70daad 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/platform-config/r0/src/python/x86_64_accton_as7712_32x_r0/__init__.py @@ -8,9 +8,10 @@ class OnlPlatform_x86_64_accton_as7712_32x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".7712.32" def baseconfig(self): + self.insmod('optoe') self.insmod('ym2651y') self.insmod('accton_i2c_cpld') - for m in [ 'fan', 'psu', 'leds', 'sfp' ]: + for m in [ 'fan', 'cpld1', 'psu', 'leds' ]: self.insmod("x86-64-accton-as7712-32x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -28,7 +29,7 @@ class OnlPlatform_x86_64_accton_as7712_32x_r0(OnlPlatformAccton, ('lm75', 0x4a, 3), ('lm75', 0x4b, 3), - ('accton_i2c_cpld', 0x60, 4), + ('as7712_32x_cpld1', 0x60, 4), ('accton_i2c_cpld', 0x62, 5), ('accton_i2c_cpld', 0x64, 6), ]) @@ -57,39 +58,72 @@ class OnlPlatform_x86_64_accton_as7712_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 self.new_i2c_devices([ - ('as7712_32x_sfp9', 0x50, 18), - ('as7712_32x_sfp10', 0x50, 19), - ('as7712_32x_sfp11', 0x50, 20), - ('as7712_32x_sfp12', 0x50, 21), - ('as7712_32x_sfp1', 0x50, 22), - ('as7712_32x_sfp2', 0x50, 23), - ('as7712_32x_sfp3', 0x50, 24), - ('as7712_32x_sfp4', 0x50, 25), - ('as7712_32x_sfp6', 0x50, 26), - ('as7712_32x_sfp5', 0x50, 27), - ('as7712_32x_sfp8', 0x50, 28), - ('as7712_32x_sfp7', 0x50, 29), - ('as7712_32x_sfp13', 0x50, 30), - ('as7712_32x_sfp14', 0x50, 31), - ('as7712_32x_sfp15', 0x50, 32), - ('as7712_32x_sfp16', 0x50, 33), - ('as7712_32x_sfp17', 0x50, 34), - ('as7712_32x_sfp18', 0x50, 35), - ('as7712_32x_sfp19', 0x50, 36), - ('as7712_32x_sfp20', 0x50, 37), - ('as7712_32x_sfp25', 0x50, 38), - ('as7712_32x_sfp26', 0x50, 39), - ('as7712_32x_sfp27', 0x50, 40), - ('as7712_32x_sfp28', 0x50, 41), - ('as7712_32x_sfp29', 0x50, 42), - ('as7712_32x_sfp30', 0x50, 43), - ('as7712_32x_sfp31', 0x50, 44), - ('as7712_32x_sfp32', 0x50, 45), - ('as7712_32x_sfp21', 0x50, 46), - ('as7712_32x_sfp22', 0x50, 47), - ('as7712_32x_sfp23', 0x50, 48), - ('as7712_32x_sfp24', 0x50, 49), + ('optoe1', 0x50, 18), + ('optoe1', 0x50, 19), + ('optoe1', 0x50, 20), + ('optoe1', 0x50, 21), + ('optoe1', 0x50, 22), + ('optoe1', 0x50, 23), + ('optoe1', 0x50, 24), + ('optoe1', 0x50, 25), + ('optoe1', 0x50, 26), + ('optoe1', 0x50, 27), + ('optoe1', 0x50, 28), + ('optoe1', 0x50, 29), + ('optoe1', 0x50, 30), + ('optoe1', 0x50, 31), + ('optoe1', 0x50, 32), + ('optoe1', 0x50, 33), + ('optoe1', 0x50, 34), + ('optoe1', 0x50, 35), + ('optoe1', 0x50, 36), + ('optoe1', 0x50, 37), + ('optoe1', 0x50, 38), + ('optoe1', 0x50, 39), + ('optoe1', 0x50, 40), + ('optoe1', 0x50, 41), + ('optoe1', 0x50, 42), + ('optoe1', 0x50, 43), + ('optoe1', 0x50, 44), + ('optoe1', 0x50, 45), + ('optoe1', 0x50, 46), + ('optoe1', 0x50, 47), + ('optoe1', 0x50, 48), + ('optoe1', 0x50, 49), ]) + subprocess.call('echo port9 > /sys/bus/i2c/devices/18-0050/port_name', shell=True) + subprocess.call('echo port10 > /sys/bus/i2c/devices/19-0050/port_name', shell=True) + subprocess.call('echo port11 > /sys/bus/i2c/devices/20-0050/port_name', shell=True) + subprocess.call('echo port12 > /sys/bus/i2c/devices/21-0050/port_name', shell=True) + subprocess.call('echo port1 > /sys/bus/i2c/devices/22-0050/port_name', shell=True) + subprocess.call('echo port2 > /sys/bus/i2c/devices/23-0050/port_name', shell=True) + subprocess.call('echo port3 > /sys/bus/i2c/devices/24-0050/port_name', shell=True) + subprocess.call('echo port4 > /sys/bus/i2c/devices/25-0050/port_name', shell=True) + subprocess.call('echo port6 > /sys/bus/i2c/devices/26-0050/port_name', shell=True) + subprocess.call('echo port5 > /sys/bus/i2c/devices/27-0050/port_name', shell=True) + subprocess.call('echo port8 > /sys/bus/i2c/devices/28-0050/port_name', shell=True) + subprocess.call('echo port7 > /sys/bus/i2c/devices/29-0050/port_name', shell=True) + subprocess.call('echo port13 > /sys/bus/i2c/devices/30-0050/port_name', shell=True) + subprocess.call('echo port14 > /sys/bus/i2c/devices/31-0050/port_name', shell=True) + subprocess.call('echo port15 > /sys/bus/i2c/devices/32-0050/port_name', shell=True) + subprocess.call('echo port16 > /sys/bus/i2c/devices/33-0050/port_name', shell=True) + subprocess.call('echo port17 > /sys/bus/i2c/devices/34-0050/port_name', shell=True) + subprocess.call('echo port18 > /sys/bus/i2c/devices/35-0050/port_name', shell=True) + subprocess.call('echo port19 > /sys/bus/i2c/devices/36-0050/port_name', shell=True) + subprocess.call('echo port20 > /sys/bus/i2c/devices/37-0050/port_name', shell=True) + subprocess.call('echo port25 > /sys/bus/i2c/devices/38-0050/port_name', shell=True) + subprocess.call('echo port26 > /sys/bus/i2c/devices/39-0050/port_name', shell=True) + subprocess.call('echo port27 > /sys/bus/i2c/devices/40-0050/port_name', shell=True) + subprocess.call('echo port28 > /sys/bus/i2c/devices/41-0050/port_name', shell=True) + subprocess.call('echo port29 > /sys/bus/i2c/devices/42-0050/port_name', shell=True) + subprocess.call('echo port30 > /sys/bus/i2c/devices/43-0050/port_name', shell=True) + subprocess.call('echo port31 > /sys/bus/i2c/devices/44-0050/port_name', shell=True) + subprocess.call('echo port32 > /sys/bus/i2c/devices/45-0050/port_name', shell=True) + subprocess.call('echo port21 > /sys/bus/i2c/devices/46-0050/port_name', shell=True) + subprocess.call('echo port22 > /sys/bus/i2c/devices/47-0050/port_name', shell=True) + subprocess.call('echo port23 > /sys/bus/i2c/devices/48-0050/port_name', shell=True) + subprocess.call('echo port24 > /sys/bus/i2c/devices/49-0050/port_name', shell=True) + self.new_i2c_device('24c02', 0x57, 1) return True From dcb4a77b8c4377357690ed05c447af637ad7587e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 29 Dec 2017 03:36:55 +0000 Subject: [PATCH 103/244] Base from $ONL. --- tools/scripts/submodule-updated.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/scripts/submodule-updated.sh b/tools/scripts/submodule-updated.sh index 979bb64c..8019f388 100755 --- a/tools/scripts/submodule-updated.sh +++ b/tools/scripts/submodule-updated.sh @@ -16,11 +16,4 @@ rm -rf $ONL/make/modules/module* # Rebuild pkg cache -onlpm.py --rebuild-pkg-cache - - - - - - - +$ONL/tools/onlpm.py --rebuild-pkg-cache From ff85b7f30755ba6654dc3404c501c0bdaff472b0 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 29 Dec 2017 16:27:27 +0000 Subject: [PATCH 104/244] Change public URLs from git: to http: as the recommended usage to improve access in restricted environments. --- .gitmodules | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 868f1568..943c63ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,21 +1,21 @@ [submodule "packages/base/any/initrds/buildroot/builds/buildroot-mirror"] path = packages/base/any/initrds/buildroot/builds/buildroot-mirror - url = git://github.com/opennetworklinux/buildroot-mirror + url = http://github.com/opennetworklinux/buildroot-mirror [submodule "packages/base/any/kernels/legacy/linux-3.9.6"] path = packages/base/any/kernels/legacy/linux-3.9.6 - url = git://github.com/opennetworklinux/linux-3.9.6 + url = http://github.com/opennetworklinux/linux-3.9.6 [submodule "sm/infra"] path = sm/infra - url = git://github.com/floodlight/infra + url = http://github.com/floodlight/infra [submodule "sm/bigcode"] path = sm/bigcode - url = git://github.com/floodlight/bigcode + url = http://github.com/floodlight/bigcode [submodule "packages/base/any/kernels/legacy/linux-3.8.13"] path = packages/base/any/kernels/legacy/linux-3.8.13 - url = git://github.com/opennetworklinux/linux-3.8.13 + url = http://github.com/opennetworklinux/linux-3.8.13 [submodule "packages/platforms-closed"] path = packages/platforms-closed url = git@github.com:opennetworklinux/platforms-closed [submodule "sm/build-artifacts"] path = sm/build-artifacts - url = git://github.com/opennetworklinux/build-artifacts + url = http://github.com/opennetworklinux/build-artifacts From 742bb5b8ca337d18a74d7a43a76c96f51d749b87 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 29 Dec 2017 08:58:44 -0800 Subject: [PATCH 105/244] Revert "sync delta Release 1.3 about ag6248c with ocp " --- .../loader-initrd-files/src/bin/swiget | 9 - .../loader-initrd-files/src/bin/swimount | 23 +- .../src/bootmodes/installed | 4 +- .../lib/platform-config-defaults-uboot.yml | 7 - .../src/python/onl/install/BaseInstall.py | 228 +- .../src/python/onl/install/InstallUtils.py | 57 - .../src/python/onl/mounts/__init__.py | 40 +- .../src/python/onl/platform/base.py | 4 - .../3.2-lts/configs/arm-iproc-all/Makefile | 2 +- .../arm-iproc-all/arm-iproc-all.config | 4 +- ...latform-delta-ag6248c-device-drivers.patch | 181 -- .../configs/arm-iproc-all/patches/series | 1 - packages/platforms/delta/armel/Makefile | 1 - .../delta/armel/arm-delta-ag6248c/Makefile | 1 - .../delta/armel/arm-delta-ag6248c/README.md | 25 - .../arm-delta-ag6248c/.gitignore | 2 - .../arm-delta-ag6248c/Makefile | 1 - .../arm-delta-ag6248c/modules/Makefile | 1 - .../arm-delta-ag6248c/modules/PKG.yml | 1 - .../modules/builds/.gitignore | 2 - .../arm-delta-ag6248c/modules/builds/Makefile | 6 - .../builds/arm-delta-ag6248c-cpld-mux-1.c | 242 --- .../builds/arm-delta-ag6248c-cpld-mux-2.c | 243 --- .../arm-delta-ag6248c/onlp/Makefile | 1 - .../arm-delta-ag6248c/onlp/PKG.yml | 1 - .../arm-delta-ag6248c/onlp/builds/Makefile | 2 - .../onlp/builds/lib/Makefile | 44 - .../builds/lib/libonlp-arm-delta-ag6248c.mk | 10 - .../onlp/builds/onlpdump/Makefile | 45 - .../platform-config/Makefile | 1 - .../platform-config/r0/Makefile | 1 - .../platform-config/r0/PKG.yml | 1 - .../r0/src/lib/arm-delta-ag6248c-r0.yml | 43 - .../python/arm_delta_ag6248c_r0/__init__.py | 23 - .../src/arm_delta_ag6248c/.gitignore | 2 - .../src/arm_delta_ag6248c/.module | 1 - .../src/arm_delta_ag6248c/Makefile | 28 - .../arm_delta_ag6248c/arm_delta_ag6248c.doxy | 1869 ----------------- .../arm_delta_ag6248c/arm_delta_ag6248c.mk | 13 - .../module/auto/arm_delta_ag6248c.yml | 67 - .../src/arm_delta_ag6248c/module/auto/make.mk | 28 - .../inc/arm_delta_ag6248c/arm_delta_ag6248c.x | 34 - .../arm_delta_ag6248c_config.h | 162 -- .../arm_delta_ag6248c/arm_delta_ag6248c_dox.h | 51 - .../arm_delta_ag6248c_porting.h | 132 -- .../src/arm_delta_ag6248c/module/make.mk | 29 - .../src/arm_delta_ag6248c/module/src/Makefile | 30 - .../module/src/arm_delta_ag6248c_config.c | 101 - .../module/src/arm_delta_ag6248c_enums.c | 30 - .../module/src/arm_delta_ag6248c_int.h | 32 - .../module/src/arm_delta_ag6248c_log.c | 38 - .../module/src/arm_delta_ag6248c_log.h | 32 - .../module/src/arm_delta_ag6248c_module.c | 44 - .../module/src/arm_delta_ag6248c_ucli.c | 82 - .../module/src/arm_delta_i2c.c | 141 -- .../module/src/arm_delta_i2c.h | 54 - .../src/arm_delta_ag6248c/module/src/fani.c | 470 ----- .../src/arm_delta_ag6248c/module/src/ledi.c | 352 ---- .../src/arm_delta_ag6248c/module/src/make.mk | 29 - .../module/src/platform_lib.c | 85 - .../module/src/platform_lib.h | 135 -- .../src/arm_delta_ag6248c/module/src/psui.c | 381 ---- .../src/arm_delta_ag6248c/module/src/sfpi.c | 364 ---- .../src/arm_delta_ag6248c/module/src/sysi.c | 290 --- .../arm_delta_ag6248c/module/src/thermali.c | 208 -- .../platforms/delta/armel/modules/Makefile | 1 - .../platforms/delta/armel/modules/PKG.yml | 1 - .../x86-64/x86-64-delta-ag5648/.gitignore | 3 +- .../delta/x86-64/x86-64-delta-ag5648/Makefile | 3 +- 69 files changed, 17 insertions(+), 6562 deletions(-) delete mode 100644 packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch delete mode 100644 packages/platforms/delta/armel/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/README.md delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c delete mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/make.mk delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c delete mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c delete mode 100644 packages/platforms/delta/armel/modules/Makefile delete mode 100644 packages/platforms/delta/armel/modules/PKG.yml diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget index 1be874d1..333674a9 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget @@ -19,7 +19,6 @@ import zipfile import onl.install.InstallUtils MountContext = onl.install.InstallUtils.MountContext BlkidParser = onl.install.InstallUtils.BlkidParser -UbinfoParser = onl.install.InstallUtils.UbinfoParser ProcMountsParser = onl.install.InstallUtils.ProcMountsParser import onl.mounts @@ -248,14 +247,6 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): part = blkid[label] except IndexError: part = None - if part is None: - ubinfo = UbinfoParser(log=self.log) - part = {} - part = ubinfo[label] - device = "/dev/" + part['device'] + "_" + part['Volume ID'] - - return self.blockdevCopy(device, r, dir=mpt) - if part is not None: return self.blockdevCopy(part.device, r, dir=mpt) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swimount b/packages/base/all/initrds/loader-initrd-files/src/bin/swimount index 2741b5bd..b7ea1879 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swimount +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swimount @@ -11,7 +11,6 @@ import logging import onl.install.InstallUtils BlkidParser = onl.install.InstallUtils.BlkidParser -UbinfoParser = onl.install.InstallUtils.UbinfoParser import onl.mounts MountContext = onl.install.InstallUtils.MountContext @@ -27,7 +26,6 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): self.log = log self.blkid = BlkidParser(log=self.log) - self.ubinfo = UbinfoParser(log=self.log) def mount(self, SWI): @@ -127,13 +125,6 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): part = self.blkid[label] except IndexError: part = None - if part is None: - part = {} - part = self.ubinfo[label] - - device = "/dev/" + part['device'] + "_" + part['Volume ID'] - - return self.blockdevMount(device, path, dir=mpt) if part is not None: return self.blockdevMount(part.device, path, dir=mpt) @@ -150,12 +141,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): if not os.path.exists(dst): self.log.error("missing SWI: %s", dst) return None - p = dev.find('ubi') - if p < 0: - self.check_call(('mount', '-o', 'rw,remount', dst,)) - else: - self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', dst,)) - + self.check_call(('mount', '-o', 'rw,remount', dst,)) return dst with MountContext(device=dev, log=self.log) as ctx: @@ -168,12 +154,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): # move to its proper location as per mtab # XXX perms may not be right here if dir is not None: - p = dev.find('ubi') - if p < 0: - self.check_call(('mount', '-o', 'rw,remount', ctx.dir,)) - else: - self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', ctx.dir,)) - + self.check_call(('mount', '-o', 'rw,remount', ctx.dir,)) self.check_call(('mount', '--move', ctx.dir, dir,)) ctx.mounted = False dst = dir diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed index dc0e887b..00aa3a41 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed +++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed @@ -15,8 +15,8 @@ if [ ! -d /mnt/onl/data ]; then fi # make sure it's mounted as per mtab.yml -d1=$(stat -f -c '%b' /mnt/onl) -d2=$(stat -f -c '%b' /mnt/onl/data) +d1=$(stat -f -c '%d' /mnt/onl) +d2=$(stat -f -c '%d' /mnt/onl/data) if [ "$d1" -eq "$d2" ]; then msg_error "Unmounted /mnt/onl/data, disk boot cannot continue" exit 200 diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml index 6b66f8c6..4ad068fb 100644 --- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml +++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml @@ -129,13 +129,6 @@ default: - ext2load mmc 0:1 $onl_loadaddr $onl_itb - "bootm $onl_loadaddr#$onl_platform" - #ubifs to boot onl - flash_bootcmds: &flash_bootcmds - - ubi part open - - ubifsmount ONL-BOOT - - ubifsload $loadaddr $onl_itb - - "bootm $onl_loadaddr#$onl_platform" - nos_bootcmds: *ide_bootcmds # Configure the fw_env.config file, diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py index 50b21638..2ca43c17 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py @@ -17,7 +17,7 @@ import imp import fnmatch, glob from InstallUtils import SubprocessMixin -from InstallUtils import MountContext, BlkidParser, PartedParser, UbinfoParser +from InstallUtils import MountContext, BlkidParser, PartedParser from InstallUtils import ProcMountsParser from InstallUtils import GdiskParser from InstallUtils import OnieSubprocess @@ -83,7 +83,6 @@ class Base: # keep track of next partition/next block self.blkidParts = [] - self.ubiParts = [] # current scan of partitions and labels self.partedDevice = None @@ -854,203 +853,7 @@ class GrubInstaller(SubprocessMixin, Base): def shutdown(self): Base.shutdown(self) -class UBIfsCreater(SubprocessMixin, Base): - - def __init__(self, *args, **kwargs): - Base.__init__(self, *args, **kwargs) - self.log = logging.getLogger("ubinfo -a") - self.device = self.im.getDevice() - self.ubiParts = None - """Set up an UBI file system.""" - - def ubifsinit(self): - UNITS = { - 'GiB' : 1024 * 1024 * 1024, - 'G' : 1000 * 1000 * 1000, - 'MiB' : 1024 * 1024, - 'M' : 1000 * 1000, - 'KiB' : 1024, - 'K' : 1000, - } - try: - code = 0 - if not code: - mtd_num = self.device[-1] - cmd = ('ubiformat', '/dev/mtd' + mtd_num) - self.check_call(cmd, vmode=self.V2) - cmd = ('ubiattach', '-m', mtd_num, '-d', '0', '/dev/ubi_ctrl',) - self.check_call(cmd, vmode=self.V2) - for part in self.im.platformConf['installer']: - label, partData = list(part.items())[0] - if type(partData) == dict: - sz, fmt = partData['='], partData.get('format', 'ubifs') - else: - sz, fmt = partData, 'ubifs' - cnt = None - for ul, ub in UNITS.items(): - if sz.endswith(ul): - cnt = int(sz[:-len(ul)], 10) * ub - break - if cnt is None: - self.log.error("invalid size (no units) for %s: %s",part, sz) - return 1 - label = label.strip() - cmd = ('ubimkvol', '/dev/ubi0', '-N', label, '-s', bytes(cnt),) - self.check_call(cmd, vmode=self.V2) - except Exception: - self.log.exception("cannot create UBI file systemfrom %s",self.device) - - return 0 - - def ubi_mount(self, dir, devpart): - - if devpart is None: - self.log.error("Mount failed.no given mount device part") - return 1 - if dir is None: - self.log.error("Mount failed.no given mount directory") - return 1 - if self.ubiParts is None: - try: - self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a")) - except Exception: - self.log.exception("Mount failed.No UBIfs") - return 1 - try: - dev = self.ubiParts[devpart] - except IndexError as ex: - self.log.error("Mount failed.cannot find %s partition", str(devpart)) - return 1 - self.makedirs(dir) - device = "/dev/" + dev['device'] + "_" + dev['Volume ID'] - if dev['fsType']: - cmd = ('mount', '-t', dev['fsType'], device, dir,) - else: - cmd = ('mount', device, dir,) - code = self.check_call(cmd, vmode=self.V2) - if code: - self.log.error("Mount failed.mount command exect failed") - return 1 - return 0 - - def ubi_unmount(self,dir=None): - - if dir is None: - self.log.error("Unmount failed.no given unmount directory") - return 1 - cmd = ('umount', dir) - code = self.check_call(cmd, vmode=self.V2) - if code: - self.log.error("Unmount failed.umount command exect failed") - return 1 - return 0 - - def ubi_getinfo(self): - try: - self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a")) - except Exception: - self.log.exception("UBI info get failed.No UBIfs") - return 1 - return 0 - - def ubi_installSwi(self): - - files = os.listdir(self.im.installerConf.installer_dir) + self.zf.namelist() - - swis = [x for x in files if x.endswith('.swi')] - - if not swis: - self.log.warn("No ONL Software Image available for ubi installation.") - self.log.warn("Post-install ZTN installation will be required.") - - if len(swis) > 1: - self.log.error("Multiple SWIs found in ubi installer: %s", " ".join(swis)) - return 1 - - base = swis[0] - - self.log.info("Installing ONL Software Image (%s)...", base) - dev = "ONL-IMAGES" - dstDir = "/tmp/ubifs" - code = self.ubi_mount(dstDir,dev) - if code : - return 1 - dst = os.path.join(dstDir, base) - self.installerCopy(base, dst) - self.log.info("syncing block devices(%s)...",dev) - self.check_call(('sync',)) - self.ubi_unmount(dstDir) - return 0 - - def ubi_installLoader(self): - - loaderBasename = None - for c in sysconfig.installer.fit: - if self.installerExists(c): - loaderBasename = c - break - if not loaderBasename: - self.log.error("The platform loader file is missing.") - return 1 - - self.log.info("Installing the ONL loader from %s...", loaderBasename) - dev = "ONL-BOOT" - dstDir = "/tmp/ubiloader" - code = self.ubi_mount(dstDir,dev) - if code : - return 1 - dst = os.path.join(dstDir, "%s.itb" % self.im.installerConf.installer_platform) - self.installerCopy(loaderBasename, dst) - self.log.info("syncing block devices(%s)...",dev) - self.check_call(('sync',)) - self.ubi_unmount(dstDir) - return 0 - - def ubi_installBootConfig(self): - - basename = 'boot-config' - - self.log.info("Installing boot-config to ONL-BOOT partion") - dev = "ONL-BOOT" - dstDir = "/tmp/ubibootcon" - code = self.ubi_mount(dstDir,dev) - if code : - return 1 - dst = os.path.join(dstDir, basename) - self.installerCopy(basename, dst, True) - with open(dst) as fd: - buf = fd.read() - ecf = buf.encode('base64', 'strict').strip() - if self.im.grub and self.im.grubEnv is not None: - setattr(self.im.grubEnv, 'boot_config_default', ecf) - if self.im.uboot and self.im.ubootEnv is not None: - setattr(self.im.ubootEnv, 'boot-config-default', ecf) - self.log.info("syncing block devices(%s)...",dev) - self.check_call(('sync',)) - self.ubi_unmount(dstDir) - return 0 - - def ubi_installOnlConfig(self): - - self.log.info("Installing onl-config to ONL-CONFIG partion") - dev = "ONL-CONFIG" - dstDir = "/tmp/ubionlconfig" - code = self.ubi_mount(dstDir,dev) - if code : - return 1 - for f in self.zf.namelist(): - d = 'config/' - if f.startswith(d) and f != d: - dst = os.path.join(dstDir, os.path.basename(f)) - if not os.path.exists(dst): - self.installerCopy(f, dst) - self.log.info("syncing block devices(%s)...",dev) - self.check_call(('sync',)) - self.ubi_unmount(dstDir) - return 0 - - -class UbootInstaller(SubprocessMixin, UBIfsCreater): +class UbootInstaller(SubprocessMixin, Base): class installmeta(Base.installmeta): @@ -1071,16 +874,13 @@ class UbootInstaller(SubprocessMixin, UBIfsCreater): cmds.append("setenv onl_itb %s" % itb) for item in self.platformConf['loader']['setenv']: k, v = list(item.items())[0] - device = self.getDevice() - if "mtdblock" in device: - cmds.append("setenv %s %s ${platformargs} ubi.mtd=%s root=/dev/ram ethaddr=$ethaddr" % (k, v, device[-1],)) - else: - cmds.append("setenv %s %s" % (k, v,)) + cmds.append("setenv %s %s" % (k, v,)) cmds.extend(self.platformConf['loader']['nos_bootcmds']) return "; ".join(cmds) def __init__(self, *args, **kwargs): - UBIfsCreater.__init__(self, *args, **kwargs) + Base.__init__(self, *args, **kwargs) + self.device = self.im.getDevice() self.rawLoaderDevice = None @@ -1214,24 +1014,6 @@ class UbootInstaller(SubprocessMixin, UBIfsCreater): code = self.assertUnmounted() if code: return code - - if "mtdblock" in self.device: - code = self.ubifsinit() - if code: return code - code = self.ubi_getinfo() - if code: return code - code = self.ubi_installSwi() - if code: return code - code = self.ubi_installLoader() - if code: return code - code = self.ubi_installBootConfig() - if code: return code - code = self.ubi_installOnlConfig() - if code: return code - code = self.runPlugins(Plugin.PLUGIN_POSTINSTALL) - if code: return code - code = self.installUbootEnv() - return code code = self.maybeCreateLabel() if code: return code diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index 85fe2c01..ccb4615e 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -388,63 +388,6 @@ class BlkidParser(SubprocessMixin): def __len__(self): return len(self.parts) -class UbinfoParser(SubprocessMixin): - - def __init__(self, log=None): - self.log = log or logging.getLogger("ubinfo -a") - self.parse() - - def parse(self): - self.parts = [] - lines = '' - try: - cmd = ('ubinfo', '-a',) - lines = self.check_output(cmd).splitlines() - except Exception as ex: - return self - - dev = None - volId = None - name = None - attrs = {} - for line in lines: - line = line.strip() - - p = line.find(':') - if p < 0: continue - name, value = line[:p], line[p+1:].strip() - if 'Volume ID' in name: - p = value.find('(') - if p < 0: continue - volumeId = value[:p].strip() - attrs['Volume ID'] = volumeId - p = value.find('on') - if p < 0: continue - dev = value[p+2:-1].strip() - attrs['device'] = dev - - if 'Name' in name: - dev = "/dev/" + dev + "_" + volumeId - p = line.find(':') - if p < 0: continue - attrs['Name'] = line[p+1:].strip() - attrs['fsType'] = 'ubifs' - self.parts.append(attrs) - dev = None - volId = None - name = None - attrs = {} - - def __getitem__(self, idxOrName): - if type(idxOrName) == int: - return self.parts[idxOrName] - for part in self.parts: - if part['Name'] == idxOrName: return part - raise IndexError("cannot find partition %s" % repr(idxOrName)) - - def __len__(self): - return len(self.parts) - class ProcMtdEntry: def __init__(self, diff --git a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py index e6d24391..bf591df6 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py @@ -63,12 +63,7 @@ class MountManager(object): self.logger.debug("%s not mounted @ %s. It will be mounted %s" % (device, directory, mode)) try: - p = device.find('ubi') - if p < 0: - cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory) - else: - cmd = "mount -o %s -t %s %s %s" % (','.join(mountargs), 'ubifs', device, directory) - + cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory) self.logger.debug("+ %s" % cmd) subprocess.check_call(cmd, shell=True) except subprocess.CalledProcessError, e: @@ -153,39 +148,12 @@ class OnlMountManager(object): def _discover(k): v = md[k] lbl = v.get('label', k) - useUbiDev = False + try: v['device'] = subprocess.check_output(('blkid', '-L', lbl,)).strip() except subprocess.CalledProcessError: - useUbiDev = True - if useUbiDev == True: - if k == 'EFI-BOOT': - return False - output = subprocess.check_output("ubinfo -d 0 -N %s" % k, shell=True).splitlines() - volumeId = None - device = None - for line in output: - line = line.strip() - p = line.find(':') - if p < 0: - self.logger.debug("Invaild ubinfo output %s" % line) - - name, value = line[:p], line[p+1:].strip() - if 'Volume ID' in name: - p = value.find('(') - if p < 0: - self.logger.debug("Invalid Volume ID %s" % value) - - volumeId = value[:p].strip() - p = value.find('on') - if p < 0: - self.logger.debug("Invalid ubi devicde %s" % value) - - device = value[p+2:-1].strip() - if 'Name' in name: - v['device'] = "/dev/" + device + "_" + volumeId - - + return False + if not os.path.isdir(v['dir']): self.logger.debug("Make directory '%s'...", v['dir']) os.makedirs(v['dir']) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index ed6efcfa..170f1eac 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -474,10 +474,6 @@ class OnlPlatformPortConfig_48x1_4x10(object): PORT_COUNT=52 PORT_CONFIG="48x1 + 4x10" -class OnlPlatformPortConfig_48x1_2x10(object): - PORT_COUNT=50 - PORT_CONFIG="48x1 + 2x10" - class OnlPlatformPortConfig_48x10_4x40(object): PORT_COUNT=52 PORT_CONFIG="48x10 + 4x40" diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile index 49f02b06..b16fc9d4 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile @@ -38,6 +38,6 @@ K_COPY_DST := kernel-3.2-lts-arm-iproc-all.bin.gz endif export ARCH=arm -DTS_LIST := accton_as4610_54 delta_ag6248c +DTS_LIST := accton_as4610_54 include $(ONL)/make/kbuild.mk diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config index e70dd3b3..4df4b2f3 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config @@ -289,7 +289,6 @@ CONFIG_BCM_RAM_START_RESERVED_SIZE=0x200000 # CONFIG_MACH_GH is not set # CONFIG_MACH_DNI_3448P is not set CONFIG_MACH_ACCTON_AS4610_54=y -CONFIG_MACH_DELTA_AG6248C=y # CONFIG_MACH_IPROC_EMULATION is not set # @@ -1939,8 +1938,7 @@ CONFIG_IPROC_QSPI_SINGLE_MODE=y # CONFIG_IPROC_QSPI_DUAL_MODE is not set # CONFIG_IPROC_QSPI_QUAD_MODE is not set CONFIG_IPROC_QSPI_MAX_HZ=62500000 -CONFIG_IPROC_MTD_NAND=y -# CONFIG_IPROC_MTD_NAND_USE_JFFS2 is not set +# CONFIG_IPROC_MTD_NAND is not set # CONFIG_IPROC_PWM is not set CONFIG_IPROC_USB2H=y CONFIG_USB_EHCI_BCM=y diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch deleted file mode 100644 index 6dd2774b..00000000 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch +++ /dev/null @@ -1,181 +0,0 @@ -diff --git a/arch/arm/boot/dts/delta_ag6248c.dts b/arch/arm/boot/dts/delta_ag6248c.dts -new file mode 100755 -index 0000000..f86c35b ---- /dev/null -+++ b/arch/arm/boot/dts/delta_ag6248c.dts -@@ -0,0 +1,78 @@ -+/* -+ * Delta Networks, Inc. AG6248C Device Tree Source -+ * -+ * Copyright 2015, Cumulus Networks, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ */ -+/dts-v1/; -+/include/ "helix4.dtsi" -+ -+/ { -+ model = "delta,ag6248c"; -+ compatible = "delta,ag6248c"; -+ -+ aliases { -+ serial0 = &uart0; -+ i2c-controller0 = &i2c0; -+ i2c-controller1 = &i2c1; -+ }; -+ -+ memory { -+ reg = <0x61000000 0x7f000000>; -+ }; -+ -+ cpus { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ -+ cpu@0 { -+ device_type = "cpu"; -+ compatible = "arm,cortex-a9"; -+ next-level-cache = <&L2>; -+ reg = <0x00>; -+ }; -+ cpu@1 { -+ device_type = "cpu"; -+ compatible = "arm,cortex-a9"; -+ next-level-cache = <&L2>; -+ reg = <0x01>; -+ }; -+ }; -+ -+ localbus@1e000000{ -+ address-cells = <0x2>; -+ #size-cells = <0x1>; -+ compatible = "simple-bus"; -+ ranges = <0x0 0x0 0x1e000000 0x02000000>; -+ -+ }; -+ -+ i2c0: i2c@18038000 { -+ compatible = "iproc-smb"; -+ reg = <0x18038000 0x1000>; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ interrupts = < 127 >; -+ clock-frequency = <400000>; -+ rtc@68 { -+ compatible = "m41st85"; -+ reg = <0x68>; -+ }; -+ }; -+ -+ -+ i2c1: i2c@1803b000 { -+ compatible = "iproc-smb"; -+ reg = <0x1803b000 0x1000>; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ interrupts = < 128 >; -+ clock-frequency = <100000>; -+ -+ }; -+}; -diff --git a/arch/arm/mach-iproc/Kconfig b/arch/arm/mach-iproc/Kconfig -index c77208d..c6a87fc 100644 ---- a/arch/arm/mach-iproc/Kconfig -+++ b/arch/arm/mach-iproc/Kconfig -@@ -49,6 +49,12 @@ config MACH_ACCTON_AS4610_54 - help - Support for Accton AS4610-54 POE and non -POE board. - -+config MACH_DELTA_AG6248C -+ select ARM_L1_CACHE_SHIFT_6 -+ bool "Support Delta AG6248C board" -+ help -+ Support for Delta AG6248C board. -+ - config MACH_IPROC_P7 - bool "Support iProc Profile 7 architecture" - depends on MACH_GH -diff --git a/arch/arm/mach-iproc/board_bu.c b/arch/arm/mach-iproc/board_bu.c -index 7e07ed1..5479020 100644 ---- a/arch/arm/mach-iproc/board_bu.c -+++ b/arch/arm/mach-iproc/board_bu.c -@@ -1083,6 +1083,7 @@ MACHINE_END - static const char * helix4_dt_board_compat[] = { - "dni,dni_3448p", - "accton,as4610_54", -+ "delta,ag6248c", - NULL - }; - -diff --git a/arch/arm/mach-iproc/common.c b/arch/arm/mach-iproc/common.c -index b116ffc..e911a2b 100644 ---- a/arch/arm/mach-iproc/common.c -+++ b/arch/arm/mach-iproc/common.c -@@ -187,7 +187,8 @@ static struct platform_device wdt_device = - enum { - HX4_NONE = 0, - HX4_DNI_3448P, -- HX4_ACCTON_AS4610_54 -+ HX4_ACCTON_AS4610_54, -+ HX4_DELTA_AG6248C, - }; - - /* -@@ -212,6 +213,8 @@ int brcm_get_hx4_model(void) - return HX4_DNI_3448P; - else if (!strcmp(model, "accton,as4610_54")) - return HX4_ACCTON_AS4610_54; -+ else if (!strcmp(model, "delta,ag6248c")) -+ return HX4_DELTA_AG6248C; - - printk( KERN_ERR "Unknown Model %s\n", model ); - return HX4_NONE; -diff --git a/arch/arm/mach-iproc/include/mach/iproc_regs.h b/arch/arm/mach-iproc/include/mach/iproc_regs.h -index 460c436..50ea557 100644 ---- a/arch/arm/mach-iproc/include/mach/iproc_regs.h -+++ b/arch/arm/mach-iproc/include/mach/iproc_regs.h -@@ -364,7 +364,11 @@ - #define IPROC_GMAC3_INT 182 - #elif (defined(CONFIG_MACH_HX4) || defined(CONFIG_MACH_KT2) || defined(CONFIG_MACH_DNI_3448P) || \ - defined(CONFIG_MACH_ACCTON_AS4610_54)) -+#if defined(CONFIG_MACH_DELTA_AG6248C) -+#define IPROC_NUM_GMACS 1 -+#else - #define IPROC_NUM_GMACS 2 -+#endif - #define IPROC_GMAC0_REG_BASE (GMAC0_DEVCONTROL) //(0x18022000) - #define IPROC_GMAC1_REG_BASE (GMAC1_DEVCONTROL) //(0x18023000) - #define IPROC_GMAC2_REG_BASE (0) // n/a -diff --git a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c -index d5b400d..a823697 100644 ---- a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c -+++ b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c -@@ -143,7 +143,8 @@ __setup("envaddr=", envaddr_setup); - enum { - HX4_NONE = 0, - HX4_DNI_3448P, -- HX4_ACCTON_AS4610_54 -+ HX4_ACCTON_AS4610_54, -+ HX4_DELTA_AG6248C - }; - - static void -@@ -158,7 +159,10 @@ setup_uboot_vars(void) { - } else if (modelnum == HX4_ACCTON_AS4610_54) { - env_offset = 0x000f0000; - uboot_vars_start = CONFIG_SPI_BASE + env_offset; -- } -+ }else if (modelnum == HX4_DELTA_AG6248C) { -+ env_offset = 0x00300000; -+ uboot_vars_start = CONFIG_NAND_BASE + env_offset; -+ } - } - - /* --- -2.1.4 - diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series index 3028ed13..e2adb686 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series @@ -506,4 +506,3 @@ scripts_package_Makefile.patch tools_include_tools_be_byteshift.h.patch tools_include_tools_le_byteshift.h.patch platform-accton-as4610-device-drivers.patch -platform-delta-ag6248c-device-drivers.patch diff --git a/packages/platforms/delta/armel/Makefile b/packages/platforms/delta/armel/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/README.md b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md deleted file mode 100644 index b49d2126..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/README.md +++ /dev/null @@ -1,25 +0,0 @@ -#How to run ONL in DELTA AG6248C board - -For the first step, it only support install the ONL to the USB and boot up. -It will be support to install the ONL to NandFlash next step. - -Build the ONL --------------------------------------------------------------------------- -Please refer the $ONL/docs/Building.md - -Install the ONL through ONIE --------------------------------------------------------------------------- -``` -ONIE:/ # onie-discovery-stop -discover: installer mode detected. -Stopping: discover... done. -ONIE:/ # -ONIE:/ # ifconfig eth0 192.168.1.1 #configure the DUT IP address -ONIE:/ # tftp -r ONL-2.*_ARMEL_INSTALLED_INSTALLER -g 192.168.1.99 -b 10240 -ONIE:/ # onie-nos-install ONL-2.*_ARMEL_INSTALLED_INSTALLER -``` -Boot the ONL --------------------------------------------------------------------------- -Device will reboot automatically after install the ONL installer successfull. - -Now it will start the ONL boot progress. diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore deleted file mode 100644 index 4d978b36..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*cel*redstone*xp*.mk -onlpdump.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml deleted file mode 100755 index cb9893f5..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c KERNELS="onl-kernel-3.2-lts-arm-iproc-all:armel" diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore deleted file mode 100755 index a813c369..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -onlpdump.mk -lib diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile deleted file mode 100755 index 465902c8..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.2-lts-arm-iproc-all:armel -KMODULES := $(wildcard *.c) -VENDOR := delta -BASENAME := arm-delta-ag6248c -ARCH := arm -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c deleted file mode 100755 index 56d68b13..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * An I2C multiplexer dirver for delta as5812 CPLD - * - * Copyright (C) 2017 Delta Networks, Inc. - * Brandon Chuang - * - * This module supports the delta cpld that hold the channel select - * mechanism for other i2c slave devices, such as SFP. - * This includes the: - * Delta ag7648c CPLD1/CPLD2/CPLD3 - * - * Based on: - * pca954x.c from Kumar Gala - * Copyright (C) 2006 - * - * Based on: - * pca954x.c from Ken Harrenstien - * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) - * - * Based on: - * i2c-virtual_cb.c from Brian Kuschak - * and - * pca9540.c from Jean Delvare . - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define CTRL_CPLD_BUS 0x0 -#define CTRL_CPLD_I2C_ADDR 0x28 -#define PARENT_CHAN 0x0 -#define NUM_OF_CPLD_CHANS 0x2 - -#define CPLD_CHANNEL_SELECT_REG 0x19 -#define CPLD_CHANNEL_SELECT_MASK 0x3 -#define CPLD_CHANNEL_SELECT_OFFSET 0x0 - -#define CPLD_DESELECT_CHANNEL 0xff - -#define CPLD_MUX_MAX_NCHANS 0x2 -enum cpld_mux_type { - delta_cpld_mux -}; - -struct delta_i2c_cpld_mux { - enum cpld_mux_type type; - struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; - u8 last_chan; /* last register value */ -}; - -struct chip_desc { - u8 nchans; - u8 deselectChan; -}; - -/* Provide specs for the PCA954x types we know about */ -static const struct chip_desc chips[] = { - [delta_cpld_mux] = { - .nchans = NUM_OF_CPLD_CHANS, - .deselectChan = CPLD_DESELECT_CHANNEL, - } -}; - -static struct delta_i2c_cpld_mux *cpld_mux_data; - -static struct device dump_dev; - -/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() - for this as they will try to lock adapter a second time */ -static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, u8 val) -{ - unsigned long orig_jiffies; - unsigned short flags; - union i2c_smbus_data data; - struct i2c_adapter *ctrl_adap; - int try; - s32 res = -EIO; - u8 reg_val = 0; - - data.byte = val; - flags = 0; - - ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); - if (!ctrl_adap) - return res; - - // try to lock it - if (ctrl_adap->algo->smbus_xfer) { - /* Retry automatically on arbitration loss */ - orig_jiffies = jiffies; - for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { - // read first - res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, - I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, - I2C_SMBUS_BYTE_DATA, &data); - if (res && res != -EAGAIN) - break; - - // modify the field we wanted - data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); - reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); - data.byte |= reg_val; - - // modify the register - res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, - I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, - I2C_SMBUS_BYTE_DATA, &data); - if (res && res != -EAGAIN) - break; - if (time_after(jiffies, - orig_jiffies + ctrl_adap->timeout)) - break; - } - } - - return res; -} - -static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - u8 regval; - int ret = 0; - regval = chan; - - /* Only select the channel if its different from the last channel */ - if (cpld_mux_data->last_chan != regval) { - ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); - cpld_mux_data->last_chan = regval; - } - - return ret; -} - -static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, - void *client, u32 chan) -{ - /* Deselect active channel */ - cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; - - return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); -} - -/* - * I2C init/probing/exit functions - */ -static int __delta_i2c_cpld_mux_init(void) -{ - struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); - int chan=0; - int ret = -ENODEV; - - memset (&dump_dev, 0, sizeof(dump_dev)); - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; - - if (!adap) - goto err; - - cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); - if (!cpld_mux_data) { - ret = -ENOMEM; - goto err; - } - - cpld_mux_data->type = delta_cpld_mux; - cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ - - /* Now create an adapter for each channel */ - for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { - cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, - chan, - delta_i2c_cpld_mux_select_chan, - delta_i2c_cpld_mux_deselect_mux); - - if (cpld_mux_data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); - goto virt_reg_failed; - } - } - - printk("registered %d multiplexed busses for I2C mux bus %d\n", - chan, PARENT_CHAN); - - return 0; - -virt_reg_failed: - for (chan--; chan >= 0; chan--) { - i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); - } - - kfree(cpld_mux_data); -err: - return ret; -} - -static int __delta_i2c_cpld_mux_remove(void) -{ - const struct chip_desc *chip = &chips[cpld_mux_data->type]; - int chan; - - for (chan = 0; chan < chip->nchans; ++chan) { - if (cpld_mux_data->virt_adaps[chan]) { - i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); - cpld_mux_data->virt_adaps[chan] = NULL; - } - } - - kfree(cpld_mux_data); - - return 0; -} - -static int __init delta_i2c_cpld_mux_init(void) -{ - return __delta_i2c_cpld_mux_init (); -} - -static void __exit delta_i2c_cpld_mux_exit(void) -{ - __delta_i2c_cpld_mux_remove (); -} - -MODULE_AUTHOR("Dave Hu "); -MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); -MODULE_LICENSE("GPL"); - -module_init(delta_i2c_cpld_mux_init); -module_exit(delta_i2c_cpld_mux_exit); - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c deleted file mode 100755 index 12b5fb38..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * An I2C multiplexer dirver for delta as5812 CPLD - * - * Copyright (C) 2017 Delta Networks, Inc. - * Brandon Chuang - * - * This module supports the delta cpld that hold the channel select - * mechanism for other i2c slave devices, such as SFP. - * This includes the: - * Delta ag7648c CPLD1/CPLD2/CPLD3 - * - * Based on: - * pca954x.c from Kumar Gala - * Copyright (C) 2006 - * - * Based on: - * pca954x.c from Ken Harrenstien - * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) - * - * Based on: - * i2c-virtual_cb.c from Brian Kuschak - * and - * pca9540.c from Jean Delvare . - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define CTRL_CPLD_BUS 0x0 -#define CTRL_CPLD_I2C_ADDR 0x28 -#define PARENT_CHAN 0x1 -#define NUM_OF_CPLD_CHANS 0x2 - -#define CPLD_CHANNEL_SELECT_REG 0x19 -#define CPLD_CHANNEL_SELECT_MASK 0x3 -#define CPLD_CHANNEL_SELECT_OFFSET 0x5 - -#define CPLD_DESELECT_CHANNEL 0xff - -#define CPLD_MUX_MAX_NCHANS 0x2 -enum cpld_mux_type { - delta_cpld_mux -}; - -struct delta_i2c_cpld_mux { - enum cpld_mux_type type; - struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; - u8 last_chan; /* last register value */ -}; - -struct chip_desc { - u8 nchans; - u8 deselectChan; -}; - -/* Provide specs for the PCA954x types we know about */ -static const struct chip_desc chips[] = { - [delta_cpld_mux] = { - .nchans = NUM_OF_CPLD_CHANS, - .deselectChan = CPLD_DESELECT_CHANNEL, - } -}; - -static struct delta_i2c_cpld_mux *cpld_mux_data; - -static struct device dump_dev; - -/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() - for this as they will try to lock adapter a second time */ -static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, u8 val) -{ - unsigned long orig_jiffies; - unsigned short flags; - union i2c_smbus_data data; - struct i2c_adapter *ctrl_adap; - int try; - s32 res = -EIO; - u8 reg_val = 0; - - data.byte = val; - flags = 0; - - ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); - if (!ctrl_adap) - return res; - - - // try to lock it - if (ctrl_adap->algo->smbus_xfer) { - /* Retry automatically on arbitration loss */ - orig_jiffies = jiffies; - for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { - // read first - res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, - I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, - I2C_SMBUS_BYTE_DATA, &data); - if (res && res != -EAGAIN) - break; - - // modify the field we wanted - data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); - reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); - data.byte |= reg_val; - - // modify the register - res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, - I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, - I2C_SMBUS_BYTE_DATA, &data); - if (res != -EAGAIN) - break; - if (time_after(jiffies, - orig_jiffies + ctrl_adap->timeout)) - break; - } - } - - return res; -} - -static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - u8 regval; - int ret = 0; - regval = chan; - - /* Only select the channel if its different from the last channel */ - if (cpld_mux_data->last_chan != regval) { - ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); - cpld_mux_data->last_chan = regval; - } - - return ret; -} - -static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, - void *client, u32 chan) -{ - /* Deselect active channel */ - cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; - - return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); -} - -/* - * I2C init/probing/exit functions - */ -static int __delta_i2c_cpld_mux_init(void) -{ - struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); - int chan=0; - int ret = -ENODEV; - - memset (&dump_dev, 0, sizeof(dump_dev)); - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; - - if (!adap) - goto err; - - cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); - if (!cpld_mux_data) { - ret = -ENOMEM; - goto err; - } - - cpld_mux_data->type = delta_cpld_mux; - cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ - - /* Now create an adapter for each channel */ - for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { - cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, - chan, - delta_i2c_cpld_mux_select_chan, - delta_i2c_cpld_mux_deselect_mux); - - if (cpld_mux_data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); - goto virt_reg_failed; - } - } - - printk("registered %d multiplexed busses for I2C mux bus %d\n", - chan, PARENT_CHAN); - - return 0; - -virt_reg_failed: - for (chan--; chan >= 0; chan--) { - i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); - } - - kfree(cpld_mux_data); -err: - return ret; -} - -static int __delta_i2c_cpld_mux_remove(void) -{ - const struct chip_desc *chip = &chips[cpld_mux_data->type]; - int chan; - - for (chan = 0; chan < chip->nchans; ++chan) { - if (cpld_mux_data->virt_adaps[chan]) { - i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); - cpld_mux_data->virt_adaps[chan] = NULL; - } - } - - kfree(cpld_mux_data); - - return 0; -} - -static int __init delta_i2c_cpld_mux_init(void) -{ - return __delta_i2c_cpld_mux_init (); -} - -static void __exit delta_i2c_cpld_mux_exit(void) -{ - __delta_i2c_cpld_mux_remove (); -} - -MODULE_AUTHOR("Dave Hu "); -MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); -MODULE_LICENSE("GPL"); - -module_init(delta_i2c_cpld_mux_init); -module_exit(delta_i2c_cpld_mux_exit); - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml deleted file mode 100644 index 63b56dc7..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=arm-delta-ag6248c ARCH=armel TOOLCHAIN=arm-linux-gnueabi diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile deleted file mode 100644 index e7437cb2..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile deleted file mode 100644 index 46fdfee8..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -############################################################ -# -# -# Copyright 2014 BigSwitch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -############################################################ -include $(ONL)/make/config.armel.mk - -MODULE := libonlp-arm-delta-ag6248c -include $(BUILDER)/standardinit.mk - -DEPENDMODULES := AIM IOF arm_delta_ag6248c onlplib -DEPENDMODULE_HEADERS := sff - -include $(BUILDER)/dependmodules.mk - -SHAREDLIB := libonlp-arm-delta-ag6248c.so -$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) -include $(BUILDER)/so.mk -.DEFAULT_GOAL := $(SHAREDLIB) - -GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc -GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 -GLOBAL_CFLAGS += -fPIC -GLOBAL_LINK_LIBS += -lpthread - -include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk deleted file mode 100644 index 9cf2a027..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the libonlp-arm-delta-ag6248c module. -# -# Autogenerated 2016-07-20 18:27:47.344268 -# -############################################################################### -libonlp-arm-delta-ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 3fe979f3..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -############################################################ -# -# -# Copyright 2014 BigSwitch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.armel.mk - -.DEFAULT_GOAL := onlpdump - -MODULE := onlpdump -include $(BUILDER)/standardinit.mk - -DEPENDMODULES := AIM IOF onlp arm_delta_ag6248c onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS - -include $(BUILDER)/dependmodules.mk - -BINARY := onlpdump -$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) -include $(BUILDER)/bin.mk - -GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main -GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 -GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 -GLOBAL_LINK_LIBS += -lpthread -lm - -include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml deleted file mode 100644 index 16ff5c28..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c REVISION=r0 diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml deleted file mode 100644 index ba1cbec5..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- - -###################################################################### -# -# platform-config for AG6248C -# -###################################################################### - -arm-delta-ag6248c-r0: - flat_image_tree: - kernel: - <<: *arm-iproc-kernel - dtb: - =: delta_ag6248c.dtb - <<: *arm-iproc-kernel-package - itb: - <<: *arm-itb - - loader: - device: /dev/mtdblock4 - loadaddr: 0x70000000 - nos_bootcmds: *flash_bootcmds - - environment: - - device: /dev/mtd2 - env_offset: 0x00000000 - env_size: 0x00002000 - sector_size: 0x00010000 - - installer: - - ONL-BOOT: - =: 128MiB - format: ubifs - - ONL-CONFIG: - =: 128MiB - format: ubifs - - ONL-IMAGES: - =: 1024MiB - format: ubifs - - ONL-DATA: - =: 2048MiB - format: ubifs - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py deleted file mode 100755 index 7d7b97a1..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -from onl.platform.base import * -from onl.platform.delta import * - -class OnlPlatform_arm_delta_ag6248c_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x1_2x10): - PLATFORM='arm-delta-ag6248c-r0' - MODEL="AG6248C" - SYS_OBJECT_ID=".6248.2" - - def baseconfig(self): - self.insmod('arm-delta-ag6248c-cpld-mux-1.ko') - self.insmod('arm-delta-ag6248c-cpld-mux-2.ko') - - self.new_i2c_devices( - [ - # initiate lm75 - ('tmp75', 0x49, 0), - ('tmp75', 0x4a, 0), - - - - ] - ) - return True diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore deleted file mode 100644 index 82fb1eaf..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/arm_delta_ag6248c_poe.mk -/doc diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module deleted file mode 100644 index 1e18e32c..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module +++ /dev/null @@ -1 +0,0 @@ -name: arm_delta_ag6248c diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile deleted file mode 100644 index bfc40983..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -############################################################ -# -# -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.mk -MODULE := arm_delta_ag6248c -AUTOMODULE := arm_delta_ag6248c -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy deleted file mode 100644 index b13fcf5d..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy +++ /dev/null @@ -1,1869 +0,0 @@ -# Doxyfile 1.8.3.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = "arm_delta_ag6248c" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "Open Network Platform Linux Example Implementation." - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doc - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a percent sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if section-label ... \endif -# and \cond section-label ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. Do not use -# file names with spaces, bibtex cannot handle them. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = module/inc - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page (index.html). -# This can be useful if you have a project on for instance GitHub and want reuse -# the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and -# SVG. The default value is HTML-CSS, which is slower, but has the best -# compatibility. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. -# There are two flavours of web server based search depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. -# See the manual for details. - -SERVER_BASED_SEARCH = NO - -# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP -# script for searching. Instead the search results are written to an XML file -# which needs to be processed by an external indexer. Doxygen will invoke an -# external search engine pointed to by the SEARCHENGINE_URL option to obtain -# the search results. Doxygen ships with an example indexer (doxyindexer) and -# search engine (doxysearch.cgi) which are based on the open source search engine -# library Xapian. See the manual for configuration details. - -EXTERNAL_SEARCH = NO - -# The SEARCHENGINE_URL should point to a search engine hosted by a web server -# which will returned the search results when EXTERNAL_SEARCH is enabled. -# Doxygen ships with an example search engine (doxysearch) which is based on -# the open source search engine library Xapian. See the manual for configuration -# details. - -SEARCHENGINE_URL = - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed -# search data is written to a file for indexing by an external tool. With the -# SEARCHDATA_FILE tag the name of this file can be specified. - -SEARCHDATA_FILE = searchdata.xml - -# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the -# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is -# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple -# projects and redirect the results back to the right project. - -EXTERNAL_SEARCH_ID = - -# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen -# projects other than the one defined by this configuration file, but that are -# all added to the same external search index. Each project needs to have a -# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id -# of to a relative location where the documentation can be found. -# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... - -EXTRA_SEARCH_MAPPINGS = - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50 percent before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = YES - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk deleted file mode 100644 index 42ac4368..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the arm_delta_ag6248c module. -# -# Autogenerated 2017-02-16 14:19:33.628446 -# -############################################################################### -arm_delta_ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(arm_delta_ag6248c_BASEDIR)module/make.mk -include $(arm_delta_ag6248c_BASEDIR)module/auto/make.mk -include $(arm_delta_ag6248c_BASEDIR)module/src/make.mk - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml deleted file mode 100644 index 80f1a97d..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml +++ /dev/null @@ -1,67 +0,0 @@ -############################################################ -# -# -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -############################################################ - -cdefs: &cdefs -- ONLPSIM_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- ONLPSIM_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- ONLPSIM_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: ONLPSIM_CONFIG_PORTING_STDLIB -- ONLPSIM_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- ONLPSIM_CONFIG_SFP_COUNT: - doc: "SFP Count." - default: 0 - -definitions: - cdefs: - ONLPSIM_CONFIG_HEADER: - defs: *cdefs - basename: arm_delta_ag6248c_config - - portingmacro: - ONLPSIM: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk deleted file mode 100644 index 57889792..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk +++ /dev/null @@ -1,28 +0,0 @@ -############################################################ -# -# -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -############################################################ - -arm_delta_ag6248c_AUTO_DEFS := module/auto/arm_delta_ag6248c.yml -arm_delta_ag6248c_AUTO_DIRS := module/inc/arm_delta_ag6248c module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x deleted file mode 100644 index f15500cc..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h deleted file mode 100644 index 68664185..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -/**************************************************************************//** - * - * @file - * @brief arm_delta_ag6248c Configuration Header - * - * @addtogroup arm_delta_ag6248c-config - * @{ - * - *****************************************************************************/ -#ifndef __ONLPSIM_CONFIG_H__ -#define __ONLPSIM_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef ONLPSIM_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * ONLPSIM_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef ONLPSIM_CONFIG_INCLUDE_LOGGING -#define ONLPSIM_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT -#define ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * ONLPSIM_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef ONLPSIM_CONFIG_LOG_BITS_DEFAULT -#define ONLPSIM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * ONLPSIM_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef ONLPSIM_CONFIG_PORTING_STDLIB -#define ONLPSIM_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLPSIM_CONFIG_PORTING_STDLIB -#endif - -/** - * ONLPSIM_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef ONLPSIM_CONFIG_INCLUDE_UCLI -#define ONLPSIM_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * ONLPSIM_CONFIG_SFP_COUNT - * - * SFP Count. */ - - -#ifndef ONLPSIM_CONFIG_SFP_COUNT -#define ONLPSIM_CONFIG_SFP_COUNT 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct arm_delta_ag6248c_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} arm_delta_ag6248c_config_settings_t; - -/** Configuration settings table. */ -/** arm_delta_ag6248c_config_settings table. */ -extern arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* arm_delta_ag6248c_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "arm_delta_ag6248c_porting.h" - -#endif /* __ONLPSIM_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h deleted file mode 100644 index 20f312ed..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -/********************************************************//** - * - * arm_delta_ag6248c Doxygen Header - * - ***********************************************************/ -#ifndef __ONLPSIM_DOX_H__ -#define __ONLPSIM_DOX_H__ - -/** - * @defgroup arm_delta_ag6248c arm_delta_ag6248c - onlpsim Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup arm_delta_ag6248c-arm_delta_ag6248c Public Interface - * @defgroup arm_delta_ag6248c-config Compile Time Configuration - * @defgroup arm_delta_ag6248c-porting Porting Macros - * - * @} - * - */ - -#endif /* __ONLPSIM_DOX_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h deleted file mode 100644 index 19853401..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -/********************************************************//** - * - * @file - * @brief arm_delta_ag6248c Porting Macros. - * - * @addtogroup arm_delta_ag6248c-porting - * @{ - * - ***********************************************************/ -#ifndef __ONLPSIM_PORTING_H__ -#define __ONLPSIM_PORTING_H__ - - -/* */ -#if ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef ONLPSIM_MALLOC - #if defined(GLOBAL_MALLOC) - #define ONLPSIM_MALLOC GLOBAL_MALLOC - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_MALLOC malloc - #else - #error The macro ONLPSIM_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_FREE - #if defined(GLOBAL_FREE) - #define ONLPSIM_FREE GLOBAL_FREE - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_FREE free - #else - #error The macro ONLPSIM_FREE is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_MEMSET - #if defined(GLOBAL_MEMSET) - #define ONLPSIM_MEMSET GLOBAL_MEMSET - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_MEMSET memset - #else - #error The macro ONLPSIM_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define ONLPSIM_MEMCPY GLOBAL_MEMCPY - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_MEMCPY memcpy - #else - #error The macro ONLPSIM_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define ONLPSIM_STRNCPY GLOBAL_STRNCPY - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_STRNCPY strncpy - #else - #error The macro ONLPSIM_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define ONLPSIM_VSNPRINTF GLOBAL_VSNPRINTF - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_VSNPRINTF vsnprintf - #else - #error The macro ONLPSIM_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define ONLPSIM_SNPRINTF GLOBAL_SNPRINTF - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_SNPRINTF snprintf - #else - #error The macro ONLPSIM_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef ONLPSIM_STRLEN - #if defined(GLOBAL_STRLEN) - #define ONLPSIM_STRLEN GLOBAL_STRLEN - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_STRLEN strlen - #else - #error The macro ONLPSIM_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __ONLPSIM_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk deleted file mode 100644 index 29f7a9f3..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk +++ /dev/null @@ -1,29 +0,0 @@ -############################################################ -# -# -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -# -############################################################ -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -arm_delta_ag6248c_INCLUDES := -I $(THIS_DIR)inc -arm_delta_ag6248c_INTERNAL_INCLUDES := -I $(THIS_DIR)src -arm_delta_ag6248c_DEPENDMODULE_ENTRIES := init:arm_delta_ag6248c ucli:arm_delta_ag6248c - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile deleted file mode 100644 index 94aa2ec9..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -############################################################ -# -# -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# Local source generation targets. -# -############################################################ - -include ../../../../init.mk - -ucli: - $(SUBMODULE_BIGCODE)/tools/uclihandlers.py arm_delta_ag6248c_ucli.c - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c deleted file mode 100644 index 6447135c..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#include - -/* */ -#define __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) #_x -#define __arm_delta_ag6248c_config_STRINGIFY_VALUE(_x) __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) -arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[] = -{ -#ifdef ONLPSIM_CONFIG_INCLUDE_LOGGING - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_LOGGING), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_LOGGING) }, -#else -{ ONLPSIM_CONFIG_INCLUDE_LOGGING(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_LOG_BITS_DEFAULT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ ONLPSIM_CONFIG_LOG_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_PORTING_STDLIB - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_STDLIB), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_STDLIB) }, -#else -{ ONLPSIM_CONFIG_PORTING_STDLIB(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_INCLUDE_UCLI - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_UCLI), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_UCLI) }, -#else -{ ONLPSIM_CONFIG_INCLUDE_UCLI(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef ONLPSIM_CONFIG_SFP_COUNT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_SFP_COUNT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_SFP_COUNT) }, -#else -{ ONLPSIM_CONFIG_SFP_COUNT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __arm_delta_ag6248c_config_STRINGIFY_VALUE -#undef __arm_delta_ag6248c_config_STRINGIFY_NAME - -const char* -arm_delta_ag6248c_config_lookup(const char* setting) -{ - int i; - for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) { - if(strcmp(arm_delta_ag6248c_config_settings[i].name, setting)) { - return arm_delta_ag6248c_config_settings[i].value; - } - } - return NULL; -} - -int -arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", arm_delta_ag6248c_config_settings[i].name, arm_delta_ag6248c_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c deleted file mode 100644 index 2a14c2cc..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h deleted file mode 100644 index 8dfd2c7c..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h +++ /dev/null @@ -1,32 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __ONLPSIM_INT_H__ -#define __ONLPSIM_INT_H__ - -#include - - -#endif /* __ONLPSIM_INT_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c deleted file mode 100644 index 1941f294..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#include - -#include "arm_delta_ag6248c_log.h" -/* - * arm_delta_ag6248c log struct. - */ -AIM_LOG_STRUCT_DEFINE( - ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT, - ONLPSIM_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h deleted file mode 100644 index 13d00bc5..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h +++ /dev/null @@ -1,32 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __ONLPSIM_LOG_H__ -#define __ONLPSIM_LOG_H__ - -#define AIM_LOG_MODULE_NAME arm_delta_ag6248c -#include - -#endif /* __ONLPSIM_LOG_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c deleted file mode 100644 index fdb080f0..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#include - -#include "arm_delta_ag6248c_log.h" - -static int -datatypes_init__(void) -{ -#define ONLPSIM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __arm_delta_ag6248c_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c deleted file mode 100644 index 4dbeeed0..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#include - -#if ONLPSIM_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -arm_delta_ag6248c_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(arm_delta_ag6248c) -} - -/* */ -/****************************************************************************** - * - * These handler table(s) were autogenerated from the symbols in this - * source file. - * - *****************************************************************************/ -static ucli_command_handler_f arm_delta_ag6248c_ucli_ucli_handlers__[] = -{ - arm_delta_ag6248c_ucli_ucli__config__, - NULL -}; -/******************************************************************************/ -/* */ - -static ucli_module_t -arm_delta_ag6248c_ucli_module__ = - { - "arm_delta_ag6248c_ucli", - NULL, - arm_delta_ag6248c_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -arm_delta_ag6248c_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&arm_delta_ag6248c_ucli_module__); - n = ucli_node_create("arm_delta_ag6248c", NULL, &arm_delta_ag6248c_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("arm_delta_ag6248c")); - return n; -} - -#else -void* -arm_delta_ag6248c_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c deleted file mode 100755 index a7a83e0e..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "arm_delta_ag6248c_log.h" -#include "arm_delta_i2c.h" -#include - -struct i2c_device_info i2c_device_list[]={ - {"RTC",0X0,0X68}, - {"TMP1_CLOSE_TO_MAC",0X0,0X49}, - {"TMP2_CLOSE_TO_PHY",0X0,0X4a}, - {"CPLD",0X0,0X28}, - {"FAN_ON_BOARD",0X1,0X2C}, - {"CURT_MONTOR",0X1,0X40}, - {"SFP1",0X2,0X50}, - {"SFP2",0X3,0X50}, -// ------------------------- - {"PSU1_PMBUS",0X4,0X58}, - {"PSU2_PMBUS",0X5,0X59}, - {"PSU1_EEPROM",0X4,0X50}, - {"PSU2_EEPROM",0X5,0X51}, -// ------------------------- - {"PSU1_PMBUS_POE",0X4,0X58}, - {"PSU2_PMBUS_POE",0X5,0X58}, - {"PSU1_EEPROM_POE",0X4,0X52}, - {"PSU2_EEPROM_POE",0X5,0X52}, - {NULL, -1,-1}, -}; - - -uint32_t i2c_flag=ONLP_I2C_F_FORCE; - - -i2c_device_info_t *i2c_dev_find_by_name (char *name) -{ - i2c_device_info_t *i2c_dev = i2c_device_list; - - if (name == NULL) return NULL; - - while (i2c_dev->name) { - if (strcmp (name, i2c_dev->name) == 0) break; - ++ i2c_dev; - } - if (i2c_dev->name == NULL) return NULL; - - return i2c_dev; -} - -int i2c_devname_read_byte (char *name, int reg) -{ - int ret=-1; - i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); - - if(i2c_dev==NULL) return -1; - - ret=onlp_i2c_readb (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); - - return ret; -} - -int i2c_devname_write_byte (char *name, int reg, int value) -{ - int ret=-1; - i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); - - if(i2c_dev==NULL) return -1; - - ret=onlp_i2c_writeb (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); - - - return ret; -} - -int i2c_devname_read_word (char *name, int reg) -{ - int ret=-1; - i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); - - if(i2c_dev==NULL) return -1; - - ret=onlp_i2c_readw (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); - - return ret; -} - -int i2c_devname_write_word (char *name, int reg, int value) -{ - int ret=-1; - i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); - - if(i2c_dev==NULL) return -1; - - ret=onlp_i2c_writew (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); - - return ret; -} - -int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size) -{ - int ret = -1; - - i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); - - if(i2c_dev==NULL) return -1; - - ret = onlp_i2c_block_read (i2c_dev->i2cbus, i2c_dev->addr, reg, buff_size, buff, i2c_flag); - - return ret; - -} - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h deleted file mode 100755 index 76c35cbb..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************/ -/* the i2c struct header*/ - -#ifndef __ARM_DELTA_I2C_H__ -#define __ARM_DELTA_I2C_H__ - -#include "arm_delta_ag6248c_log.h" - -struct i2c_device_info { - /*i2c device name*/ - char *name; - char i2cbus; - char addr; -}; - - -typedef struct i2c_device_info i2c_device_info_t; - -extern struct i2c_device_info i2c_device_list[]; - - -extern int i2c_devname_read_byte(char *name, int reg); - -extern int i2c_devname_write_byte(char *name, int reg, int value); - - -extern int i2c_devname_read_word(char *name, int reg); - -extern int i2c_devname_write_word(char *name, int reg, int value); - - -extern int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size); - -#endif diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c deleted file mode 100755 index b0c16526..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c +++ /dev/null @@ -1,470 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include "platform_lib.h" -#include "arm_delta_ag6248c_int.h" -#include "arm_delta_i2c.h" -#include - -#define MAX_FAN_SPEED 12000 -#define MAX_PSU_FAN_SPEED 23000 - -#define FILE_NAME_LEN 80 - -/* The MAX6639 registers, valid channel numbers: 0, 1 */ -#define MAX6639_REG_STATUS 0x02 -#define MAX6639_REG_FAN_CONFIG1(ch) (0x10 + 4*(ch-1)) -#define MAX6639_REG_FAN_CNT(ch) (0x20 + (ch-1)) -#define MAX6639_REG_TARGET_CNT(ch) (0x22 + (ch-1)) - -/*define the reg bit mask*/ -#define MAX6639_REG_FAN_STATUS_BIT(ch) (0X02>>(ch-1)) -#define MAX6639_FAN_CONFIG1_RPM_RANGE 0x03 -#define MAX6639_FAN_PRESENT_REG (0x0c) -#define MAX6639_FAN_PRESENT_BIT (0x2) -#define MAX6639_FAN_GOOD_BIT (0x1) -#define FAN_FROM_REG(val) ((480000.0) / (val)) - -static int fan_initd=0; - -enum onlp_fan_id -{ - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2 -}; - -#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ - ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ - (ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM| ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ - ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ - (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[] = { - { }, /* Not used */ - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), - MAKE_FAN_INFO_NODE_ON_PSU(1,1), - MAKE_FAN_INFO_NODE_ON_PSU(2,1), -}; - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int - _onlp_psu_fan_val_to_rpm (int v) -{ - int lf = (v & 0xffff); - int y, n; - - y = lf & 0x7ff; - n = ((lf >> 11) & 0x1f); - - return (y * (1 << n)); -} - -static int -_onlp_fan_board_init(void) -{ - i2c_devname_write_byte("FAN_ON_BOARD", 0x03,0xfc); - i2c_devname_write_byte("FAN_ON_BOARD", 0x04,0x30); - - i2c_devname_write_byte("FAN_ON_BOARD", 0x10,0x23); - i2c_devname_write_byte("FAN_ON_BOARD", 0x11,0x00); - i2c_devname_write_byte("FAN_ON_BOARD", 0x12,0x00); - i2c_devname_write_byte("FAN_ON_BOARD", 0x13,0x21); - i2c_devname_write_byte("FAN_ON_BOARD", 0x24,0xe8); - - i2c_devname_write_byte("FAN_ON_BOARD", 0x14,0x23); - i2c_devname_write_byte("FAN_ON_BOARD", 0x15,0x00); - i2c_devname_write_byte("FAN_ON_BOARD", 0x16,0x00); - i2c_devname_write_byte("FAN_ON_BOARD", 0x17,0x21); - i2c_devname_write_byte("FAN_ON_BOARD", 0x25,0xe8); - - fan_initd=1; - - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) -{ - int r_data,fan_good,fan_present,fan_fault; - - /* init the fan on the board*/ - if(fan_initd==0) - _onlp_fan_board_init(); - /* get fan fault status (turn on when any one fails)*/ - r_data= i2c_devname_read_byte("CPLD",MAX6639_FAN_PRESENT_REG); - - if(r_data<0) - return ONLP_STATUS_E_INVALID; - - fan_present = r_data & MAX6639_FAN_PRESENT_BIT; - - if(!fan_present){ - - info->status |= ONLP_FAN_STATUS_PRESENT; - - fan_good=r_data&MAX6639_FAN_GOOD_BIT; - - if(fan_good) - info->status&=~ONLP_FAN_STATUS_FAILED; - else{ - r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_STATUS); - - if(r_data<0) - return ONLP_STATUS_E_INVALID; - - fan_fault=r_data & MAX6639_REG_FAN_STATUS_BIT(local_id); - - if(!fan_fault) - info->status &=~ ONLP_FAN_STATUS_FAILED; - else{ - info->status |=ONLP_FAN_STATUS_FAILED; - info->rpm=0; - info->percentage=0; - goto mode; - } - } - } - else{ - info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - - /* get fan speed */ - r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_FAN_CNT(local_id)); - - if(r_data<0) - return ONLP_STATUS_E_INVALID; - - info->rpm = FAN_FROM_REG(r_data); - - /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100.0) / MAX_FAN_SPEED; - -mode: - if(info->percentage>100) - strcpy(info->model,"ONLP_FAN_MODE_LAST"); - else if(info->percentage==100) - strcpy(info->model,"ONLP_FAN_MODE_MAX"); - else if(info->percentage>=75&&info->percentage<100) - strcpy(info->model,"ONLP_FAN_MODE_FAST"); - else if(info->percentage>=35&&info->percentage<75) - strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); - else if(info->percentage>0&&info->percentage<35) - strcpy(info->model,"ONLP_FAN_MODE_SLOW"); - else if(info->percentage<=0) - strcpy(info->model,"ONLP_FAN_MODE_OFF"); - else{ } - - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) -{ - int psu_id; - int r_data,fan_rpm; - int psu_present; - int psu_good; - psu_type_t psu_type; - - enum ag6248c_product_id pid = get_product_id(); - /* get fan fault status - */ - psu_id = (local_id - FAN_1_ON_PSU1) + 1; - DEBUG_PRINT("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id); - - psu_type = get_psu_type(psu_id); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */ - DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type); - psu_present=psu_status_info_get(psu_id, "present"); - psu_good=psu_status_info_get(psu_id, "good"); - if((psu_present<=0)||(psu_good<=0)){ - info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - - switch (psu_type) { - case PSU_TYPE_AC_F2B: - info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B); - break; - case PSU_TYPE_AC_B2F: - info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* get fan speed*/ - if(pid == PID_AG6248C_48){ - if(psu_id==1) - r_data=i2c_devname_read_word("PSU1_PMBUS", 0x90); - else - r_data=i2c_devname_read_word("PSU2_PMBUS", 0x90); - } - else{ - if(psu_id==1) - r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x90); - else - r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x90); - } - - if(r_data<0) - return ONLP_STATUS_E_INVALID; - - fan_rpm=_onlp_psu_fan_val_to_rpm(r_data); - - info->rpm = fan_rpm; - - /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100.0) / MAX_PSU_FAN_SPEED; - - if(info->percentage>100) - strcpy(info->model,"ONLP_FAN_MODE_LAST"); - else if(info->percentage==100) - strcpy(info->model,"ONLP_FAN_MODE_MAX"); - else if(info->percentage>=75&&info->percentage<100) - strcpy(info->model,"ONLP_FAN_MODE_FAST"); - else if(info->percentage>=35&&info->percentage<75) - strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); - else if(info->percentage>0&&info->percentage<35) - strcpy(info->model,"ONLP_FAN_MODE_SLOW"); - else if(info->percentage<=0) - strcpy(info->model,"ONLP_FAN_MODE_OFF"); - else{} - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - int rc; - rc=_onlp_fan_board_init(); - return rc; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) -{ - int rc = 0; - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - if (chassis_fan_count() == 0) { - local_id += 1; - } - - *info = linfo[local_id]; - - switch (local_id) - { - case FAN_1_ON_PSU1: - case FAN_1_ON_PSU2: - rc = _onlp_fani_info_get_fan_on_psu(local_id, info); - break; - case FAN_1_ON_MAIN_BOARD: - case FAN_2_ON_MAIN_BOARD: - rc =_onlp_fani_info_get_fan(local_id, info); - break; - default: - rc = ONLP_STATUS_E_INVALID; - break; - } - - return rc; -} - -/* - * This function sets the speed of the given fan in RPM. - * - * This function will only be called if the fan supprots the RPM_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ /* - the rpm is the actual rpm/1000. so 16 represents the 16000(max spd) - */ - int fan_set_rpm_cont,rc; - int local_id; - int actual_rpm=rpm; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) - return ONLP_STATUS_E_UNSUPPORTED; - - if (chassis_fan_count() == 0) { - return ONLP_STATUS_E_INVALID; - } - /* init the fan on the board*/ - if(fan_initd==0) - _onlp_fan_board_init(); - - /* reject rpm=0 (rpm=0, stop fan) */ - if (actual_rpm == 0) - return ONLP_STATUS_E_INVALID; - - /*get ret value for the speed set*/ - fan_set_rpm_cont=FAN_FROM_REG(actual_rpm); - - /*set the rpm speed */ - rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont); - - if(rc<0) - return ONLP_STATUS_E_INVALID; - - return ONLP_STATUS_OK; -} -/*set the percentage for the psu fan*/ - - -/* - * This function sets the fan speed of the given OID as a percentage. - * - * This will only be called if the OID has the PERCENTAGE_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_percentage_set(onlp_oid_t id, int p) -{ - /* - p is between 0 and 100 ,p=100 represents 16000(max spd) - */ - int rpm_val,fan_set_rpm_cont,rc; - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) - return ONLP_STATUS_E_UNSUPPORTED; - - if (chassis_fan_count() == 0) { - return ONLP_STATUS_E_INVALID; - } - - /* init the fan on the board*/ - if(fan_initd==0) - _onlp_fan_board_init(); - - /* reject p=0 (p=0, stop fan) */ - if (p == 0){ - return ONLP_STATUS_E_INVALID; - } - - rpm_val=p*(MAX_FAN_SPEED/100); - - /*get ret value for the speed set*/ - fan_set_rpm_cont=FAN_FROM_REG(rpm_val); - - /*set the rpm speed */ - rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont); - - if(rc<0) - return ONLP_STATUS_E_INVALID; - - return ONLP_STATUS_OK; - - -} - - -/* - * This function sets the fan speed of the given OID as per - * the predefined ONLP fan speed modes: off, slow, normal, fast, max. - * - * Interpretation of these modes is up to the platform. - * - */ -int -onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan direction of the given OID. - * - * This function is only relevant if the fan OID supports both direction - * capabilities. - * - * This function is optional unless the functionality is available. - */ -int -onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c deleted file mode 100755 index 1a0ea7bb..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c +++ /dev/null @@ -1,352 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include - -#include -#include "platform_lib.h" -#include "arm_delta_ag6248c_int.h" -#include "arm_delta_i2c.h" -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -#define CPLD_LED_MODE_REG (0X0A) -#define CPLD_LED_MODE_TEMP_REG (0X0B) -#define CPLD_LED_MODE_REG_BIT(ch) (0x3<<2*((ch)-1)) -#define CPLD_LED_MODE_TEMP_REG_BIT (0x0C) -#define CPLD_LED_MODE_MASTER_REG_BIT (0x02) -#define CPLD_LED_MODE_REG_OFFSET(ch) (2*((ch)-1)) -#define CPLD_LED_MODE_TEMP_REG_OFFSET (2) -#define CPLD_LED_MODE_MASTER_REG_OFFSET (1) - - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "sys", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_GREEN_BLINKING |ONLP_LED_CAPS_GREEN | - ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_RED , - }, - - { - { ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 }, - ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_ON_OFF | - ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - }, - - { - { ONLP_LED_ID_CREATE(LED_PSU2), "psu2", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING | - ONLP_LED_CAPS_GREEN , - }, - - { - { ONLP_LED_ID_CREATE(LED_PSU1), "psu1", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING | - ONLP_LED_CAPS_GREEN , - }, - - { - { ONLP_LED_ID_CREATE(LED_TEMP), "temp", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | - ONLP_LED_CAPS_RED , - }, - - { - { ONLP_LED_ID_CREATE(LED_MASTER), "master", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN , - }, -}; - -static int conver_led_light_mode_to_onl(uint32_t id, int led_ligth_mode) -{ - switch (id) { - case LED_SYS: - switch (led_ligth_mode) { - case SYS_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; - case SYS_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; - case SYS_LED_MODE_RED: return ONLP_LED_MODE_RED; - case SYS_LED_MODE_RED_BLINKING: return ONLP_LED_MODE_RED_BLINKING; - default: return ONLP_LED_MODE_OFF; - } - case LED_PSU1: - case LED_PSU2: - switch (led_ligth_mode) { - case PSU_LED_MODE_OFF: return ONLP_LED_MODE_OFF; - case PSU_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; - case PSU_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; - default: return ONLP_LED_MODE_OFF; - } - case LED_FAN: - switch (led_ligth_mode) { - case FAN_LED_MODE_OFF: return ONLP_LED_MODE_OFF; - case FAN_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; - case FAN_LED_MODE_RED: return ONLP_LED_MODE_RED; - default: return ONLP_LED_MODE_OFF; - } - case LED_TEMP: - switch (led_ligth_mode) { - case TEMP_LED_MODE_OFF: return ONLP_LED_MODE_OFF; - case TEMP_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; - case TEMP_LED_MODE_RED: return ONLP_LED_MODE_RED; - default: return ONLP_LED_MODE_OFF; - } - case LED_MASTER: - switch (led_ligth_mode) { - case MASTER_LED_MODE_OFF: return ONLP_LED_MODE_OFF; - case MASTER_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; - default: return ONLP_LED_MODE_OFF; - } - } - - return ONLP_LED_MODE_OFF; -} - -static int conver_onlp_led_light_mode_to_driver(uint32_t id, int led_ligth_mode) -{ - switch (id) { - case LED_SYS: - switch (led_ligth_mode) { - case ONLP_LED_MODE_GREEN_BLINKING: return SYS_LED_MODE_GREEN_BLINKING; - case ONLP_LED_MODE_GREEN: return SYS_LED_MODE_GREEN; - case ONLP_LED_MODE_RED: return SYS_LED_MODE_RED ; - case ONLP_LED_MODE_RED_BLINKING: return SYS_LED_MODE_RED_BLINKING; - default: return SYS_LED_MODE_UNKNOWN; - } - case LED_PSU1: - case LED_PSU2: - switch (led_ligth_mode) { - case ONLP_LED_MODE_OFF: return PSU_LED_MODE_OFF; - case ONLP_LED_MODE_GREEN: return PSU_LED_MODE_GREEN; - case ONLP_LED_MODE_GREEN_BLINKING: return PSU_LED_MODE_GREEN_BLINKING; - default: return PSU_LED_MODE_UNKNOWN; - } - case LED_FAN: - switch (led_ligth_mode) { - case ONLP_LED_MODE_OFF: return FAN_LED_MODE_OFF; - case ONLP_LED_MODE_GREEN: return FAN_LED_MODE_GREEN ; - case ONLP_LED_MODE_RED: return FAN_LED_MODE_RED; - default: return FAN_LED_MODE_UNKNOWN; - } - case LED_TEMP: - switch (led_ligth_mode) { - case ONLP_LED_MODE_OFF: return TEMP_LED_MODE_OFF; - case ONLP_LED_MODE_GREEN: return TEMP_LED_MODE_GREEN; - case ONLP_LED_MODE_RED: return TEMP_LED_MODE_RED; - default: return TEMP_LED_MODE_UNKNOWN; - } - case LED_MASTER: - switch (led_ligth_mode) { - case ONLP_LED_MODE_OFF: return MASTER_LED_MODE_OFF; - case ONLP_LED_MODE_GREEN: return MASTER_LED_MODE_GREEN; - default: return TEMP_LED_MODE_UNKNOWN; - } - - } - - return ONLP_LED_MODE_OFF; -} - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -int -onlp_ledi_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -onlp_ledi_oid_to_internal_id(onlp_oid_t id) -{ - enum ag6248c_product_id pid = get_product_id(); - int lid = ONLP_OID_ID_GET(id); - - if ((pid != PID_AG6248C_48P)||(pid != PID_AG6248C_48)) { - return lid; - } - - switch (lid) { - case 1: return LED_SYS; - case 2: return LED_FAN; - case 3: return LED_PSU2; - case 4: return LED_PSU1; - case 5: return LED_TEMP; - case 6: return LED_MASTER; - } - - return lid; -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int r_data,m_data; - - int lid = onlp_ledi_oid_to_internal_id(id); - - VALIDATE(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[lid]; - - if((lid==LED_TEMP)||(lid==LED_MASTER)) - r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG); - else - r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG); - - if(r_data<0) - return ONLP_STATUS_E_INTERNAL; - - if(lid==LED_TEMP) - m_data=(r_data & CPLD_LED_MODE_TEMP_REG_BIT); - else if(lid==LED_MASTER) - m_data=(r_data & CPLD_LED_MODE_MASTER_REG_BIT); - else - m_data=(r_data & CPLD_LED_MODE_REG_BIT(lid)); - - if(lid==LED_TEMP) - m_data=(m_data>> CPLD_LED_MODE_TEMP_REG_OFFSET); - else if(lid==LED_MASTER) - m_data=(m_data>> CPLD_LED_MODE_MASTER_REG_OFFSET); - else - m_data=(m_data>>CPLD_LED_MODE_REG_OFFSET(lid)); - - info->mode = conver_led_light_mode_to_onl(lid, m_data); - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - - } - - return ONLP_STATUS_OK; -} - -/* - * This function puts the LED into the given mode. It is a more functional - * interface for multimode LEDs. - * - * Only modes reported in the LED's capabilities will be attempted. - */ -int -onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) -{ - int r_data,driver_mode, rc; - - int lid = onlp_ledi_oid_to_internal_id(id); - - VALIDATE(id); - - driver_mode = conver_onlp_led_light_mode_to_driver(lid, mode); - - if((driver_mode==SYS_LED_MODE_UNKNOWN)||(driver_mode==PSU_LED_MODE_UNKNOWN)||\ - (driver_mode==FAN_LED_MODE_UNKNOWN)||(driver_mode==TEMP_LED_MODE_UNKNOWN)||\ - (driver_mode==MASTER_LED_MODE_UNKNOWN)) - return ONLP_STATUS_E_UNSUPPORTED; - - if((lid==LED_TEMP)||(lid==LED_MASTER)) - r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG); - else - r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG); - - if(r_data<0) - return ONLP_STATUS_E_INTERNAL; - - if(lid==LED_TEMP) - r_data=r_data&(~CPLD_LED_MODE_TEMP_REG_BIT); - else if(lid==LED_MASTER) - r_data=r_data&(~CPLD_LED_MODE_MASTER_REG_BIT); - else - r_data=r_data&(~CPLD_LED_MODE_REG_BIT(lid)); - - if(lid==LED_TEMP) - driver_mode=(driver_mode< -# -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# -# -############################################################ - -LIBRARY := arm_delta_ag6248c -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -#$(LIBRARY)_LAST := 1 -include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c deleted file mode 100755 index 118cc437..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include "arm_delta_i2c.h" - - -psu_type_t get_psu_type(int id) -{ - if ((id == PSU1_ID)||(id == PSU2_ID)) - return PSU_TYPE_AC_B2F; - return PSU_TYPE_UNKNOWN; -} - -enum ag6248c_product_id get_product_id(void) -{ - int ret; - int pid = PID_UNKNOWN; - - ret = i2c_devname_read_byte("CPLD", 0X01); - - if(ret<0) - return PID_UNKNOWN; - - pid = ((ret&0xf0)>>4); - - - if (pid >= PID_UNKNOWN || pid < PID_AG6248C_48) { - return PID_UNKNOWN; - } - - return pid; -} - -int chassis_fan_count(void) -{ - enum ag6248c_product_id pid = get_product_id(); - - if ((pid == PID_AG6248C_48P)||(pid == PID_AG6248C_48)) { - return 4; - } - - return 0 ; -} - -int chassis_led_count(void) -{ - enum ag6248c_product_id pid = get_product_id(); - - if (pid == PID_AG6248C_48P) - return 5; - else if(pid == PID_AG6248C_48) - return 6; - else - return 0; -} diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h deleted file mode 100755 index b8f6fc46..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "arm_delta_ag6248c_log.h" - -#define CHASSIS_THERMAL_COUNT 4 -#define CHASSIS_PSU_COUNT 2 - -#define PSU1_ID 1 -#define PSU2_ID 2 - - -typedef enum psu_type { - PSU_TYPE_UNKNOWN, - PSU_TYPE_AC_F2B, - PSU_TYPE_AC_B2F -} psu_type_t; - -psu_type_t get_psu_type(int id); - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) -#else - #define DEBUG_PRINT(format, ...) -#endif - -enum onlp_fan_duty_cycle_percentage -{ - FAN_IDLE_RPM = 5500, - FAN_LEVEL1_RPM = 7000, - FAN_LEVEL2_RPM = 9000, - FAN_LEVEL3_RPM = 12000, -}; - -enum ag6248c_product_id { - PID_AG6248C_48= 2, - PID_AG6248C_48P=4, - PID_UNKNOWN -}; -/* LED related data */ -enum sys_led_light_mode { - SYS_LED_MODE_GREEN_BLINKING = 0, - SYS_LED_MODE_GREEN, - SYS_LED_MODE_RED, - SYS_LED_MODE_RED_BLINKING, - SYS_LED_MODE_AUTO, - SYS_LED_MODE_UNKNOWN -}; - -enum fan_led_light_mode { - FAN_LED_MODE_OFF=0, - FAN_LED_MODE_GREEN, - FAN_LED_MODE_RED, - FAN_LED_MODE_RESERVERD, - FAN_LED_MODE_AUTO, - FAN_LED_MODE_UNKNOWN -}; - -enum psu_led_light_mode { - PSU_LED_MODE_OFF =0, - PSU_LED_MODE_GREEN, - PSU_LED_MODE_GREEN_BLINKING, - PSU_LED_MODE_RESERVERD, - PSU_LED_MODE_UNKNOWN -}; - -enum temp_led_light_mode { - TEMP_LED_MODE_OFF =0, - TEMP_LED_MODE_GREEN, - TEMP_LED_MODE_RED, - TEMP_LED_MODE_RESERVERD, - TEMP_LED_MODE_UNKNOWN -}; - -enum master_led_light_mode { - MASTER_LED_MODE_OFF =0, - MASTER_LED_MODE_GREEN, - MASTER_LED_MODE_OFF1, - MASTER_LED_MODE_RESERVERD, - MASTER_LED_MODE_UNKNOWN -}; - -typedef enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SYS, - LED_FAN, - LED_PSU2, - LED_PSU1, - LED_TEMP, - LED_MASTER -} onlp_led_id_t; - -enum ag6248c_product_id get_product_id(void); -int chassis_fan_count(void); -int chassis_led_count(void); - -typedef enum platform_id_e { - PLATFORM_ID_UNKNOWN, - PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0, - PLATFORM_ID_POWERPC_DELTA_AG6248C_R0, -} platform_id_t; - -extern platform_id_t platform_id; - -extern int psu_status_info_get(int id, char *node); -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c deleted file mode 100755 index 3a0d8344..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c +++ /dev/null @@ -1,381 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include "platform_lib.h" -#include "arm_delta_ag6248c_int.h" -#include "arm_delta_i2c.h" - -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 -#define PSU_STATUS_REG (0X08) -#define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1)) -#define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1)) -#define PSU_STATUS_PRESENT_OFFSET(ch) (4*ch-1) -#define PSU_STATUS_GOOD_OFFSET(ch) (0x2+4*(ch-1)) -#define PSU_PNBUS_VIN_REG (0x88) -#define PSU_PNBUS_IIN_REG (0x89) -#define PSU_PNBUS_PIN_REG (0x97) -#define PSU_PNBUS_VOUT_REG (0x8b) -#define PSU_PNBUS_IOUT_REG (0x8c) -#define PSU_PNBUS_POUT_REG (0x96) -#define PSU_PNBUS_SERIAL_REG (0x39) -#define PSU_PNBUS_MODEL_REG (0xc) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static long psu_data_convert(unsigned int d, int mult) -{ - long X, Y, N, n; - - Y = d & 0x07FF; - N = (d >> 11) & 0x0f; - n = d & 0x8000 ? 1 : 0; - - if (n) - X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; - else - X = (Y * mult) * (N=(1<<(N&0xf))); - - return X; -} - -static long psu_data_convert_16(unsigned int d, int mult) -{ - long X; - X = (d * mult) / (1 << 9); - return X; - -} - - -int -psu_status_info_get(int id, char *node) -{ - int ret; - int r_data; - ret=i2c_devname_read_byte("CPLD",PSU_STATUS_REG); - - if(ret<0) - return -1; - - if (PSU1_ID == id) { - if(!strcmp("present",node)) - r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); - else if(!strcmp("good",node)) - r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); - else - r_data=-1; - - } - else if (PSU2_ID == id) { - - if(!strcmp("present",node)) - r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); - else if(!strcmp("good",node)) - r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); - else - r_data=-1; - } - else{ - r_data=-1; - } - - return r_data; -} - -static int -psu_value_info_get(int id, char *type) -{ - int ret; - char *dev_name; - int reg_offset; - - enum ag6248c_product_id pid = get_product_id(); - - if(pid == PID_AG6248C_48){ - if(PSU1_ID == id) - dev_name="PSU1_PMBUS"; - else - dev_name="PSU2_PMBUS"; - } - else{ - if(PSU1_ID == id) - dev_name="PSU1_PMBUS_POE"; - else - dev_name="PSU2_PMBUS_POE"; - } - - if(!strcmp(type,"vin")) - reg_offset=PSU_PNBUS_VIN_REG; - else if(!strcmp(type,"iin")) - reg_offset=PSU_PNBUS_IIN_REG; - else if(!strcmp(type,"pin")) - reg_offset=PSU_PNBUS_PIN_REG; - else if(!strcmp(type,"vout")) - reg_offset=PSU_PNBUS_VOUT_REG; - else if(!strcmp(type,"iout")) - reg_offset=PSU_PNBUS_IOUT_REG; - else - reg_offset=PSU_PNBUS_POUT_REG; - - ret=i2c_devname_read_word(dev_name,reg_offset); - - if(ret<0) - return -1; - - return ret; -} - - -static int -psu_serial_model_info_get(int id,char *type,char*data,int data_len) -{ - int i,r_data,re_cnt; - char *dev_name; - int reg_offset; - - enum ag6248c_product_id pid = get_product_id(); - - if(pid == PID_AG6248C_48){ - if(PSU1_ID == id) - dev_name="PSU1_EEPROM"; - else - dev_name="PSU2_EEPROM"; - } - else{ - if(PSU1_ID == id) - dev_name="PSU1_EEPROM_POE"; - else - dev_name="PSU2_EEPROM_POE"; - } - - if(!strcmp(type,"serial")) - reg_offset=PSU_PNBUS_SERIAL_REG; - else - reg_offset=PSU_PNBUS_MODEL_REG; - - for(i=0;istatus &= ~ONLP_PSU_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get power good status */ - val=psu_status_info_get(index,"good"); - - if (val<0) { - AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - if (val != PSU_STATUS_POWER_GOOD) { - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - /* Get PSU type - */ - psu_type = get_psu_type(index); - - switch (psu_type) { - case PSU_TYPE_AC_F2B: - case PSU_TYPE_AC_B2F: - info->caps = ONLP_PSU_CAPS_AC; - ret = ONLP_STATUS_OK; - break; - case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - info->status &= ~ONLP_PSU_STATUS_FAILED; - ret = ONLP_STATUS_OK; - break; - default: - ret = ONLP_STATUS_E_UNSUPPORTED; - break; - } - - /* Get PSU vin,vout*/ - - r_data=psu_value_info_get(index,"vin"); - - if (r_data<0) { - AIM_LOG_INFO("Unable to read PSU %d Vin value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - info->mvin=psu_data_convert(r_data,1000); - - r_data=psu_value_info_get(index,"vout"); - - if (r_data<0) { - AIM_LOG_INFO("Unable to read PSU %d Vout value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - info->mvout=psu_data_convert_16(r_data,1000); - /* Get PSU iin, iout - */ - r_data=psu_value_info_get(index,"iin"); - - if (r_data<0) { - AIM_LOG_INFO("Unable to read PSU %d Iin value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - info->miin=psu_data_convert(r_data,1000); - - r_data=psu_value_info_get(index,"iout"); - - if (r_data<0) { - AIM_LOG_INFO("Unable to read PSU %d Iout value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - info->miout=psu_data_convert(r_data,1000); - - /* Get PSU pin, pout - */ - r_data=psu_value_info_get(index,"pin"); - - if (r_data<0) { - AIM_LOG_INFO("Unable to read PSU %d Pin value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - info->mpin=psu_data_convert(r_data,1000); - - r_data=psu_value_info_get(index,"pout"); - - if (r_data<0) { - AIM_LOG_INFO("Unable to read PSU %d Pout value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - info->mpout=psu_data_convert(r_data,1000); - /* Get PSU serial - */ - - ret=psu_serial_model_info_get(index,"serial",sn_data,14); - if (ret!=ONLP_STATUS_OK) { - AIM_LOG_INFO("Unable to read PSU %d SN value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - strcpy(info->serial,sn_data); - - /* Get PSU model - */ - ret=psu_serial_model_info_get(index,"model",model_data,16); - if (ret!=ONLP_STATUS_OK) { - AIM_LOG_INFO("Unable to read PSU %d model value)\r\n", index); - return ONLP_STATUS_E_INVALID; - } - - strcpy(info->model,model_data); - - return ONLP_STATUS_OK; -} - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c deleted file mode 100755 index 4764bbe9..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c +++ /dev/null @@ -1,364 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "platform_lib.h" - -#include -#include "arm_delta_ag6248c_log.h" -#include "arm_delta_i2c.h" - -#define SFP_PRESENT_REG (0X14) -#define SFP_RX_LOS_REG (0X11) -#define SFP_TX_DISABLE_REG (0X17) -#define SFP_PRESENT_PORT47_BIT (0X40) -#define SFP_PRESENT_PORT48_BIT (0X80) -#define SFP_PRESENT_PORT47_OFFSET (0X06) -#define SFP_PRESENT_PORT48_OFFSET (0X07) - - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int start_port, end_port; - - if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| - (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)) - { - start_port = 47; - end_port = 48; - } - else /*reserved*/ - { - AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); - return ONLP_STATUS_E_UNSUPPORTED; - } - - for(p = start_port; p <=end_port; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - /* - * Return 1 if present. - * Return 0 if not present. - * Return < 0 if error. - */ - int present,r_data; - - if((port==47)||(port==48)) - r_data=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG); - else{ - AIM_LOG_ERROR("The port %d is invalid \r\n", port); - return ONLP_STATUS_E_UNSUPPORTED; - } - - if(r_data<0){ - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - if(port==47){ - r_data&=SFP_PRESENT_PORT47_BIT; - present=!(r_data>>SFP_PRESENT_PORT47_OFFSET); - } - else{ - r_data&=SFP_PRESENT_PORT48_BIT; - present=!(r_data>>SFP_PRESENT_PORT48_OFFSET); - } - - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int status; - int port, i = 0; - uint64_t presence_all=0; - - AIM_BITMAP_CLR_ALL(dst); - - if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \ - (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){ - - port=47; - - } - else{ - AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); - return ONLP_STATUS_E_UNSUPPORTED; - } - - status=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG); - - if(status<0){ - AIM_LOG_ERROR("Unable to read the sfp_is_present_all value. \r\n"); - return ONLP_STATUS_E_INTERNAL; - } - status=~status; - - status>>=6; - - /* Convert to 64 bit integer in port order */ - - presence_all = status & 0x3; - - presence_all <<= port; - - /* Populate bitmap */ - for(i = 0; presence_all; i++) { - AIM_BITMAP_MOD(dst, i, (presence_all & 1)); - presence_all >>= 1; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int status; - int port,i = 0; - uint64_t rx_los_all = 0; - - AIM_BITMAP_CLR_ALL(dst); - - if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \ - (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){ - - port=47; - - } - else{ - AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); - return ONLP_STATUS_E_UNSUPPORTED; - } - - status=i2c_devname_read_byte("CPLD", SFP_RX_LOS_REG); - - if(status<0){ - AIM_LOG_ERROR("Unable to read the rx loss reg value. \r\n"); - return ONLP_STATUS_E_INTERNAL; - } - - status>>=6; - - /* Convert to 64 bit integer in port order */ - rx_los_all = status & 0x3; - - rx_los_all <<= port; - - /* Populate bitmap */ - for(i = 0; rx_los_all; i++) { - AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); - rx_los_all >>= 1; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - /* - * Read the SFP eeprom into data[] - * - * Return MISSING if SFP is missing. - * Return OK if eeprom is read - */ - - int i, r_data, re_cnt; - char* sfp_name; - - memset(data, 0, 256); - - if(port==47) - sfp_name="SFP1"; - else - sfp_name="SFP2"; - - - for(i=0;i<256;i++){ - re_cnt=3; - while(re_cnt){ - r_data=i2c_devname_read_byte(sfp_name,i); - if(r_data<0){ - re_cnt--; - continue; - } - data[i]=r_data; - break; - } - if(re_cnt==0){ - AIM_LOG_ERROR("Unable to read the %d reg \r\n",i); - return ONLP_STATUS_E_INTERNAL; - } - - } - - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - - return onlp_sfpi_eeprom_read( port, data); -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - /*value is 1 if the tx disable - value is 0 if the tx enable - */ - - int rc,r_data,dis_value,present; - - present=onlp_sfpi_is_present(port); - - if(present==0){ - AIM_LOG_INFO("The port %d is not present and can not set tx disable\r\n",port); - return ONLP_STATUS_E_UNSUPPORTED; - } - - r_data=i2c_devname_read_byte("CPLD", SFP_TX_DISABLE_REG); - - if(r_data<0){ - AIM_LOG_INFO("Unable to read sfp tx disable reg value\r\n"); - return ONLP_STATUS_E_INTERNAL; - } - - if(port==47){ - r_data&=~(0x1<>SFP_PRESENT_PORT47_OFFSET); - } - else{ - r_data&=(0x1<>SFP_PRESENT_PORT48_OFFSET); - } - - return ONLP_STATUS_OK; -} - - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c deleted file mode 100755 index b8b0adec..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c +++ /dev/null @@ -1,290 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "arm_delta_ag6248c_int.h" -#include "arm_delta_ag6248c_log.h" - -#include "platform_lib.h" -#include "arm_delta_i2c.h" -platform_id_t platform_id = PLATFORM_ID_UNKNOWN; - -#define ONIE_PLATFORM_NAME "arm-delta-ag6248c-r0" - -const char* -onlp_sysi_platform_get(void) -{ - enum ag6248c_product_id pid = get_product_id(); - - if (pid == PID_AG6248C_48) - return "arm-delta-ag6248c"; - else if(pid == PID_AG6248C_48P) - return "arm-delta-ag6248c-poe"; - else - return "unknow"; -} - -int -onlp_sysi_platform_set(const char* platform) -{ - if(strstr(platform,"arm-delta-ag6248c-r0")) { - platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_R0; - return ONLP_STATUS_OK; - } - if(strstr(platform,"arm-delta-ag6248c-poe-r0")) { - platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0; - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("No support for platform '%s'", platform); - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int v; - - v = i2c_devname_read_byte("CPLD", 0X07); - - pi->cpld_versions = aim_fstrdup("%d", v); - - return 0; -} - -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - uint8_t* rdata = aim_zmalloc(256); - int fd,rc_size; - char fullpath[20] = {0}; - - sprintf(fullpath, "/dev/mtd7"); - - fd=open(fullpath,O_RDWR); - - if(fd<0){ - aim_free(rdata); - return ONLP_STATUS_E_INTERNAL ; - } - - rc_size=read(fd,rdata,256); - - if(rc_size<0||rc_size!=256){ - aim_free(rdata); - return ONLP_STATUS_E_INTERNAL ; - } - - *data = rdata; - - return ONLP_STATUS_OK; - - -} - -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - aim_free(data); -} - - - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - int i; - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - - /* 1 Thermal sensors on the chassis */ - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* LEDs on the chassis */ - for (i = 1; i <= chassis_led_count(); i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* 1 Fans on the chassis */ - for (i = 1; i <= chassis_fan_count(); i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - /* 2 PSUs on the chassis */ - for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { - *e++ = ONLP_PSU_ID_CREATE(i); - } - - return 0; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - - int rc; - onlp_thermal_info_t ti1; - onlp_thermal_info_t ti2; - int mtemp=0; - int new_rpm=0; - - if (chassis_fan_count() == 0) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* Get temperature */ - rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); - - if (rc != ONLP_STATUS_OK) { - return rc; - } - - rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); - - if (rc != ONLP_STATUS_OK) { - return rc; - } - - mtemp=(ti1.mcelsius+ti2.mcelsius)/2; - /* Bring fan speed according the temp - */ - if(mtemp<50000) - new_rpm=FAN_IDLE_RPM; - else if((mtemp>=55000)&&(mtemp<60000)) - new_rpm=FAN_LEVEL1_RPM; - else if((mtemp>=65000)&&(mtemp<70000)) - new_rpm=FAN_LEVEL2_RPM; - else if(mtemp>=75000) - new_rpm=FAN_LEVEL3_RPM; - else{ - return ONLP_STATUS_OK; - } - - onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); - onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); - - - return ONLP_STATUS_OK; -} - - -int -onlp_sysi_platform_manage_leds(void) -{ - int rc,rc1; - - onlp_fan_info_t info1,info2; - onlp_led_mode_t fan_new_mode; - onlp_thermal_info_t ti; - onlp_led_mode_t temp_new_mode; - onlp_psu_info_t psu1; - onlp_led_mode_t psu1_new_mode; - onlp_psu_info_t psu2; - onlp_led_mode_t psu2_new_mode; - onlp_led_mode_t sys_new_mode; - /*fan led */ - rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &info1); - - rc1=onlp_fani_info_get(ONLP_FAN_ID_CREATE(2), &info2); - - if ((rc != ONLP_STATUS_OK)||(rc1 != ONLP_STATUS_OK)){ - fan_new_mode=ONLP_LED_MODE_RED; - goto temp_led; - } - if(((info1.status&0x3)==1)&&((info2.status&0x3)==1)) - fan_new_mode=ONLP_LED_MODE_GREEN; - else - fan_new_mode=ONLP_LED_MODE_RED; - -temp_led: - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode); - - /*temperature led */ - - rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti); - if (rc != ONLP_STATUS_OK) { - temp_new_mode=ONLP_LED_MODE_OFF; - goto psu1_led; - } - if(ti.mcelsius >= 75000) - temp_new_mode=ONLP_LED_MODE_RED; - else - temp_new_mode=ONLP_LED_MODE_GREEN; - -psu1_led: - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_TEMP),temp_new_mode); - - /*psu1 and psu2 led */ - rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(1),&psu1); - - if (rc != ONLP_STATUS_OK) { - psu1_new_mode=ONLP_LED_MODE_OFF; - goto psu2_led; - } - - if((psu1.status&0x1)&&!(psu1.status&0x2)) - psu1_new_mode=ONLP_LED_MODE_GREEN; - else - psu1_new_mode=ONLP_LED_MODE_OFF; -psu2_led: - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1),psu1_new_mode); - //psu2 led ---------------- - rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(2),&psu2); - - if (rc != ONLP_STATUS_OK) { - psu2_new_mode=ONLP_LED_MODE_OFF; - goto sys_led; - } - - if((psu2.status&0x1)&&!(psu2.status&0x2)) - psu2_new_mode=ONLP_LED_MODE_GREEN; - else - psu2_new_mode=ONLP_LED_MODE_OFF; -sys_led : - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2),psu2_new_mode); - //sys led ---------------- - - if((fan_new_mode!=ONLP_LED_MODE_GREEN)||((psu2_new_mode!=ONLP_LED_MODE_GREEN)&& \ - (psu1_new_mode!=ONLP_LED_MODE_GREEN))) - sys_new_mode=ONLP_LED_MODE_RED_BLINKING; - else - sys_new_mode=ONLP_LED_MODE_GREEN; - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode); - - - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c deleted file mode 100755 index 807855c9..00000000 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include "arm_delta_ag6248c_log.h" -#include -#include "arm_delta_i2c.h" -#define prefix_path "/sys/bus/i2c/devices/" -#define LOCAL_DEBUG 0 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -enum onlp_thermal_id -{ - THERMAL_RESERVED = 0, - THERMAL_1_CLOSE_TO_MAC, - THERMAL_2_CLOSE_TO_PHY, - THERMAL_1_ON_PSU1, - THERMAL_1_ON_PSU2, -}; - -static char* last_path[] = /* must map with onlp_thermal_id */ -{ - "reserved", - "0-0049/temp1_input", - "0-004a/temp1_input", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_MAC), "Thermal Sensor 1- close to mac", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_CLOSE_TO_PHY), "Thermal Sensor 2- close to phy", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - } -}; -static int -_onlp_psu_thermali_val_to_temperature (int v,int mult) -{ - long X, Y, N, n; - Y = v & 0x07FF; - N = (v >> 11) & 0x0f; - n = v & 0x8000 ? 1 : 0; - if (n) - X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; - else - X = Y * mult * (N=(1<<(N&0xf))); - return X; -} -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -/* - * Retrieve the information structure for the given thermal OID. - * - * If the OID is invalid, return ONLP_E_STATUS_INVALID. - * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. - * Otherwise, return ONLP_STATUS_OK with the OID's information. - * - * Note -- it is expected that you fill out the information - * structure even if the sensor described by the OID is not present. - */ -static int -_onlp_thermali_info_get(int id, onlp_thermal_info_t* info) -{ - int len, nbytes = 10, temp_base=1, local_id; - uint8_t r_data[10] = {0}; - char fullpath[50] = {0}; - - local_id = 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]); - - onlp_file_read(r_data,nbytes,&len, fullpath); - - info->mcelsius =ONLPLIB_ATOI((char*)r_data) / temp_base; - - DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); - - return ONLP_STATUS_OK; -} - -static int -_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info) -{ - int psu_present,psu_good; - int psu_id,local_id; - int r_data,temperature_v; - enum ag6248c_product_id pid; - - local_id=id; - - DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); - - psu_id=(local_id-THERMAL_1_ON_PSU1)+1; - pid=get_product_id(); - //if the psu is not, directly to return - psu_present=psu_status_info_get(psu_id, "present"); - psu_good=psu_status_info_get(psu_id, "good"); - if((psu_present<=0)||(psu_good<=0)){ - info->status &= ~ONLP_THERMAL_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - //read the pus temperture register value - if(pid == PID_AG6248C_48){ - if(psu_id==1) - r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); - else - r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); - } - else{ - if(psu_id==1) - r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x8d); - else - r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x8d); - } - if(r_data<0) - return ONLP_STATUS_E_INVALID; - //get the real temperture value - temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000); - - info->mcelsius=temperature_v; - - DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); - - return ONLP_STATUS_OK; - -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) -{ - int rc; - int local_id; - - VALIDATE(id); - - local_id=ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; - - if((local_id==THERMAL_1_CLOSE_TO_MAC) || (local_id==THERMAL_2_CLOSE_TO_PHY)) - rc= _onlp_thermali_info_get(local_id,info); - else if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2)) - rc=_onlp_thermali_psu_info_get(local_id,info); - else{ - rc=ONLP_STATUS_E_INVALID; - } - return rc; -} - - - diff --git a/packages/platforms/delta/armel/modules/Makefile b/packages/platforms/delta/armel/modules/Makefile deleted file mode 100644 index 003238cf..00000000 --- a/packages/platforms/delta/armel/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/modules/PKG.yml b/packages/platforms/delta/armel/modules/PKG.yml deleted file mode 100644 index e73b86da..00000000 --- a/packages/platforms/delta/armel/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=armel VENDOR=delta diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore index 76483140..269535f7 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/.gitignore @@ -1,3 +1,2 @@ -*x86*64*delta_agc7648a*.mk +*x86*64*delta*ag5648*.mk onlpdump.mk - diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile index 26aa37e6..003238cf 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/Makefile @@ -1,2 +1 @@ -include $(ONL)/make/pkg.mk - +include $(ONL)/make/pkg.mk \ No newline at end of file From 2af7ab2cba819b33a5291c5446b86d89e755de6f Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 31 Dec 2017 16:00:39 +0000 Subject: [PATCH 106/244] Add target which builds the required packages (but no the rfs itself). --- make/rfs.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/make/rfs.mk b/make/rfs.mk index f137e411..c3741bae 100644 --- a/make/rfs.mk +++ b/make/rfs.mk @@ -44,3 +44,6 @@ clean: show-packages: $(ONL_V_at) $(RFS_COMMAND) --show-packages + +build-packages: + $(ONL_V_at) $(RFS_COMMAND) --only-build-packages From 6359a48a654aafacf48bc0813fe5be0f23036383 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 31 Dec 2017 17:15:14 +0000 Subject: [PATCH 107/244] Enhancements - All package build step only. - Evironmental option to skip package scans. --- tools/onlrfs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index 54f36ead..470d95aa 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -284,10 +284,11 @@ class OnlRfsBuilder(object): msconfig = self.ms.generate_file() # Optional local package updates - for r in self.ms.localrepos: - logger.info("Updating %s" % r) - if os.path.exists(os.path.join(r, 'Makefile')): - onlu.execute("make -C %s" % r) + if os.getenv("ONLRFS_NO_PACKAGE_SCAN") is None: + for r in self.ms.localrepos: + logger.info("Updating %s" % r) + if os.path.exists(os.path.join(r, 'Makefile')): + onlu.execute("make -C %s" % r) if os.path.exists(dir_): onlu.execute("sudo rm -rf %s" % dir_, @@ -545,6 +546,7 @@ if __name__ == '__main__': ap.add_argument("--dir") ap.add_argument("--show-packages", action='store_true') ap.add_argument("--no-build-packages", action='store_true') + ap.add_argument("--only-build-packages", action='store_true') ap.add_argument("--msconfig") ap.add_argument("--multistrap-only", action='store_true') ap.add_argument("--no-multistrap", action='store_true') @@ -572,7 +574,8 @@ if __name__ == '__main__': # Invoke onlpm to build all required (local) packages. onlu.execute("onlpm --try-arches %s all --skip-missing --require %s" % (ops.arch, " ".join(pkgs)), ex=OnlRfsError("Failed to build all required packages.")) - + if ops.only_build_packages: + sys.exit(0) if ops.multistrap_only: x.multistrap(ops.dir) From 050c0450ad458083acaf7480fad4bd029b99ca24 Mon Sep 17 00:00:00 2001 From: chenglin-tsai Date: Tue, 2 Jan 2018 11:03:35 +0800 Subject: [PATCH 108/244] Remove the not existing module. --- .../r0/src/python/x86_64_delta_agc5648s_r0/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py index 35e58a79..1cf43993 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/platform-config/r0/src/python/x86_64_delta_agc5648s_r0/__init__.py @@ -12,7 +12,5 @@ class OnlPlatform_x86_64_delta_agc5648s_r0(OnlPlatformDelta, # initiate eeprom self.new_i2c_device('24c02', 0x53, 0) - self.insmod('i2c-mei') - return True From 6405036e28165005456a45a6432e0e84827a8723 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Tue, 2 Jan 2018 16:42:03 -0800 Subject: [PATCH 109/244] Update README-proxy.md --- docs/README-proxy.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/README-proxy.md b/docs/README-proxy.md index f3e395de..4a1a7e55 100644 --- a/docs/README-proxy.md +++ b/docs/README-proxy.md @@ -6,12 +6,6 @@ build process dynamically pulls lots of things, this can be a pain. While everyone's setup is different, hopefully these directions help reduce that pain. - -* Update the git modules to point to http: instead of git: - - - sed -i -e 's/git:/http:/' $ONL/.gitmodules - * Make sure you have apt-cacher-ng installed in your host (non-docker) environment and that docker starts it. Next, configure it to use your proxy: From d580f334b70f54d98a7ed8be8b71d09853683e3a Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 3 Jan 2018 11:23:03 +0800 Subject: [PATCH 110/244] [as7716-32x] Add support for OOM driver --- .../builds/x86-64-accton-as7716-32x-cpld1.c | 558 ++++++ .../builds/x86-64-accton-as7716-32x-fan.c | 7 +- .../builds/x86-64-accton-as7716-32x-leds.c | 13 +- .../builds/x86-64-accton-as7716-32x-psu.c | 9 +- .../builds/x86-64-accton-as7716-32x-sfp.c | 1533 ----------------- .../onlp/builds/src/module/src/sfpi.c | 61 +- .../x86_64_accton_as7716_32x_r0/__init__.py | 105 +- 7 files changed, 645 insertions(+), 1641 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-cpld1.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-cpld1.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-cpld1.c new file mode 100644 index 00000000..ba33259e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-cpld1.c @@ -0,0 +1,558 @@ +/* + * A hwmon driver for the as7716_32x_cpld + * + * Copyright (C) 2013 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static ssize_t show_present(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7716_32x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7716_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +struct as7716_32x_cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/* Addresses scanned for as7716_32x_cpld + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index + +enum as7716_32x_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), +}; + +/* sysfs attributes for hwmon + */ + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_present, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); + +static struct attribute *as7716_32x_cpld_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_ATTR(1), + DECLARE_TRANSCEIVER_ATTR(2), + DECLARE_TRANSCEIVER_ATTR(3), + DECLARE_TRANSCEIVER_ATTR(4), + DECLARE_TRANSCEIVER_ATTR(5), + DECLARE_TRANSCEIVER_ATTR(6), + DECLARE_TRANSCEIVER_ATTR(7), + DECLARE_TRANSCEIVER_ATTR(8), + DECLARE_TRANSCEIVER_ATTR(9), + DECLARE_TRANSCEIVER_ATTR(10), + DECLARE_TRANSCEIVER_ATTR(11), + DECLARE_TRANSCEIVER_ATTR(12), + DECLARE_TRANSCEIVER_ATTR(13), + DECLARE_TRANSCEIVER_ATTR(14), + DECLARE_TRANSCEIVER_ATTR(15), + DECLARE_TRANSCEIVER_ATTR(16), + DECLARE_TRANSCEIVER_ATTR(17), + DECLARE_TRANSCEIVER_ATTR(18), + DECLARE_TRANSCEIVER_ATTR(19), + DECLARE_TRANSCEIVER_ATTR(20), + DECLARE_TRANSCEIVER_ATTR(21), + DECLARE_TRANSCEIVER_ATTR(22), + DECLARE_TRANSCEIVER_ATTR(23), + DECLARE_TRANSCEIVER_ATTR(24), + DECLARE_TRANSCEIVER_ATTR(25), + DECLARE_TRANSCEIVER_ATTR(26), + DECLARE_TRANSCEIVER_ATTR(27), + DECLARE_TRANSCEIVER_ATTR(28), + DECLARE_TRANSCEIVER_ATTR(29), + DECLARE_TRANSCEIVER_ATTR(30), + DECLARE_TRANSCEIVER_ATTR(31), + DECLARE_TRANSCEIVER_ATTR(32), + NULL +}; + +static const struct attribute_group as7716_32x_cpld_group = { + .attrs = as7716_32x_cpld_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x30, 0x31, 0x32, 0x33}; + struct i2c_client *client = to_i2c_client(dev); + struct as7716_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7716_32x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_present(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 as7716_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x31; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x33; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + default: + return 0; + } + + + mutex_lock(&data->update_lock); + status = as7716_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 reg = 0, mask = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7716_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + + switch (attr->index) { + case CPLD_VERSION: + reg = 0x1; + mask = 0xFF; + break; + default: + break; + } + + mutex_lock(&data->update_lock); + status = as7716_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%d\n", (status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7716_32x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7716_32x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static int as7716_32x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7716_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static void as7716_32x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7716_32x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static int as7716_32x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int status; + struct as7716_32x_cpld_data *data = NULL; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7716_32x_cpld_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7716_32x_cpld_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + as7716_32x_cpld_add_client(client); + + dev_info(&client->dev, "%s: cpld '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7716_32x_cpld_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7716_32x_cpld_remove(struct i2c_client *client) +{ + struct as7716_32x_cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7716_32x_cpld_group); + kfree(data); + as7716_32x_cpld_remove_client(client); + + return 0; +} + +int as7716_32x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7716_32x_cpld_read); + +int as7716_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7716_32x_cpld_write); + +static const struct i2c_device_id as7716_32x_cpld_id[] = { + { "as7716_32x_cpld1", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7716_32x_cpld_id); + +static struct i2c_driver as7716_32x_cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7716_32x_cpld1", + }, + .probe = as7716_32x_cpld_probe, + .remove = as7716_32x_cpld_remove, + .id_table = as7716_32x_cpld_id, + .address_list = normal_i2c, +}; + +static int __init as7716_32x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7716_32x_cpld_driver); +} + +static void __exit as7716_32x_cpld_exit(void) +{ + i2c_del_driver(&as7716_32x_cpld_driver); +} + +module_init(as7716_32x_cpld_init); +module_exit(as7716_32x_cpld_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7716_32x_cpld driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-fan.c index 08b02c35..e85831f8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-fan.c @@ -469,12 +469,7 @@ static struct i2c_driver as7716_32x_fan_driver = { static int __init as7716_32x_fan_init(void) { - extern int platform_accton_as7716_32x(void); - if (!platform_accton_as7716_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7716_32x_fan_driver); + return i2c_add_driver(&as7716_32x_fan_driver); } static void __exit as7716_32x_fan_exit(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-leds.c index 5a848972..a3b23e69 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-leds.c @@ -30,8 +30,8 @@ #include #include -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as7716_32x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7716_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -175,12 +175,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as7716_32x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as7716_32x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as7716_32x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as7716_32x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as7716_32x_led_update(void) @@ -397,11 +397,6 @@ static int __init accton_as7716_32x_led_init(void) { int ret; - extern int platform_accton_as7716_32x(void); - if (!platform_accton_as7716_32x()) { - return -ENODEV; - } - ret = platform_driver_register(&accton_as7716_32x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-psu.c index 79e36a9a..b9bd6278 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-psu.c @@ -42,7 +42,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); static int as7716_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as7716_32x_cpld_read (unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -314,7 +314,7 @@ static struct as7716_32x_psu_data *as7716_32x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as7716_32x update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as7716_32x_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); @@ -362,11 +362,6 @@ exit: static int __init as7716_32x_psu_init(void) { - extern int platform_accton_as7716_32x(void); - if (!platform_accton_as7716_32x()) { - return -ENODEV; - } - return i2c_add_driver(&as7716_32x_psu_driver); } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c deleted file mode 100644 index e4926c1f..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/modules/builds/x86-64-accton-as7716-32x-sfp.c +++ /dev/null @@ -1,1533 +0,0 @@ -/* - * SFP driver for accton as7716 sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as7716_32x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 32 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as7716_32x_port1, as7716_32x_port2, as7716_32x_port3, as7716_32x_port4, as7716_32x_port5, as7716_32x_port6, as7716_32x_port7, as7716_32x_port8, -as7716_32x_port9, as7716_32x_port10, as7716_32x_port11, as7716_32x_port12, as7716_32x_port13, as7716_32x_port14, as7716_32x_port15, as7716_32x_port16, -as7716_32x_port17, as7716_32x_port18, as7716_32x_port19, as7716_32x_port20, as7716_32x_port21, as7716_32x_port22, as7716_32x_port23, as7716_32x_port24, -as7716_32x_port25, as7716_32x_port26, as7716_32x_port27, as7716_32x_port28, as7716_32x_port29, as7716_32x_port30, as7716_32x_port31, as7716_32x_port32 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7716_32x_port1), -I2C_DEV_ID(as7716_32x_port2), -I2C_DEV_ID(as7716_32x_port3), -I2C_DEV_ID(as7716_32x_port4), -I2C_DEV_ID(as7716_32x_port5), -I2C_DEV_ID(as7716_32x_port6), -I2C_DEV_ID(as7716_32x_port7), -I2C_DEV_ID(as7716_32x_port8), -I2C_DEV_ID(as7716_32x_port9), -I2C_DEV_ID(as7716_32x_port10), -I2C_DEV_ID(as7716_32x_port11), -I2C_DEV_ID(as7716_32x_port12), -I2C_DEV_ID(as7716_32x_port13), -I2C_DEV_ID(as7716_32x_port14), -I2C_DEV_ID(as7716_32x_port15), -I2C_DEV_ID(as7716_32x_port16), -I2C_DEV_ID(as7716_32x_port17), -I2C_DEV_ID(as7716_32x_port18), -I2C_DEV_ID(as7716_32x_port19), -I2C_DEV_ID(as7716_32x_port20), -I2C_DEV_ID(as7716_32x_port21), -I2C_DEV_ID(as7716_32x_port22), -I2C_DEV_ID(as7716_32x_port23), -I2C_DEV_ID(as7716_32x_port24), -I2C_DEV_ID(as7716_32x_port25), -I2C_DEV_ID(as7716_32x_port26), -I2C_DEV_ID(as7716_32x_port27), -I2C_DEV_ID(as7716_32x_port28), -I2C_DEV_ID(as7716_32x_port29), -I2C_DEV_ID(as7716_32x_port30), -I2C_DEV_ID(as7716_32x_port31), -I2C_DEV_ID(as7716_32x_port32), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0; - int status = -1; - u8 regs[] = {0x30, 0x31, 0x32, 0x33}; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 1~32 */ - data->present = 0; - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = accton_i2c_cpld_read(0x60, regs[i]); - - if (status < 0) { - DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); - data->present |= (u64)status << (i*8); - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[4] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as7716_32x_port1 || dev_id->driver_data > as7716_32x_port32) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - data->driver_type = DRIVER_TYPE_QSFP; - - ret = qsfp_probe(client, dev_id, &data->qsfp); - if (ret < 0) { - goto exit_kfree_buf; - } - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); -#if (MULTIPAGE_SUPPORT == 1) - kfree(data->writebuf); -#endif - - if (data->driver_type == DRIVER_TYPE_QSFP) { - ret = qsfp_remove(client, data->qsfp); - } - - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7716_32x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sfpi.c index b1fd2e53..49dc5e8c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/sfpi.c @@ -25,53 +25,24 @@ ***********************************************************/ #include -#include /* For O_RDWR && open */ -#include -#include -#include -#include - +#include +#include #include "platform_lib.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; - #define MUX_START_INDEX 25 #define NUM_OF_SFP_PORT 32 -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { +static const int port_bus_index[NUM_OF_SFP_PORT] = { 4, 5, 6, 7, 9, 8, 11, 10, 0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31, 20, 21, 22, 23, 24, 25, 26, 27 }; -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]+MUX_START_INDEX) +#define PORT_BUS_INDEX(port) (port_bus_index[port]+MUX_START_INDEX) +#define PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" -static int -as7512_32x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8]; - *value = 0; - - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as7512_32x_sfp_get_port_path(int port, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", - FRONT_PORT_TO_MUX_INDEX(port), - node_name); - - return sfp_node_path; -} +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/11-0060/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/11-0060/module_present_all" /************************************************************ * @@ -110,9 +81,8 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as7512_32x_sfp_get_port_path(port, "sfp_is_present"); - if (as7512_32x_sfp_node_read_int(path, &present, 0) != 0) { + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -124,11 +94,9 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; - char* path; FILE* fp; - path = as7512_32x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); @@ -164,26 +132,19 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_OK; } -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - return ONLP_STATUS_OK; -} - int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + if(onlp_file_read(data, 256, &size, PORT_FORMAT, PORT_BUS_INDEX(port), "eeprom") != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py index ae270587..9ba0f66d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/platform-config/r0/src/python/x86_64_accton_as7716_32x_r0/__init__.py @@ -8,10 +8,11 @@ class OnlPlatform_x86_64_accton_as7716_32x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".7716.32" def baseconfig(self): - - self.insmod("ym2651y") + self.insmod('optoe') + self.insmod('ym2651y') self.insmod('accton_i2c_cpld') - self.insmod_platform() + for m in [ 'fan', 'cpld1', 'psu', 'leds' ]: + self.insmod("x86-64-accton-as7716-32x-%s.ko" % m) ########### initialize I2C bus 0 ########### self.new_i2c_devices([ @@ -30,7 +31,7 @@ class OnlPlatform_x86_64_accton_as7716_32x_r0(OnlPlatformAccton, ('lm75', 0x4a, 10), #initiate CPLD - ('accton_i2c_cpld', 0x60, 11), + ('as7716_32x_cpld1', 0x60, 11), ('accton_i2c_cpld', 0x62, 12), ('accton_i2c_cpld', 0x64, 13), @@ -52,39 +53,71 @@ class OnlPlatform_x86_64_accton_as7716_32x_r0(OnlPlatformAccton, ('pca9548', 0x75, 2), # initialize QSFP port 1-32 - ('as7716_32x_port9', 0x50, 25), - ('as7716_32x_port10', 0x50, 26), - ('as7716_32x_port11', 0x50, 27), - ('as7716_32x_port12', 0x50, 28), - ('as7716_32x_port1', 0x50, 29), - ('as7716_32x_port2', 0x50, 30), - ('as7716_32x_port3', 0x50, 31), - ('as7716_32x_port4', 0x50, 32), - ('as7716_32x_port6', 0x50, 33), - ('as7716_32x_port5', 0x50, 34), - ('as7716_32x_port8', 0x50, 35), - ('as7716_32x_port7', 0x50, 36), - ('as7716_32x_port13', 0x50, 37), - ('as7716_32x_port14', 0x50, 38), - ('as7716_32x_port15', 0x50, 39), - ('as7716_32x_port16', 0x50, 40), - ('as7716_32x_port17', 0x50, 41), - ('as7716_32x_port18', 0x50, 42), - ('as7716_32x_port19', 0x50, 43), - ('as7716_32x_port20', 0x50, 44), - ('as7716_32x_port25', 0x50, 45), - ('as7716_32x_port26', 0x50, 46), - ('as7716_32x_port27', 0x50, 47), - ('as7716_32x_port28', 0x50, 48), - ('as7716_32x_port29', 0x50, 49), - ('as7716_32x_port30', 0x50, 50), - ('as7716_32x_port31', 0x50, 51), - ('as7716_32x_port32', 0x50, 52), - ('as7716_32x_port21', 0x50, 53), - ('as7716_32x_port22', 0x50, 54), - ('as7716_32x_port23', 0x50, 55), - ('as7716_32x_port24', 0x50, 56), + ('optoe1', 0x50, 25), + ('optoe1', 0x50, 26), + ('optoe1', 0x50, 27), + ('optoe1', 0x50, 28), + ('optoe1', 0x50, 29), + ('optoe1', 0x50, 30), + ('optoe1', 0x50, 31), + ('optoe1', 0x50, 32), + ('optoe1', 0x50, 33), + ('optoe1', 0x50, 34), + ('optoe1', 0x50, 35), + ('optoe1', 0x50, 36), + ('optoe1', 0x50, 37), + ('optoe1', 0x50, 38), + ('optoe1', 0x50, 39), + ('optoe1', 0x50, 40), + ('optoe1', 0x50, 41), + ('optoe1', 0x50, 42), + ('optoe1', 0x50, 43), + ('optoe1', 0x50, 44), + ('optoe1', 0x50, 45), + ('optoe1', 0x50, 46), + ('optoe1', 0x50, 47), + ('optoe1', 0x50, 48), + ('optoe1', 0x50, 49), + ('optoe1', 0x50, 50), + ('optoe1', 0x50, 51), + ('optoe1', 0x50, 52), + ('optoe1', 0x50, 53), + ('optoe1', 0x50, 54), + ('optoe1', 0x50, 55), + ('optoe1', 0x50, 56), ('24c02', 0x56, 0), ]) + subprocess.call('echo port9 > /sys/bus/i2c/devices/25-0050/port_name', shell=True) + subprocess.call('echo port10 > /sys/bus/i2c/devices/26-0050/port_name', shell=True) + subprocess.call('echo port11 > /sys/bus/i2c/devices/27-0050/port_name', shell=True) + subprocess.call('echo port12 > /sys/bus/i2c/devices/28-0050/port_name', shell=True) + subprocess.call('echo port1 > /sys/bus/i2c/devices/29-0050/port_name', shell=True) + subprocess.call('echo port2 > /sys/bus/i2c/devices/30-0050/port_name', shell=True) + subprocess.call('echo port3 > /sys/bus/i2c/devices/31-0050/port_name', shell=True) + subprocess.call('echo port4 > /sys/bus/i2c/devices/32-0050/port_name', shell=True) + subprocess.call('echo port6 > /sys/bus/i2c/devices/33-0050/port_name', shell=True) + subprocess.call('echo port5 > /sys/bus/i2c/devices/34-0050/port_name', shell=True) + subprocess.call('echo port8 > /sys/bus/i2c/devices/35-0050/port_name', shell=True) + subprocess.call('echo port7 > /sys/bus/i2c/devices/36-0050/port_name', shell=True) + subprocess.call('echo port13 > /sys/bus/i2c/devices/37-0050/port_name', shell=True) + subprocess.call('echo port14 > /sys/bus/i2c/devices/38-0050/port_name', shell=True) + subprocess.call('echo port15 > /sys/bus/i2c/devices/39-0050/port_name', shell=True) + subprocess.call('echo port16 > /sys/bus/i2c/devices/40-0050/port_name', shell=True) + subprocess.call('echo port17 > /sys/bus/i2c/devices/41-0050/port_name', shell=True) + subprocess.call('echo port18 > /sys/bus/i2c/devices/42-0050/port_name', shell=True) + subprocess.call('echo port19 > /sys/bus/i2c/devices/43-0050/port_name', shell=True) + subprocess.call('echo port20 > /sys/bus/i2c/devices/44-0050/port_name', shell=True) + subprocess.call('echo port25 > /sys/bus/i2c/devices/45-0050/port_name', shell=True) + subprocess.call('echo port26 > /sys/bus/i2c/devices/46-0050/port_name', shell=True) + subprocess.call('echo port27 > /sys/bus/i2c/devices/47-0050/port_name', shell=True) + subprocess.call('echo port28 > /sys/bus/i2c/devices/48-0050/port_name', shell=True) + subprocess.call('echo port29 > /sys/bus/i2c/devices/49-0050/port_name', shell=True) + subprocess.call('echo port30 > /sys/bus/i2c/devices/50-0050/port_name', shell=True) + subprocess.call('echo port31 > /sys/bus/i2c/devices/51-0050/port_name', shell=True) + subprocess.call('echo port32 > /sys/bus/i2c/devices/52-0050/port_name', shell=True) + subprocess.call('echo port21 > /sys/bus/i2c/devices/53-0050/port_name', shell=True) + subprocess.call('echo port22 > /sys/bus/i2c/devices/54-0050/port_name', shell=True) + subprocess.call('echo port23 > /sys/bus/i2c/devices/55-0050/port_name', shell=True) + subprocess.call('echo port24 > /sys/bus/i2c/devices/56-0050/port_name', shell=True) return True From 6aadd03984d505e8403f99ff44efe50f92e8ac16 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 3 Jan 2018 16:34:27 -0800 Subject: [PATCH 111/244] Clean up platform detection - export /etc/machine.conf settings to installer.conf - better handling of machine.conf bits during onie chroots (debug) --- builds/any/installer/installer.sh.in | 10 +++++ .../vendor-config-onl/src/lib/install/lib.sh | 4 +- .../src/python/onl/install/App.py | 31 ++++++++++++---- .../src/python/onl/install/ConfUtils.py | 18 +++++++-- .../src/python/onl/install/SystemInstall.py | 14 +++++-- .../src/python/onl/platform/base.py | 5 ++- .../src/python/onl/platform/current.py | 37 ++++++++++++++----- 7 files changed, 93 insertions(+), 26 deletions(-) diff --git a/builds/any/installer/installer.sh.in b/builds/any/installer/installer.sh.in index 6711709d..c66ccbe4 100644 --- a/builds/any/installer/installer.sh.in +++ b/builds/any/installer/installer.sh.in @@ -149,6 +149,11 @@ if test "$onie_platform"; then else onie_platform=$(onie-sysinfo -p 2>/dev/null) || : fi +if test "$onie_arch"; then + : +else + onie_arch=$(onie-sysinfo -c 2>/dev/null) || : +fi if test "$onie_platform"; then : elif test -r /etc/machine.conf; then @@ -479,6 +484,11 @@ mkdir -p "${rootdir}/etc/onl" cp /dev/null "${rootdir}/etc/onl/installer.conf" echo "onl_version=\"$onl_version\"" >> "${rootdir}/etc/onl/installer.conf" +# pass in the platform identifier, otherwise encoded in +# machine-XXX.conf and onie-sysinfo +echo "onie_platform=$onie_platform" >> "${rootdir}/etc/onl/installer.conf" +echo "onie_arch=$onie_arch" >> "${rootdir}/etc/onl/installer.conf" + # Generate the MD5 signature for ourselves for future reference. installer_md5=$(md5sum "$0" | awk '{print $1}') echo "installer_md5=\"$installer_md5\"" >> "${rootdir}/etc/onl/installer.conf" diff --git a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh index 3835580f..d684cf15 100644 --- a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh +++ b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh @@ -123,9 +123,7 @@ installer_mkchroot() { fi # export ONIE defines to the installer, if they exist - if test -r /etc/machine.conf; then - cp /etc/machine.conf "${rootdir}/etc/machine.conf" - fi + cp /etc/machine*.conf "${rootdir}/etc/." # export ONL defines to the installer mkdir -p "${rootdir}/etc/onl" diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py index 13465b90..8d149bcc 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py @@ -250,21 +250,38 @@ class App(SubprocessMixin, object): def findPlatform(self): plat = arch = None - if self.machineConf is not None: + + def _p2a(plat): + if plat.startswith('x86-64'): + return 'x86_64' + else: + return plat.partition('-')[0] + + # recover platform specifier from installer configuration + if plat is None: + plat = getattr(self.installerConf, 'onie_platform', None) + if plat: + self.log.info("ONL installer running chrooted.") + plat = plat.replace('_', '-').replace('.', '-') + arch = getattr(self.installerConf, 'onie_arch', None) + + # recover platform specifier from legacy ONIE machine.conf + if plat is None and self.machineConf is not None: plat = getattr(self.machineConf, 'onie_platform', None) arch = getattr(self.machineConf, 'onie_arch', None) - if plat and arch: + if plat: self.log.info("ONL installer running under ONIE.") plat = plat.replace('_', '-').replace('.', '-') - elif os.path.exists("/etc/onl/platform"): + + # recover platform specifier from ONL runtime + if plat is None and os.path.exists("/etc/onl/platform"): with open("/etc/onl/platform") as fd: plat = fd.read().strip() - if plat.startswith('x86-64'): - arch = 'x86_64' - else: - arch = plat.partition('-')[0] self.log.info("ONL installer running under ONL or ONL loader.") + if plat is not None and arch is None: + arch = _p2a(plat) + if plat and arch: self.installerConf.installer_platform = plat self.installerConf.installer_arch = arch diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py index 3e63541b..5b3e1f51 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py @@ -63,18 +63,30 @@ class ConfFileBase(ConfBase): PATH = None # Override me - def __init__(self, path=None): + SHELL = False + # override me + + def __init__(self, path=None, shell=False): self.__dict__['path'] = path or self.PATH + self.__dict__['shell'] = shell or self.SHELL ConfBase.__init__(self) def _parse(self): self.__dict__['_data'] = {} - with open(self.path) as fd: - for line in fd.xreadlines(): + if self.SHELL: + cmd = "IFS=; set -e; . '%s'; set +e; set | egrep ^[a-zA-Z][a-zA-Z0-9_]*=" % self.path + buf = subprocess.check_output(cmd, shell=True) + for line in buf.splitlines(False): self._feedLine(line) + else: + with open(self.path) as fd: + for line in fd.xreadlines(): + self._feedLine(line) class MachineConf(ConfFileBase): + """XXX roth -- deprecated, machine.conf is executable shell now.""" PATH = "/etc/machine.conf" + SHELL = True class InstallerConf(ConfFileBase): PATH = "/etc/onl/installer.conf" diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py index 09348f52..56e520da 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -12,6 +12,7 @@ import shutil import argparse import fnmatch import subprocess +import glob from onl.install.InstallUtils import InitrdContext from onl.install.InstallUtils import ProcMountsParser @@ -58,9 +59,9 @@ class App(SubprocessMixin): self.log.info("onie directory is %s", octx.onieDir) self.log.info("initrd directory is %s", octx.initrdDir) - src = os.path.join(octx.initrdDir, "etc/machine.conf") - dst = os.path.join(ctx.dir, "etc/machine.conf") - if os.path.exists(src): + srcPat = os.path.join(octx.initrdDir, "etc/machine*.conf") + for src in glob.glob(srcPat): + dst = os.path.join(ctx.dir, "etc", os.path.split(src)[1]) self.log.debug("+ /bin/cp %s %s", src, dst) shutil.copy2(src, dst) @@ -99,6 +100,13 @@ class App(SubprocessMixin): pass installerConf.installer_zip = os.path.split(zipPath)[1] + import onl.platform.current + plat = onl.platform.current.OnlPlatformName + if plat.startswith('x86-64'): + plat = 'x86_64' + plat[6:] + installerConf.onie_platform = plat + installerConf.onie_arch = plat.partition('-')[0] + # finalize the local installer.conf dst = os.path.join(ctx.dir, "etc/onl/installer.conf") with open(dst, "w") as fd: diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index 170f1eac..b0849cf8 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -17,6 +17,7 @@ import yaml import onl.YamlUtils import subprocess import platform +import ast class OnlInfoObject(object): DEFAULT_INDENT=" " @@ -256,9 +257,11 @@ class OnlPlatformBase(object): mc = self.basedir_onl("etc/onie/machine.json") if not os.path.exists(mc): data = {} - mcconf = subprocess.check_output("""onie-shell -c "cat /etc/machine.conf" """, shell=True) + mcconf = subprocess.check_output("""onie-shell -c "IFS=; . /etc/machine.conf; set | egrep ^onie_.*=" """, shell=True) for entry in mcconf.split(): (k,e,v) = entry.partition('=') + if v and (v.startswith("'") or v.startswith('"')): + v = ast.literal_eval(v) if e: data[k] = v diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py index 36e9e457..57b3fd45 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py @@ -17,14 +17,27 @@ import os, sys import importlib import subprocess +import ast def platform_name_get(): # Determine the current platform name. platform = None - if os.path.exists("/etc/onl/platform"): + + # running ONL proper + if platform is None and os.path.exists("/etc/onl/platform"): with open("/etc/onl/platform", 'r') as f: platform=f.read().strip() - elif os.path.exists("/bin/onie-sysinfo"): + + # in the middle of an ONL install + if platform is None and os.path.exists("/etc/onl/installer.conf"): + with open("/etc/onl/installer.conf") as f: + lines = f.readlines(False) + lines = [x for x in lines if x.startswith('onie_platform')] + if lines: + platform = lines[0].partition('=')[2].strip() + + # running ONIE + if platform is None and os.path.exists("/bin/onie-sysinfo"): try: platform = subprocess.check_output(('/bin/onie-sysinfo', '-p',)).strip() except subprocess.CalledProcessError as what: @@ -32,7 +45,9 @@ def platform_name_get(): sys.stderr.write(">>> %s\n" % line) sys.stderr.write("onie-sysinfo failed with code %d\n" % what.returncode) platform = None - elif os.path.exists("/usr/bin/onie-shell"): + + # running ONL loader, with access to ONIE + if platform is None and os.path.exists("/usr/bin/onie-shell"): try: platform = subprocess.check_output(('/usr/bin/onie-shell', '-c', "onie-sysinfo -p",)).strip() except subprocess.CalledProcessError as what: @@ -40,12 +55,16 @@ def platform_name_get(): sys.stderr.write(">>> %s\n" % line) sys.stderr.write("onie-sysinfo (onie-shell) failed with code %d\n" % what.returncode) platform = None - elif os.path.exists("/etc/machine.conf"): - with open("/etc/machine.conf", 'r') as f: - lines = f.readlines(False) - lines = [x for x in lines if x.startswith('onie_platform=')] - if lines: - platform = lines[0].partition('=')[2].strip() + + # legacy ONIE environment (including parsable shell in machine.conf) + if platform is None and os.path.exists("/etc/machine.conf"): + cmd = "IFS=; . /tmp/machine.conf; set | egrep ^onie_platform=" + buf = subprocess.check_output(cmd) + if buf: + platform = buf.partition('=')[2].strip() + if platform.startswith('"') or platform.startswith("'"): + platform = ast.literal_eval(platform) + if platform is None: raise RuntimeError("cannot find a platform declaration") From 2f340beef7007c685ef83ddb75b8eb6ed1c0bb5c Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 4 Jan 2018 23:48:48 +0000 Subject: [PATCH 112/244] Update to 3.16-LTS to 3.16.52. --- packages/base/any/kernels/3.16-lts/kconfig.mk | 2 +- .../kernels/3.16-lts/patches/overlayfs.patch | 27 ------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/packages/base/any/kernels/3.16-lts/kconfig.mk b/packages/base/any/kernels/3.16-lts/kconfig.mk index ddd9b87e..0deb7b61 100644 --- a/packages/base/any/kernels/3.16-lts/kconfig.mk +++ b/packages/base/any/kernels/3.16-lts/kconfig.mk @@ -25,6 +25,6 @@ THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) K_MAJOR_VERSION := 3 K_PATCH_LEVEL := 16 -K_SUB_LEVEL := 39 +K_SUB_LEVEL := 52 K_SUFFIX := K_PATCH_DIR := $(THIS_DIR)/patches diff --git a/packages/base/any/kernels/3.16-lts/patches/overlayfs.patch b/packages/base/any/kernels/3.16-lts/patches/overlayfs.patch index 11f414c3..3d2d3f1b 100644 --- a/packages/base/any/kernels/3.16-lts/patches/overlayfs.patch +++ b/packages/base/any/kernels/3.16-lts/patches/overlayfs.patch @@ -350,19 +350,6 @@ diff -urpN a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c diff -urpN a/fs/ext4/namei.c b/fs/ext4/namei.c --- a/fs/ext4/namei.c 2016-11-20 01:17:41.000000000 +0000 +++ b/fs/ext4/namei.c 2016-12-21 21:06:34.010677297 +0000 -@@ -1849,10 +1849,10 @@ static int make_indexed_dir(handle_t *ha - - retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh); - if (retval) -- goto out_frames; -+ goto out_frames; - retval = ext4_handle_dirty_dirent_node(handle, dir, bh); - if (retval) -- goto out_frames; -+ goto out_frames; - - de = do_split(handle,dir, &bh, frame, &hinfo); - if (IS_ERR(de)) { @@ -2905,7 +2905,7 @@ retry: * for transaction commit if we are running out of space * and thus we deadlock. So we have to stop transaction now @@ -4075,20 +4062,6 @@ diff -urpN a/include/linux/fs.h b/include/linux/fs.h * * @AOP_TRUNCATED_PAGE: The AOP method that was handed a locked page has * unlocked it and the page might have been truncated. -@@ -806,10 +826,10 @@ static inline struct file *get_file(stru - - #define MAX_NON_LFS ((1UL<<31) - 1) - --/* Page cache limit. The filesystems should put that into their s_maxbytes -- limits, otherwise bad things can happen in VM. */ -+/* Page cache limit. The filesystems should put that into their s_maxbytes -+ limits, otherwise bad things can happen in VM. */ - #if BITS_PER_LONG==32 --#define MAX_LFS_FILESIZE (((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) -+#define MAX_LFS_FILESIZE (((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) - #elif BITS_PER_LONG==64 - #define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL) - #endif @@ -1401,6 +1421,7 @@ extern int vfs_link(struct dentry *, str extern int vfs_rmdir(struct inode *, struct dentry *); extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); From 1132af8a9288eea04cc9acd903973823a2fc3896 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 5 Jan 2018 00:26:15 +0000 Subject: [PATCH 113/244] Allow for changing sub levels. --- .../amd64/kernels/kernel-3.16-lts-x86-64-all/builds/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/amd64/kernels/kernel-3.16-lts-x86-64-all/builds/Makefile b/packages/base/amd64/kernels/kernel-3.16-lts-x86-64-all/builds/Makefile index 54cb65cb..a01c2479 100644 --- a/packages/base/amd64/kernels/kernel-3.16-lts-x86-64-all/builds/Makefile +++ b/packages/base/amd64/kernels/kernel-3.16-lts-x86-64-all/builds/Makefile @@ -15,7 +15,7 @@ include $(ONL)/make/config.mk kernel: rm -rf lib $(MAKE) -C $(ONL)/packages/base/any/kernels/3.16-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL) - ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-3.16.39-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common + ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-3.16.*-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common clean: rm -rf linux-3.16* kernel-3.16* From 78d303832a6162c598f8e9d041292b9ee5fafe45 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 5 Jan 2018 00:27:19 +0000 Subject: [PATCH 114/244] Update 4.9-LTS to 4.9.74. --- .../amd64/kernels/kernel-4.9-lts-x86-64-all/builds/Makefile | 2 +- .../any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config | 5 +++-- packages/base/any/kernels/4.9-lts/kconfig.mk | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/base/amd64/kernels/kernel-4.9-lts-x86-64-all/builds/Makefile b/packages/base/amd64/kernels/kernel-4.9-lts-x86-64-all/builds/Makefile index 422af6c5..7ce691aa 100644 --- a/packages/base/amd64/kernels/kernel-4.9-lts-x86-64-all/builds/Makefile +++ b/packages/base/amd64/kernels/kernel-4.9-lts-x86-64-all/builds/Makefile @@ -15,7 +15,7 @@ include $(ONL)/make/config.mk kernel: rm -rf lib $(MAKE) -C $(ONL)/packages/base/any/kernels/4.9-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL) - ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-4.9.30-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common + ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-4.9.*-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common clean: rm -rf linux-4.9* kernel-4.9* diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index f475b11d..10162036 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 4.9.30 Kernel Configuration +# Linux/x86_64 4.9.74 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -759,7 +759,6 @@ CONFIG_IA32_EMULATION=y CONFIG_COMPAT=y CONFIG_COMPAT_FOR_U64_ALIGNMENT=y CONFIG_SYSVIPC_COMPAT=y -CONFIG_KEYS_COMPAT=y CONFIG_X86_DEV_DMA_OPS=y CONFIG_PMC_ATOM=y CONFIG_NET=y @@ -959,6 +958,7 @@ CONFIG_IP6_NF_MANGLE=y # CONFIG_L2TP is not set # CONFIG_BRIDGE is not set CONFIG_HAVE_NET_DSA=y +# CONFIG_NET_DSA is not set # CONFIG_VLAN_8021Q is not set # CONFIG_DECNET is not set # CONFIG_LLC2 is not set @@ -4214,6 +4214,7 @@ CONFIG_X86_DEBUG_FPU=y # Security options # CONFIG_KEYS=y +CONFIG_KEYS_COMPAT=y # CONFIG_PERSISTENT_KEYRINGS is not set # CONFIG_BIG_KEYS is not set # CONFIG_ENCRYPTED_KEYS is not set diff --git a/packages/base/any/kernels/4.9-lts/kconfig.mk b/packages/base/any/kernels/4.9-lts/kconfig.mk index a653d2c9..08982e1b 100644 --- a/packages/base/any/kernels/4.9-lts/kconfig.mk +++ b/packages/base/any/kernels/4.9-lts/kconfig.mk @@ -25,6 +25,6 @@ THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) K_MAJOR_VERSION := 4 K_PATCH_LEVEL := 9 -K_SUB_LEVEL := 30 +K_SUB_LEVEL := 74 K_SUFFIX := K_PATCH_DIR := $(THIS_DIR)/patches From b9611cfe0dea1b5ec0327ed2d7d8d28bfd6ff2e7 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Fri, 5 Jan 2018 10:26:36 +0800 Subject: [PATCH 115/244] [as7816-64x] Add support for OOM driver --- .../builds/x86-64-accton-as7816-64x-cpld1.c | 670 +++++++ .../builds/x86-64-accton-as7816-64x-leds.c | 8 +- .../builds/x86-64-accton-as7816-64x-psu.c | 4 +- .../builds/x86-64-accton-as7816-64x-sfp.c | 1576 ----------------- .../onlp/builds/src/module/src/sfpi.c | 45 +- .../x86_64_accton_as7816_64x_r0/__init__.py | 203 ++- 6 files changed, 839 insertions(+), 1667 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c new file mode 100644 index 00000000..1dcd3395 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c @@ -0,0 +1,670 @@ +/* + * A hwmon driver for the as7816_64x_cpld + * + * Copyright (C) 2018 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static ssize_t show_present(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7816_64x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7816_64x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +struct as7816_64x_cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/* Addresses scanned for as7816_64x_cpld + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index + +enum as7816_64x_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_PRESENT_ATTR_ID(55), + TRANSCEIVER_PRESENT_ATTR_ID(56), + TRANSCEIVER_PRESENT_ATTR_ID(57), + TRANSCEIVER_PRESENT_ATTR_ID(58), + TRANSCEIVER_PRESENT_ATTR_ID(59), + TRANSCEIVER_PRESENT_ATTR_ID(60), + TRANSCEIVER_PRESENT_ATTR_ID(61), + TRANSCEIVER_PRESENT_ATTR_ID(62), + TRANSCEIVER_PRESENT_ATTR_ID(63), + TRANSCEIVER_PRESENT_ATTR_ID(64), +}; + +/* sysfs attributes for hwmon + */ + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_present, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(54); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(55); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(56); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(57); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(58); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(59); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(60); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(61); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(62); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(63); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(64); + +static struct attribute *as7816_64x_cpld_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_ATTR(1), + DECLARE_TRANSCEIVER_ATTR(2), + DECLARE_TRANSCEIVER_ATTR(3), + DECLARE_TRANSCEIVER_ATTR(4), + DECLARE_TRANSCEIVER_ATTR(5), + DECLARE_TRANSCEIVER_ATTR(6), + DECLARE_TRANSCEIVER_ATTR(7), + DECLARE_TRANSCEIVER_ATTR(8), + DECLARE_TRANSCEIVER_ATTR(9), + DECLARE_TRANSCEIVER_ATTR(10), + DECLARE_TRANSCEIVER_ATTR(11), + DECLARE_TRANSCEIVER_ATTR(12), + DECLARE_TRANSCEIVER_ATTR(13), + DECLARE_TRANSCEIVER_ATTR(14), + DECLARE_TRANSCEIVER_ATTR(15), + DECLARE_TRANSCEIVER_ATTR(16), + DECLARE_TRANSCEIVER_ATTR(17), + DECLARE_TRANSCEIVER_ATTR(18), + DECLARE_TRANSCEIVER_ATTR(19), + DECLARE_TRANSCEIVER_ATTR(20), + DECLARE_TRANSCEIVER_ATTR(21), + DECLARE_TRANSCEIVER_ATTR(22), + DECLARE_TRANSCEIVER_ATTR(23), + DECLARE_TRANSCEIVER_ATTR(24), + DECLARE_TRANSCEIVER_ATTR(25), + DECLARE_TRANSCEIVER_ATTR(26), + DECLARE_TRANSCEIVER_ATTR(27), + DECLARE_TRANSCEIVER_ATTR(28), + DECLARE_TRANSCEIVER_ATTR(29), + DECLARE_TRANSCEIVER_ATTR(30), + DECLARE_TRANSCEIVER_ATTR(31), + DECLARE_TRANSCEIVER_ATTR(32), + DECLARE_TRANSCEIVER_ATTR(33), + DECLARE_TRANSCEIVER_ATTR(34), + DECLARE_TRANSCEIVER_ATTR(35), + DECLARE_TRANSCEIVER_ATTR(36), + DECLARE_TRANSCEIVER_ATTR(37), + DECLARE_TRANSCEIVER_ATTR(38), + DECLARE_TRANSCEIVER_ATTR(39), + DECLARE_TRANSCEIVER_ATTR(40), + DECLARE_TRANSCEIVER_ATTR(41), + DECLARE_TRANSCEIVER_ATTR(42), + DECLARE_TRANSCEIVER_ATTR(43), + DECLARE_TRANSCEIVER_ATTR(44), + DECLARE_TRANSCEIVER_ATTR(45), + DECLARE_TRANSCEIVER_ATTR(46), + DECLARE_TRANSCEIVER_ATTR(47), + DECLARE_TRANSCEIVER_ATTR(48), + DECLARE_TRANSCEIVER_ATTR(49), + DECLARE_TRANSCEIVER_ATTR(50), + DECLARE_TRANSCEIVER_ATTR(51), + DECLARE_TRANSCEIVER_ATTR(52), + DECLARE_TRANSCEIVER_ATTR(53), + DECLARE_TRANSCEIVER_ATTR(54), + DECLARE_TRANSCEIVER_ATTR(55), + DECLARE_TRANSCEIVER_ATTR(56), + DECLARE_TRANSCEIVER_ATTR(57), + DECLARE_TRANSCEIVER_ATTR(58), + DECLARE_TRANSCEIVER_ATTR(59), + DECLARE_TRANSCEIVER_ATTR(60), + DECLARE_TRANSCEIVER_ATTR(61), + DECLARE_TRANSCEIVER_ATTR(62), + DECLARE_TRANSCEIVER_ATTR(63), + DECLARE_TRANSCEIVER_ATTR(64), + NULL +}; + +static const struct attribute_group as7816_64x_cpld_group = { + .attrs = as7816_64x_cpld_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[8] = {0}; + u8 regs[] = {0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77}; + struct i2c_client *client = to_i2c_client(dev); + struct as7816_64x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7816_64x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 64 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3], + values[4], values[5], values[6], values[7]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_present(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 as7816_64x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x70; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x71; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x72; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x73; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x74; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x75; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_56: + reg = 0x76; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_PRESENT_57 ... MODULE_PRESENT_64: + reg = 0x77; + mask = 0x1 << (attr->index - MODULE_PRESENT_57); + break; + default: + return 0; + } + + + mutex_lock(&data->update_lock); + status = as7816_64x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 reg = 0, mask = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7816_64x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + + switch (attr->index) { + case CPLD_VERSION: + reg = 0x1; + mask = 0xFF; + break; + default: + break; + } + + mutex_lock(&data->update_lock); + status = as7816_64x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%d\n", (status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7816_64x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7816_64x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static int as7816_64x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7816_64x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static void as7816_64x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7816_64x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static int as7816_64x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int status; + struct as7816_64x_cpld_data *data = NULL; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7816_64x_cpld_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7816_64x_cpld_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + as7816_64x_cpld_add_client(client); + + dev_info(&client->dev, "%s: cpld '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7816_64x_cpld_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7816_64x_cpld_remove(struct i2c_client *client) +{ + struct as7816_64x_cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7816_64x_cpld_group); + kfree(data); + as7816_64x_cpld_remove_client(client); + + return 0; +} + +int as7816_64x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7816_64x_cpld_read); + +int as7816_64x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7816_64x_cpld_write); + +static const struct i2c_device_id as7816_64x_cpld_id[] = { + { "as7816_64x_cpld1", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7816_64x_cpld_id); + +static struct i2c_driver as7816_64x_cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7816_64x_cpld1", + }, + .probe = as7816_64x_cpld_probe, + .remove = as7816_64x_cpld_remove, + .id_table = as7816_64x_cpld_id, + .address_list = normal_i2c, +}; + +static int __init as7816_64x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7816_64x_cpld_driver); +} + +static void __exit as7816_64x_cpld_exit(void) +{ + i2c_del_driver(&as7816_64x_cpld_driver); +} + +module_init(as7816_64x_cpld_init); +module_exit(as7816_64x_cpld_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7816_64x_cpld driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c index 3d1e7be6..c6cca629 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-leds.c @@ -30,8 +30,8 @@ #include #include -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as7816_64x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7816_64x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -185,12 +185,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int as7816_64x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as7816_64x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int as7816_64x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as7816_64x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void as7816_64x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c index c5bbd1ff..a2703aa9 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c @@ -42,7 +42,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static struct as7816_64x_psu_data *as7816_64x_psu_update_device(struct device *dev); -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7816_64x_cpld_read (unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -200,7 +200,7 @@ static struct as7816_64x_psu_data *as7816_64x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as7816_64x update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as7816_64x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c deleted file mode 100644 index 28047a46..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-sfp.c +++ /dev/null @@ -1,1576 +0,0 @@ -/* - * SFP driver for accton as7816_64x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as7816_64x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 24 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as7816_64x_port1, as7816_64x_port2, as7816_64x_port3, as7816_64x_port4, -as7816_64x_port5, as7816_64x_port6, as7816_64x_port7, as7816_64x_port8, -as7816_64x_port9, as7816_64x_port10, as7816_64x_port11, as7816_64x_port12, -as7816_64x_port13, as7816_64x_port14, as7816_64x_port15, as7816_64x_port16, -as7816_64x_port17, as7816_64x_port18, as7816_64x_port19, as7816_64x_port20, -as7816_64x_port21, as7816_64x_port22, as7816_64x_port23, as7816_64x_port24, -as7816_64x_port25, as7816_64x_port26, as7816_64x_port27, as7816_64x_port28, -as7816_64x_port29, as7816_64x_port30, as7816_64x_port31, as7816_64x_port32, -as7816_64x_port33, as7816_64x_port34, as7816_64x_port35, as7816_64x_port36, -as7816_64x_port37, as7816_64x_port38, as7816_64x_port39, as7816_64x_port40, -as7816_64x_port41, as7816_64x_port42, as7816_64x_port43, as7816_64x_port44, -as7816_64x_port45, as7816_64x_port46, as7816_64x_port47, as7816_64x_port48, -as7816_64x_port49, as7816_64x_port50, as7816_64x_port51, as7816_64x_port52, -as7816_64x_port53, as7816_64x_port54, as7816_64x_port55, as7816_64x_port56, -as7816_64x_port57, as7816_64x_port58, as7816_64x_port59, as7816_64x_port60, -as7816_64x_port61, as7816_64x_port62, as7816_64x_port63, as7816_64x_port64 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7816_64x_port1), -I2C_DEV_ID(as7816_64x_port2), -I2C_DEV_ID(as7816_64x_port3), -I2C_DEV_ID(as7816_64x_port4), -I2C_DEV_ID(as7816_64x_port5), -I2C_DEV_ID(as7816_64x_port6), -I2C_DEV_ID(as7816_64x_port7), -I2C_DEV_ID(as7816_64x_port8), -I2C_DEV_ID(as7816_64x_port9), -I2C_DEV_ID(as7816_64x_port10), -I2C_DEV_ID(as7816_64x_port11), -I2C_DEV_ID(as7816_64x_port12), -I2C_DEV_ID(as7816_64x_port13), -I2C_DEV_ID(as7816_64x_port14), -I2C_DEV_ID(as7816_64x_port15), -I2C_DEV_ID(as7816_64x_port16), -I2C_DEV_ID(as7816_64x_port17), -I2C_DEV_ID(as7816_64x_port18), -I2C_DEV_ID(as7816_64x_port19), -I2C_DEV_ID(as7816_64x_port20), -I2C_DEV_ID(as7816_64x_port21), -I2C_DEV_ID(as7816_64x_port22), -I2C_DEV_ID(as7816_64x_port23), -I2C_DEV_ID(as7816_64x_port24), -I2C_DEV_ID(as7816_64x_port25), -I2C_DEV_ID(as7816_64x_port26), -I2C_DEV_ID(as7816_64x_port27), -I2C_DEV_ID(as7816_64x_port28), -I2C_DEV_ID(as7816_64x_port29), -I2C_DEV_ID(as7816_64x_port30), -I2C_DEV_ID(as7816_64x_port31), -I2C_DEV_ID(as7816_64x_port32), -I2C_DEV_ID(as7816_64x_port33), -I2C_DEV_ID(as7816_64x_port34), -I2C_DEV_ID(as7816_64x_port35), -I2C_DEV_ID(as7816_64x_port36), -I2C_DEV_ID(as7816_64x_port37), -I2C_DEV_ID(as7816_64x_port38), -I2C_DEV_ID(as7816_64x_port39), -I2C_DEV_ID(as7816_64x_port40), -I2C_DEV_ID(as7816_64x_port41), -I2C_DEV_ID(as7816_64x_port42), -I2C_DEV_ID(as7816_64x_port43), -I2C_DEV_ID(as7816_64x_port44), -I2C_DEV_ID(as7816_64x_port45), -I2C_DEV_ID(as7816_64x_port46), -I2C_DEV_ID(as7816_64x_port47), -I2C_DEV_ID(as7816_64x_port48), -I2C_DEV_ID(as7816_64x_port49), -I2C_DEV_ID(as7816_64x_port50), -I2C_DEV_ID(as7816_64x_port51), -I2C_DEV_ID(as7816_64x_port52), -I2C_DEV_ID(as7816_64x_port53), -I2C_DEV_ID(as7816_64x_port54), -I2C_DEV_ID(as7816_64x_port55), -I2C_DEV_ID(as7816_64x_port56), -I2C_DEV_ID(as7816_64x_port57), -I2C_DEV_ID(as7816_64x_port58), -I2C_DEV_ID(as7816_64x_port59), -I2C_DEV_ID(as7816_64x_port60), -I2C_DEV_ID(as7816_64x_port61), -I2C_DEV_ID(as7816_64x_port62), -I2C_DEV_ID(as7816_64x_port63), -I2C_DEV_ID(as7816_64x_port64), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP, - DRIVER_TYPE_XFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0; - int status = -1; - u8 regs[] = {0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77}; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 1~64 */ - data->present = 0; - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = accton_i2c_cpld_read(0x60, regs[i]); - - if (status < 0) { - DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); - data->present |= (u64)status << (i*8); - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[8] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 64 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3], - values[4], values[5], values[6], values[7]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP || - port_data->driver_type == DRIVER_TYPE_XFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as7816_64x_port1 || dev_id->driver_data > as7816_64x_port64) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - data->driver_type = DRIVER_TYPE_QSFP; - - ret = qsfp_probe(client, dev_id, &data->qsfp); - if (ret < 0) { - goto exit_kfree_buf; - } - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - ret = qsfp_remove(client, data->qsfp); - } - - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7816_64x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c index 3b0fa4be..e2e72461 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/sfpi.c @@ -40,8 +40,11 @@ static const int port_bus_index[NUM_OF_SFP_PORT] = { 81, 82, 83, 84, 25, 26, 27, 28 }; -#define QSFP_BUS_INDEX(port) (port_bus_index[port]) -#define QSFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" +#define PORT_BUS_INDEX(port) (port_bus_index[port]) +#define PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" + +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/19-0060/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/19-0060/module_present_all" /************************************************************ * @@ -59,7 +62,7 @@ int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) { /* - * Ports {0, 16} + * Ports {0, 64} */ int p; AIM_BITMAP_CLR_ALL(bmap); @@ -80,7 +83,8 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - if (onlp_file_read_int(&present, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_is_present") < 0) { + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -92,11 +96,9 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[8]; - char path[64] = {0}; FILE* fp; - sprintf(path, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(0), "sfp_is_present_all"); - fp = fopen(path, "r"); + fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); @@ -114,7 +116,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) /* Convert to 64 bit integer in port order */ int i = 0; - uint32_t presence_all = 0 ; + uint64_t presence_all = 0 ; for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { presence_all <<= 8; presence_all |= bytes[i]; @@ -132,42 +134,51 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ int size = 0; - if(onlp_file_read(data, 256, &size, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { - if(size == 256) { - return ONLP_STATUS_OK; - } + if(onlp_file_read(data, 256, &size, PORT_FORMAT, PORT_BUS_INDEX(port), "eeprom") != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; } - return ONLP_STATUS_E_INTERNAL; + if(size != 256) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; } int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - int bus = QSFP_BUS_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - int bus = QSFP_BUS_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - int bus = QSFP_BUS_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) { - int bus = QSFP_BUS_INDEX(port); + int bus = PORT_BUS_INDEX(port); return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py index 67359750..0f79ec54 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py @@ -8,10 +8,11 @@ class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".7816.64" def baseconfig(self): - - self.insmod("ym2651y") + self.insmod('optoe') + self.insmod('ym2651y') self.insmod('accton_i2c_cpld') - self.insmod_platform() + for m in [ 'fan', 'cpld1', 'psu', 'leds' ]: + self.insmod("x86-64-accton-as7816-64x-%s.ko" % m) ########### initialize I2C bus 0 ########### self.new_i2c_devices([ @@ -43,7 +44,7 @@ class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton, ('lm75', 0x4e, 17), #initiate CPLD - ('accton_i2c_cpld', 0x60, 19), + ('as7816_64x_cpld1', 0x60, 19), ('accton_i2c_cpld', 0x62, 20), ('accton_i2c_cpld', 0x64, 21), ('accton_i2c_cpld', 0x66, 22), @@ -58,72 +59,138 @@ class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton, ('pca9548', 0x76, 2), # initialize QSFP port 1-64 - ('as7816_64x_port61', 0x50, 25), - ('as7816_64x_port62', 0x50, 26), - ('as7816_64x_port63', 0x50, 27), - ('as7816_64x_port64', 0x50, 28), - ('as7816_64x_port55', 0x50, 29), - ('as7816_64x_port56', 0x50, 30), - ('as7816_64x_port53', 0x50, 31), - ('as7816_64x_port54', 0x50, 32), - ('as7816_64x_port9', 0x50, 33), - ('as7816_64x_port10', 0x50, 34), - ('as7816_64x_port11', 0x50, 35), - ('as7816_64x_port12', 0x50, 36), - ('as7816_64x_port1', 0x50, 37), - ('as7816_64x_port2', 0x50, 38), - ('as7816_64x_port3', 0x50, 39), - ('as7816_64x_port4', 0x50, 40), - ('as7816_64x_port6', 0x50, 41), - ('as7816_64x_port5', 0x50, 42), - ('as7816_64x_port8', 0x50, 43), - ('as7816_64x_port7', 0x50, 44), - ('as7816_64x_port13', 0x50, 45), - ('as7816_64x_port14', 0x50, 46), - ('as7816_64x_port15', 0x50, 47), - ('as7816_64x_port16', 0x50, 48), - ('as7816_64x_port17', 0x50, 49), - ('as7816_64x_port18', 0x50, 50), - ('as7816_64x_port19', 0x50, 51), - ('as7816_64x_port20', 0x50, 52), - ('as7816_64x_port25', 0x50, 53), - ('as7816_64x_port26', 0x50, 54), - ('as7816_64x_port27', 0x50, 55), - ('as7816_64x_port28', 0x50, 56), - ('as7816_64x_port29', 0x50, 57), - ('as7816_64x_port30', 0x50, 58), - ('as7816_64x_port31', 0x50, 59), - ('as7816_64x_port32', 0x50, 60), - ('as7816_64x_port21', 0x50, 61), - ('as7816_64x_port22', 0x50, 62), - ('as7816_64x_port23', 0x50, 63), - ('as7816_64x_port24', 0x50, 64), - ('as7816_64x_port41', 0x50, 65), - ('as7816_64x_port42', 0x50, 66), - ('as7816_64x_port43', 0x50, 67), - ('as7816_64x_port44', 0x50, 68), - ('as7816_64x_port33', 0x50, 69), - ('as7816_64x_port34', 0x50, 70), - ('as7816_64x_port35', 0x50, 71), - ('as7816_64x_port36', 0x50, 72), - ('as7816_64x_port45', 0x50, 73), - ('as7816_64x_port46', 0x50, 74), - ('as7816_64x_port47', 0x50, 75), - ('as7816_64x_port48', 0x50, 76), - ('as7816_64x_port37', 0x50, 77), - ('as7816_64x_port38', 0x50, 78), - ('as7816_64x_port39', 0x50, 79), - ('as7816_64x_port40', 0x50, 80), - ('as7816_64x_port57', 0x50, 81), - ('as7816_64x_port58', 0x50, 82), - ('as7816_64x_port59', 0x50, 83), - ('as7816_64x_port60', 0x50, 84), - ('as7816_64x_port49', 0x50, 85), - ('as7816_64x_port50', 0x50, 86), - ('as7816_64x_port51', 0x50, 87), - ('as7816_64x_port52', 0x50, 88), + ('optoe1', 0x50, 25), + ('optoe1', 0x50, 26), + ('optoe1', 0x50, 27), + ('optoe1', 0x50, 28), + ('optoe1', 0x50, 29), + ('optoe1', 0x50, 30), + ('optoe1', 0x50, 31), + ('optoe1', 0x50, 32), + ('optoe1', 0x50, 33), + ('optoe1', 0x50, 34), + ('optoe1', 0x50, 35), + ('optoe1', 0x50, 36), + ('optoe1', 0x50, 37), + ('optoe1', 0x50, 38), + ('optoe1', 0x50, 39), + ('optoe1', 0x50, 40), + ('optoe1', 0x50, 41), + ('optoe1', 0x50, 42), + ('optoe1', 0x50, 43), + ('optoe1', 0x50, 44), + ('optoe1', 0x50, 45), + ('optoe1', 0x50, 46), + ('optoe1', 0x50, 47), + ('optoe1', 0x50, 48), + ('optoe1', 0x50, 49), + ('optoe1', 0x50, 50), + ('optoe1', 0x50, 51), + ('optoe1', 0x50, 52), + ('optoe1', 0x50, 53), + ('optoe1', 0x50, 54), + ('optoe1', 0x50, 55), + ('optoe1', 0x50, 56), + ('optoe1', 0x50, 57), + ('optoe1', 0x50, 58), + ('optoe1', 0x50, 59), + ('optoe1', 0x50, 60), + ('optoe1', 0x50, 61), + ('optoe1', 0x50, 62), + ('optoe1', 0x50, 63), + ('optoe1', 0x50, 64), + ('optoe1', 0x50, 65), + ('optoe1', 0x50, 66), + ('optoe1', 0x50, 67), + ('optoe1', 0x50, 68), + ('optoe1', 0x50, 69), + ('optoe1', 0x50, 70), + ('optoe1', 0x50, 71), + ('optoe1', 0x50, 72), + ('optoe1', 0x50, 73), + ('optoe1', 0x50, 74), + ('optoe1', 0x50, 75), + ('optoe1', 0x50, 76), + ('optoe1', 0x50, 77), + ('optoe1', 0x50, 78), + ('optoe1', 0x50, 79), + ('optoe1', 0x50, 80), + ('optoe1', 0x50, 81), + ('optoe1', 0x50, 82), + ('optoe1', 0x50, 83), + ('optoe1', 0x50, 84), + ('optoe1', 0x50, 85), + ('optoe1', 0x50, 86), + ('optoe1', 0x50, 87), + ('optoe1', 0x50, 88), ('24c02', 0x56, 0), ]) + subprocess.call('echo port61 > /sys/bus/i2c/devices/25-0050/port_name', shell=True) + subprocess.call('echo port62 > /sys/bus/i2c/devices/26-0050/port_name', shell=True) + subprocess.call('echo port63 > /sys/bus/i2c/devices/27-0050/port_name', shell=True) + subprocess.call('echo port64 > /sys/bus/i2c/devices/28-0050/port_name', shell=True) + subprocess.call('echo port55 > /sys/bus/i2c/devices/29-0050/port_name', shell=True) + subprocess.call('echo port56 > /sys/bus/i2c/devices/30-0050/port_name', shell=True) + subprocess.call('echo port53 > /sys/bus/i2c/devices/31-0050/port_name', shell=True) + subprocess.call('echo port54 > /sys/bus/i2c/devices/32-0050/port_name', shell=True) + subprocess.call('echo port9 > /sys/bus/i2c/devices/33-0050/port_name', shell=True) + subprocess.call('echo port10 > /sys/bus/i2c/devices/34-0050/port_name', shell=True) + subprocess.call('echo port11 > /sys/bus/i2c/devices/35-0050/port_name', shell=True) + subprocess.call('echo port12 > /sys/bus/i2c/devices/36-0050/port_name', shell=True) + subprocess.call('echo port1 > /sys/bus/i2c/devices/37-0050/port_name', shell=True) + subprocess.call('echo port2 > /sys/bus/i2c/devices/38-0050/port_name', shell=True) + subprocess.call('echo port3 > /sys/bus/i2c/devices/39-0050/port_name', shell=True) + subprocess.call('echo port4 > /sys/bus/i2c/devices/40-0050/port_name', shell=True) + subprocess.call('echo port6 > /sys/bus/i2c/devices/41-0050/port_name', shell=True) + subprocess.call('echo port5 > /sys/bus/i2c/devices/42-0050/port_name', shell=True) + subprocess.call('echo port8 > /sys/bus/i2c/devices/43-0050/port_name', shell=True) + subprocess.call('echo port7 > /sys/bus/i2c/devices/44-0050/port_name', shell=True) + subprocess.call('echo port13 > /sys/bus/i2c/devices/45-0050/port_name', shell=True) + subprocess.call('echo port14 > /sys/bus/i2c/devices/46-0050/port_name', shell=True) + subprocess.call('echo port15 > /sys/bus/i2c/devices/47-0050/port_name', shell=True) + subprocess.call('echo port16 > /sys/bus/i2c/devices/48-0050/port_name', shell=True) + subprocess.call('echo port17 > /sys/bus/i2c/devices/49-0050/port_name', shell=True) + subprocess.call('echo port18 > /sys/bus/i2c/devices/50-0050/port_name', shell=True) + subprocess.call('echo port19 > /sys/bus/i2c/devices/51-0050/port_name', shell=True) + subprocess.call('echo port20 > /sys/bus/i2c/devices/52-0050/port_name', shell=True) + subprocess.call('echo port25 > /sys/bus/i2c/devices/53-0050/port_name', shell=True) + subprocess.call('echo port26 > /sys/bus/i2c/devices/54-0050/port_name', shell=True) + subprocess.call('echo port27 > /sys/bus/i2c/devices/55-0050/port_name', shell=True) + subprocess.call('echo port28 > /sys/bus/i2c/devices/56-0050/port_name', shell=True) + + subprocess.call('echo port29 > /sys/bus/i2c/devices/57-0050/port_name', shell=True) + subprocess.call('echo port30 > /sys/bus/i2c/devices/58-0050/port_name', shell=True) + subprocess.call('echo port31 > /sys/bus/i2c/devices/59-0050/port_name', shell=True) + subprocess.call('echo port32 > /sys/bus/i2c/devices/60-0050/port_name', shell=True) + subprocess.call('echo port21 > /sys/bus/i2c/devices/61-0050/port_name', shell=True) + subprocess.call('echo port22 > /sys/bus/i2c/devices/62-0050/port_name', shell=True) + subprocess.call('echo port23 > /sys/bus/i2c/devices/63-0050/port_name', shell=True) + subprocess.call('echo port24 > /sys/bus/i2c/devices/64-0050/port_name', shell=True) + subprocess.call('echo port41 > /sys/bus/i2c/devices/65-0050/port_name', shell=True) + subprocess.call('echo port42 > /sys/bus/i2c/devices/66-0050/port_name', shell=True) + subprocess.call('echo port43 > /sys/bus/i2c/devices/67-0050/port_name', shell=True) + subprocess.call('echo port44 > /sys/bus/i2c/devices/68-0050/port_name', shell=True) + subprocess.call('echo port33 > /sys/bus/i2c/devices/69-0050/port_name', shell=True) + subprocess.call('echo port34 > /sys/bus/i2c/devices/70-0050/port_name', shell=True) + subprocess.call('echo port35 > /sys/bus/i2c/devices/71-0050/port_name', shell=True) + subprocess.call('echo port36 > /sys/bus/i2c/devices/72-0050/port_name', shell=True) + subprocess.call('echo port45 > /sys/bus/i2c/devices/73-0050/port_name', shell=True) + subprocess.call('echo port46 > /sys/bus/i2c/devices/74-0050/port_name', shell=True) + subprocess.call('echo port47 > /sys/bus/i2c/devices/75-0050/port_name', shell=True) + subprocess.call('echo port48 > /sys/bus/i2c/devices/76-0050/port_name', shell=True) + subprocess.call('echo port37 > /sys/bus/i2c/devices/77-0050/port_name', shell=True) + subprocess.call('echo port38 > /sys/bus/i2c/devices/78-0050/port_name', shell=True) + subprocess.call('echo port39 > /sys/bus/i2c/devices/79-0050/port_name', shell=True) + subprocess.call('echo port40 > /sys/bus/i2c/devices/80-0050/port_name', shell=True) + subprocess.call('echo port57 > /sys/bus/i2c/devices/81-0050/port_name', shell=True) + subprocess.call('echo port58 > /sys/bus/i2c/devices/82-0050/port_name', shell=True) + subprocess.call('echo port59 > /sys/bus/i2c/devices/83-0050/port_name', shell=True) + subprocess.call('echo port60 > /sys/bus/i2c/devices/84-0050/port_name', shell=True) + subprocess.call('echo port49 > /sys/bus/i2c/devices/85-0050/port_name', shell=True) + subprocess.call('echo port50 > /sys/bus/i2c/devices/86-0050/port_name', shell=True) + subprocess.call('echo port51 > /sys/bus/i2c/devices/87-0050/port_name', shell=True) + subprocess.call('echo port52 > /sys/bus/i2c/devices/88-0050/port_name', shell=True) + return True From 9d476e2207506e17143b9adf6327697ecfe8911c Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 9 Jan 2018 16:13:22 +0000 Subject: [PATCH 116/244] Upgrade to 3.16.53. --- .../configs/powerpc-e500v-all/powerpc-e500v-all.config | 3 +-- .../kernels/3.16-lts/configs/x86_64-all/x86_64-all.config | 5 +++-- packages/base/any/kernels/3.16-lts/kconfig.mk | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/base/any/kernels/3.16-lts/configs/powerpc-e500v-all/powerpc-e500v-all.config b/packages/base/any/kernels/3.16-lts/configs/powerpc-e500v-all/powerpc-e500v-all.config index 8c5c268d..2a9d8ae8 100644 --- a/packages/base/any/kernels/3.16-lts/configs/powerpc-e500v-all/powerpc-e500v-all.config +++ b/packages/base/any/kernels/3.16-lts/configs/powerpc-e500v-all/powerpc-e500v-all.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/powerpc 3.16.39 Kernel Configuration +# Linux/powerpc 3.16.53 Kernel Configuration # # CONFIG_PPC64 is not set @@ -732,7 +732,6 @@ CONFIG_VLAN_8021Q=y # CONFIG_BATMAN_ADV is not set # CONFIG_OPENVSWITCH is not set # CONFIG_VSOCKETS is not set -# CONFIG_NETLINK_MMAP is not set # CONFIG_NETLINK_DIAG is not set # CONFIG_NET_MPLS_GSO is not set # CONFIG_HSR is not set diff --git a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config index 109a7ccd..24d29cee 100644 --- a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86_64 3.16.39 Kernel Configuration +# Linux/x86_64 3.16.53 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -1054,7 +1054,6 @@ CONFIG_DNS_RESOLVER=y # CONFIG_BATMAN_ADV is not set # CONFIG_OPENVSWITCH is not set # CONFIG_VSOCKETS is not set -CONFIG_NETLINK_MMAP=y CONFIG_NETLINK_DIAG=y # CONFIG_NET_MPLS_GSO is not set # CONFIG_HSR is not set @@ -3412,6 +3411,7 @@ CONFIG_KEYS=y # CONFIG_KEYS_DEBUG_PROC_KEYS is not set # CONFIG_SECURITY_DMESG_RESTRICT is not set # CONFIG_SECURITY is not set +CONFIG_PAGE_TABLE_ISOLATION=y # CONFIG_SECURITYFS is not set CONFIG_DEFAULT_SECURITY_DAC=y CONFIG_DEFAULT_SECURITY="" @@ -3630,3 +3630,4 @@ CONFIG_AVERAGE=y CONFIG_CORDIC=y # CONFIG_DDR is not set CONFIG_OID_REGISTRY=y +CONFIG_UCS2_STRING=y diff --git a/packages/base/any/kernels/3.16-lts/kconfig.mk b/packages/base/any/kernels/3.16-lts/kconfig.mk index 0deb7b61..290135c9 100644 --- a/packages/base/any/kernels/3.16-lts/kconfig.mk +++ b/packages/base/any/kernels/3.16-lts/kconfig.mk @@ -25,6 +25,6 @@ THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) K_MAJOR_VERSION := 3 K_PATCH_LEVEL := 16 -K_SUB_LEVEL := 52 +K_SUB_LEVEL := 53 K_SUFFIX := K_PATCH_DIR := $(THIS_DIR)/patches From 3305efba3b40543046616f234604819b22197cd9 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 9 Jan 2018 16:18:45 +0000 Subject: [PATCH 117/244] Update the 4.9.75. --- .../any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config | 3 ++- packages/base/any/kernels/4.9-lts/kconfig.mk | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index 10162036..82636cbb 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86_64 4.9.74 Kernel Configuration +# Linux/x86_64 4.9.75 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -4221,6 +4221,7 @@ CONFIG_KEYS_COMPAT=y # CONFIG_KEY_DH_OPERATIONS is not set # CONFIG_SECURITY_DMESG_RESTRICT is not set CONFIG_SECURITY=y +CONFIG_PAGE_TABLE_ISOLATION=y # CONFIG_SECURITYFS is not set CONFIG_SECURITY_NETWORK=y # CONFIG_SECURITY_NETWORK_XFRM is not set diff --git a/packages/base/any/kernels/4.9-lts/kconfig.mk b/packages/base/any/kernels/4.9-lts/kconfig.mk index 08982e1b..f86fb63a 100644 --- a/packages/base/any/kernels/4.9-lts/kconfig.mk +++ b/packages/base/any/kernels/4.9-lts/kconfig.mk @@ -25,6 +25,6 @@ THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) K_MAJOR_VERSION := 4 K_PATCH_LEVEL := 9 -K_SUB_LEVEL := 74 +K_SUB_LEVEL := 75 K_SUFFIX := K_PATCH_DIR := $(THIS_DIR)/patches From 04257bed1a77d9596c701893c8b4147f6b87b1b8 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 9 Jan 2018 16:32:02 +0000 Subject: [PATCH 118/244] Update to 3.2.98. --- packages/base/any/kernels/3.2-lts/kconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/any/kernels/3.2-lts/kconfig.mk b/packages/base/any/kernels/3.2-lts/kconfig.mk index ba7135a8..8b670e4f 100644 --- a/packages/base/any/kernels/3.2-lts/kconfig.mk +++ b/packages/base/any/kernels/3.2-lts/kconfig.mk @@ -22,7 +22,7 @@ THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) K_MAJOR_VERSION := 3 K_PATCH_LEVEL := 2 -K_SUB_LEVEL := 84 +K_SUB_LEVEL := 98 K_SUFFIX := ifndef K_PATCH_DIR K_PATCH_DIR := $(THIS_DIR)/patches From ed3ef67ce06da37627758c730a26bfdb8648ecb9 Mon Sep 17 00:00:00 2001 From: chenglin-tsai Date: Wed, 10 Jan 2018 14:25:55 +0800 Subject: [PATCH 119/244] Remove not existing module. --- .../r0/src/python/x86_64_delta_ag9064_r0/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py index d9083aca..bd96f2c4 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/platform-config/r0/src/python/x86_64_delta_ag9064_r0/__init__.py @@ -12,7 +12,5 @@ class OnlPlatform_x86_64_delta_ag9064_r0(OnlPlatformDelta, # initiate eeprom self.new_i2c_device('24c02', 0x56, 0) - self.insmod('i2c-mei') - return True From 438cf371915863fbd1bb4ba398cf681f21f919f9 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Wed, 10 Jan 2018 22:28:32 +0000 Subject: [PATCH 120/244] Adding support for Wedge 100S --- .../x86-64-accton-wedge100s-32x/Makefile | 1 + .../modules/Makefile | 1 + .../modules/PKG.yml | 1 + .../x86-64-accton-wedge100s-32x/onlp/Makefile | 1 + .../x86-64-accton-wedge100s-32x/onlp/PKG.yml | 16 +++++++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../lib/x86-64-accton-wedge100s-32x-r0.yml | 34 +++++++++++++++++++ .../__init__.py | 8 +++++ 10 files changed, 65 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/PKG.yml new file mode 100644 index 00000000..37dc3877 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100s-32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml new file mode 100644 index 00000000..b1524668 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml @@ -0,0 +1,16 @@ +variables: + platform: x86-64-accton-wedge100s-32x-r0 + install: /lib/platform-config/${platform}/onl + +common: + version: 1.0.0 + arch: amd64 + copyright: Copyright 2013, 2014, 2015 Big Switch Networks + maintainer: support@bigswitch.com + support: opennetworklinux@googlegroups.com + comment: dummy package for ONLP on Wedge +packages: + - name: onlp-${platform} + summary: ONLP Package for the ${platform} platform. + + changelog: initial version diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/PKG.yml new file mode 100644 index 00000000..34ea7f0c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100s-32x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml new file mode 100644 index 00000000..b72d94a8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml @@ -0,0 +1,34 @@ +--- + +###################################################################### +# +# platform-config for WEDGE +# +###################################################################### + +x86-64-accton-wedge100s-32x-r0: + + grub: + + serial: >- + --unit=0 + --speed=57600 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-4-9 + + args: >- + nopat + console=ttyS0,57600n8 + rd_NO_MD + rd_NO_LUKS + intel_iommu=off + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py new file mode 100644 index 00000000..3ec4b68d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py @@ -0,0 +1,8 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_wedge100s_32x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_32x100): + MODEL="Wedge-100s-32x" + PLATFORM="x86-64-accton-wedge100s-32x-r0" + SYS_OBJECT_ID=".100.2" From 9cd087dcb78a942cb320927f2971f4074fb2be83 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 11 Jan 2018 20:58:53 +0000 Subject: [PATCH 121/244] Allow input from both yaml and json. --- tools/sjson.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/sjson.py b/tools/sjson.py index 4e3483b2..8f32d36d 100755 --- a/tools/sjson.py +++ b/tools/sjson.py @@ -48,7 +48,10 @@ if ops.inout: g_data={} if ops._in: - g_data = json.load(open(ops._in)) + try: + g_data = yaml.load(open(ops._in)) + except: + g_data = json.load(open(ops._in)) if ops.kj: (k, j) = ops.kj From 313ae83055df1ef440d27ec0ffa3500368355346 Mon Sep 17 00:00:00 2001 From: Stanley Chi Date: Fri, 12 Jan 2018 13:05:54 +0800 Subject: [PATCH 122/244] Add new Delta platform: AG9032V2. Add ipmitool to jessie builds. Add support for AG9032V2 on kernel 4.9-lts config. Signed-off-by: Stanley Chi --- .../jessie/common/all-base-packages.yml | 1 + .../configs/x86_64-all/x86_64-all.config | 28 +- .../x86-64/x86-64-delta-ag9032v2/.gitignore | 3 + .../x86-64/x86-64-delta-ag9032v2/Makefile | 1 + .../x86-64-delta-ag9032v2/modules/Makefile | 1 + .../x86-64-delta-ag9032v2/modules/PKG.yml | 1 + .../x86-64-delta-ag9032v2/onlp/Makefile | 1 + .../x86-64/x86-64-delta-ag9032v2/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++ .../lib/libonlp-x86-64-delta-ag9032v2-r0.mk | 10 + .../onlp/builds/onlpdump/Makefile | 46 ++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 10 + .../onlp/builds/src/module/auto/make.mk | 10 + .../src/module/auto/x86_64_delta_ag9032v2.yml | 55 ++ .../x86_64_delta_ag9032v2.x | 16 + .../x86_64_delta_ag9032v2_config.h | 155 +++++ .../x86_64_delta_ag9032v2_dox.h | 26 + .../x86_64_delta_ag9032v2_porting.h | 107 ++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 284 +++++++++ .../onlp/builds/src/module/src/ledi.c | 305 ++++++++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 139 +++++ .../onlp/builds/src/module/src/platform_lib.h | 151 +++++ .../onlp/builds/src/module/src/psui.c | 180 ++++++ .../onlp/builds/src/module/src/sfpi.c | 552 ++++++++++++++++++ .../onlp/builds/src/module/src/sysi.c | 128 ++++ .../onlp/builds/src/module/src/thermali.c | 157 +++++ .../module/src/x86_64_delta_ag9032v2_config.c | 81 +++ .../module/src/x86_64_delta_ag9032v2_enums.c | 10 + .../module/src/x86_64_delta_ag9032v2_int.h | 12 + .../module/src/x86_64_delta_ag9032v2_log.c | 18 + .../module/src/x86_64_delta_ag9032v2_log.h | 12 + .../module/src/x86_64_delta_ag9032v2_module.c | 24 + .../module/src/x86_64_delta_ag9032v2_ucli.c | 50 ++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 2 + .../r0/src/lib/x86-64-delta-ag9032v2-r0.yml | 30 + .../x86_64_delta_ag9032v2_r0/__init__.py | 18 + 43 files changed, 2697 insertions(+), 6 deletions(-) create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/libonlp-x86-64-delta-ag9032v2-r0.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.module create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2.x create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_dox.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_enums.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_int.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_module.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_ucli.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/lib/x86-64-delta-ag9032v2-r0.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/python/x86_64_delta_ag9032v2_r0/__init__.py diff --git a/builds/any/rootfs/jessie/common/all-base-packages.yml b/builds/any/rootfs/jessie/common/all-base-packages.yml index c33d5e8e..a3835b56 100644 --- a/builds/any/rootfs/jessie/common/all-base-packages.yml +++ b/builds/any/rootfs/jessie/common/all-base-packages.yml @@ -78,3 +78,4 @@ - tcpdump - strace - sysstat +- ipmitool diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index 82636cbb..c42f22ad 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -393,10 +393,13 @@ CONFIG_ZONE_DMA=y CONFIG_SMP=y CONFIG_X86_FEATURE_NAMES=y CONFIG_X86_FAST_FEATURE_TESTS=y +CONFIG_X86_X2APIC=y CONFIG_X86_MPPARSE=y # CONFIG_GOLDFISH is not set CONFIG_X86_EXTENDED_PLATFORM=y +# CONFIG_X86_NUMACHIP is not set # CONFIG_X86_VSMP is not set +# CONFIG_X86_UV is not set # CONFIG_X86_GOLDFISH is not set # CONFIG_X86_INTEL_MID is not set # CONFIG_X86_INTEL_LPSS is not set @@ -404,7 +407,8 @@ CONFIG_X86_EXTENDED_PLATFORM=y # CONFIG_IOSF_MBI is not set CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y CONFIG_SCHED_OMIT_FRAME_POINTER=y -# CONFIG_HYPERVISOR_GUEST is not set +CONFIG_HYPERVISOR_GUEST=y +# CONFIG_PARAVIRT is not set CONFIG_NO_BOOTMEM=y # CONFIG_MK8 is not set # CONFIG_MPSC is not set @@ -600,6 +604,7 @@ CONFIG_ACPI_CPU_FREQ_PSS=y CONFIG_ACPI_PROCESSOR_CSTATE=y CONFIG_ACPI_PROCESSOR_IDLE=y CONFIG_ACPI_PROCESSOR=y +# CONFIG_ACPI_IPMI is not set CONFIG_ACPI_HOTPLUG_CPU=y # CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set CONFIG_ACPI_THERMAL=y @@ -1874,6 +1879,7 @@ CONFIG_MOUSE_PS2_TRACKPOINT=y # CONFIG_MOUSE_PS2_SENTELIC is not set # CONFIG_MOUSE_PS2_TOUCHKIT is not set CONFIG_MOUSE_PS2_FOCALTECH=y +# CONFIG_MOUSE_PS2_VMMOUSE is not set # CONFIG_MOUSE_SERIAL is not set # CONFIG_MOUSE_APPLETOUCH is not set # CONFIG_MOUSE_BCM5974 is not set @@ -2072,7 +2078,14 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_FSL_LPUART is not set CONFIG_HVC_DRIVER=y CONFIG_VIRTIO_CONSOLE=y -# CONFIG_IPMI_HANDLER is not set +CONFIG_IPMI_HANDLER=y +CONFIG_IPMI_PANIC_EVENT=y +CONFIG_IPMI_PANIC_STRING=y +CONFIG_IPMI_DEVICE_INTERFACE=y +CONFIG_IPMI_SI=y +CONFIG_IPMI_SSIF=y +# CONFIG_IPMI_WATCHDOG is not set +CONFIG_IPMI_POWEROFF=y CONFIG_HW_RANDOM=y # CONFIG_HW_RANDOM_TIMERIOMEM is not set # CONFIG_HW_RANDOM_INTEL is not set @@ -2133,8 +2146,8 @@ CONFIG_I2C_ALGOBIT=y # CONFIG_I2C_AMD756 is not set # CONFIG_I2C_AMD8111 is not set CONFIG_I2C_I801=y -# CONFIG_I2C_ISCH is not set -# CONFIG_I2C_ISMT is not set +CONFIG_I2C_ISCH=y +CONFIG_I2C_ISMT=y # CONFIG_I2C_PIIX4 is not set # CONFIG_I2C_NFORCE2 is not set # CONFIG_I2C_SIS5595 is not set @@ -2296,6 +2309,8 @@ CONFIG_HWMON=y # CONFIG_SENSORS_G760A is not set # CONFIG_SENSORS_G762 is not set # CONFIG_SENSORS_HIH6130 is not set +# CONFIG_SENSORS_IBMAEM is not set +# CONFIG_SENSORS_IBMPEX is not set CONFIG_SENSORS_IIO_HWMON=y # CONFIG_SENSORS_I5500 is not set CONFIG_SENSORS_CORETEMP=y @@ -2512,7 +2527,7 @@ CONFIG_BCMA_POSSIBLE=y # # Multifunction device drivers # -# CONFIG_MFD_CORE is not set +CONFIG_MFD_CORE=y # CONFIG_MFD_AS3711 is not set # CONFIG_PMIC_ADP5520 is not set # CONFIG_MFD_BCM590XX is not set @@ -2531,7 +2546,7 @@ CONFIG_BCMA_POSSIBLE=y # CONFIG_MFD_MC13XXX_I2C is not set # CONFIG_HTC_PASIC3 is not set # CONFIG_LPC_ICH is not set -# CONFIG_LPC_SCH is not set +CONFIG_LPC_SCH=y # CONFIG_MFD_INTEL_LPSS_ACPI is not set # CONFIG_MFD_INTEL_LPSS_PCI is not set # CONFIG_MFD_JANZ_CMODIO is not set @@ -3353,6 +3368,7 @@ CONFIG_VIRTIO_MMIO=y # # Microsoft Hyper-V guest support # +# CONFIG_HYPERV is not set # CONFIG_STAGING is not set CONFIG_X86_PLATFORM_DEVICES=y # CONFIG_ACERHDF is not set diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/.gitignore new file mode 100644 index 00000000..9760ef60 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/.gitignore @@ -0,0 +1,3 @@ +*x86*64*delta*ag9032v2.mk +onlpdump.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/PKG.yml new file mode 100644 index 00000000..485fedea --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-ag9032v2 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/PKG.yml new file mode 100644 index 00000000..7ce40e85 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-delta-ag9032v2 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/Makefile new file mode 100644 index 00000000..c9339e4b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-delta-ag9032v2 +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_delta_ag9032v2 onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-delta-ag9032v2.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/libonlp-x86-64-delta-ag9032v2-r0.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/libonlp-x86-64-delta-ag9032v2-r0.mk new file mode 100644 index 00000000..50c767a3 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/lib/libonlp-x86-64-delta-ag9032v2-r0.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-delta-ag9032v2-r0 module. +# +# Autogenerated 2016-03-16 22:11:47.698846 +# +############################################################################### +libonlp-x86-64-delta-ag9032v2-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..849c7a0d --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_delta_ag9032v2 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.module b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.module new file mode 100644 index 00000000..af8dabeb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_delta_ag9032v2 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/Makefile new file mode 100644 index 00000000..feefff90 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/Makefile @@ -0,0 +1,10 @@ +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.mk + +MODULE := x86_64_delta_ag9032v2 +AUTOMODULE := x86_64_delta_ag9032v2 +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..7b2d1020 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# x86_64_delta_ag9032v2 Autogeneration +# +############################################################################### + +x86_64_delta_ag9032v2_AUTO_DEFS := module/auto/x86_64_delta_ag9032v2.yml +x86_64_delta_ag9032v2_AUTO_DIRS := module/inc/x86_64_delta_ag9032v2 module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml new file mode 100644 index 00000000..eab5e217 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml @@ -0,0 +1,55 @@ +############################################################################### +# +# x86_64_delta_ag9032v2 Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_DELTA_ag9032v2_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_DELTA_ag9032v2_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_DELTA_ag9032v2_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_DELTA_ag9032v2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB +- X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 +- X86_64_DELTA_ag9032v2_CONFIG_SFP_COUNT: + doc: "SFP port numbers." + default: 4 +- X86_64_DELTA_ag9032v2_CONFIG_FAN_RPM_MAX: + doc: "Max fan speed." + default: 18000 + +definitions: + cdefs: + X86_64_DELTA_ag9032v2_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_delta_ag9032v2_config + + portingmacro: + X86_64_DELTA_ag9032v2: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2.x b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2.x new file mode 100644 index 00000000..8480a046 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2.x @@ -0,0 +1,16 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ + + +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h new file mode 100644 index 00000000..23042b1d --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h @@ -0,0 +1,155 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_ag9032v2 Configuration Header + * + * @addtogroup x86_64_delta_ag9032v2-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG9032V2_CONFIG_H__ +#define __X86_64_DELTA_AG9032V2_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_DELTA_AG9032V2_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING +#define X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT +#define X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI +#define X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_SFP_COUNT + * + * SFP port numbers. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT +#define X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT 4 +#endif + +/** + * X86_64_DELTA_ag9032v2_CONFIG_FAN_RPM_MAX + * + * Max fan speed. */ + + +#ifndef X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX +#define X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX 18000 +#endif + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_delta_ag9032v2_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_delta_ag9032v2_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_delta_ag9032v2_config_settings table. */ +extern x86_64_delta_ag9032v2_config_settings_t x86_64_delta_ag9032v2_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_delta_ag9032v2_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_delta_ag9032v2_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_delta_ag9032v2_porting.h" + +#endif /* __x86_64_delta_ag9032v2_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_dox.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_dox.h new file mode 100644 index 00000000..2057732c --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_delta_ag9032v2 Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_ag9032v2_DOX_H__ +#define _X86_64_DELTA_ag9032v2_DOX_H__ + +/** + * @defgroup x86_64_delta_ag9032v2 x86_64_delta_ag9032v2 - x86_64_delta_ag9032v2 Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_delta_ag9032v2-x86_64_delta_ag9032v2 Public Interface + * @defgroup x86_64_delta_ag9032v2-config Compile Time Configuration + * @defgroup x86_64_delta_ag9032v2-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_DELTA_ag9032v2_DOX_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h new file mode 100644 index 00000000..43ba283a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_ag9032v2 Porting Macros. + * + * @addtogroup x86_64_delta_ag9032v2-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG9032V2_PORTING_H__ +#define __X86_64_DELTA_AG9032V2_PORTING_H__ + + +/* */ +#if X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_delta_ag9032v2_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_delta_ag9032v2_MALLOC GLOBAL_MALLOC + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_MALLOC malloc + #else + #error The macro x86_64_delta_ag9032v2_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_FREE + #if defined(GLOBAL_FREE) + #define x86_64_delta_ag9032v2_FREE GLOBAL_FREE + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_FREE free + #else + #error The macro x86_64_delta_ag9032v2_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_delta_ag9032v2_MEMSET GLOBAL_MEMSET + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_MEMSET memset + #else + #error The macro x86_64_delta_ag9032v2_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_delta_ag9032v2_MEMCPY GLOBAL_MEMCPY + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_MEMCPY memcpy + #else + #error The macro x86_64_delta_ag9032v2_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_delta_ag9032v2_STRNCPY GLOBAL_STRNCPY + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_STRNCPY strncpy + #else + #error The macro x86_64_delta_ag9032v2_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_delta_ag9032v2_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_VSNPRINTF vsnprintf + #else + #error The macro x86_64_delta_ag9032v2_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_delta_ag9032v2_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_SNPRINTF snprintf + #else + #error The macro x86_64_delta_ag9032v2_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag9032v2_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_delta_ag9032v2_STRLEN GLOBAL_STRLEN + #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag9032v2_STRLEN strlen + #else + #error The macro x86_64_delta_ag9032v2_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* _X86_64_DELTA_AG9032V2_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..bac60943 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_delta_ag9032v2_INCLUDES := -I $(THIS_DIR)inc +x86_64_delta_ag9032v2_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_delta_ag9032v2_DEPENDMODULE_ENTRIES := init:x86_64_delta_ag9032v2 ucli:x86_64_delta_ag9032v2 + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..afea0377 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_delta_ag9032v2_ucli.c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..0766660a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/fani.c @@ -0,0 +1,284 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include "platform_lib.h" +#include +#include + +#define MAKE_FAN_INFO_NODE_ON_FAN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_FAN_BOARD), "Chassis Fan "#id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, // Not used + MAKE_FAN_INFO_NODE_ON_FAN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_FAN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_FAN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_FAN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_FAN_BOARD(5), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_name) +{ + int bit_data = 0; + int rv = ONLP_STATUS_OK; + uint8_t present_bit = 0x00; + uint8_t bit = 0x00; + UINT4 multiplier = 1; + UINT4 u4Data = 0; + + if(dni_get_bmc_data(dev_name, &u4Data, multiplier) == ONLP_STATUS_OK) + { + info->rpm = u4Data; + info->percentage = (info->rpm * 100) / MAX_FAN_SPEED; + } + + rv = dni_fanpresent_info_get(&bit_data); + + if(rv == ONLP_STATUS_OK && bit_data != 0) + { + present_bit = bit_data; + } + else + { + rv = ONLP_STATUS_E_INVALID; + } + + + switch(local_id) + { + case FAN_1_ON_FAN_BOARD: + if((present_bit & ((bit+1) << 4)) == 0) + info->status |= ONLP_FAN_STATUS_PRESENT; + else + info->status |= ONLP_FAN_STATUS_FAILED; + break; + case FAN_2_ON_FAN_BOARD: + if((present_bit & ((bit+1) << 3)) == 0) + info->status |= ONLP_FAN_STATUS_PRESENT; + else + info->status |= ONLP_FAN_STATUS_FAILED; + break; + case FAN_3_ON_FAN_BOARD: + if((present_bit & ((bit+1) << 2)) == 0) + info->status |= ONLP_FAN_STATUS_PRESENT; + else + info->status |= ONLP_FAN_STATUS_FAILED; + break; + case FAN_4_ON_FAN_BOARD: + if((present_bit & ((bit+1) << 1)) == 0) + info->status |= ONLP_FAN_STATUS_PRESENT; + else + info->status |= ONLP_FAN_STATUS_FAILED; + break; + case FAN_5_ON_FAN_BOARD: + if((present_bit & (bit+1)) == 0) + info->status |= ONLP_FAN_STATUS_PRESENT; + else + info->status |= ONLP_FAN_STATUS_FAILED; + break; + } + return rv; + +} + +static int +dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, char *dev_name) +{ + int rpm_data = 0; + int rv = ONLP_STATUS_OK; + int psu_present = 0; + char module_name[20] = {0}; + UINT4 multiplier = 1; + UINT4 u4Data = 0; + + psu_present = dni_psui_eeprom_info_get(module_name, local_id - CHASSIS_FAN_COUNT, PSU_MODEL_REG); + rv = dni_get_bmc_data(dev_name, &u4Data, multiplier); + rpm_data = (int)u4Data; + + if( psu_present == ONLP_STATUS_OK ) + { + info->rpm = rpm_data; + info->percentage = (info->rpm * 100) / MAX_FAN_SPEED; + } + else + { + rv = ONLP_STATUS_E_INVALID; + } + + switch(local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + if( psu_present == ONLP_STATUS_OK ) + info->status |= ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F; + else + info->status |= ONLP_FAN_STATUS_FAILED; + break; + } + return rv; + +} +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int local_id; + int rv = ONLP_STATUS_OK; + + VALIDATE(id); + local_id = ONLP_OID_ID_GET(id); + *info = linfo[ONLP_OID_ID_GET(id)]; + + switch(local_id) + { + case FAN_1_ON_FAN_BOARD: + rv = dni_fani_info_get_fan(local_id, info, "Fantray_1"); + break; + case FAN_2_ON_FAN_BOARD: + rv = dni_fani_info_get_fan(local_id, info, "Fantray_2"); + break; + case FAN_3_ON_FAN_BOARD: + rv = dni_fani_info_get_fan(local_id, info, "Fantray_3"); + break; + case FAN_4_ON_FAN_BOARD: + rv = dni_fani_info_get_fan(local_id, info, "Fantray_4"); + break; + case FAN_5_ON_FAN_BOARD: + rv = dni_fani_info_get_fan(local_id, info, "Fantray_5"); + break; + case FAN_1_ON_PSU1: + rv = dni_fani_info_get_fan_on_psu(local_id, info, "PSU1_Fan"); + break; + case FAN_1_ON_PSU2: + rv = dni_fani_info_get_fan_on_psu(local_id, info, "PSU2_Fan"); + break; + default: + rv = ONLP_STATUS_E_INVALID; + break; + } + + return rv; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..90123707 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,305 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include "platform_lib.h" +#include +#include + + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Get the information for the given LED OID. + */ + +static onlp_led_info_t linfo[] = +{ + { }, // Not used + { + { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_PWR1), "FRONT LED (PWR1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_PWR2), "FRONT LED (PWR2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_5), "FAN TRAY 5 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN, + }, +}; + + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int rv = ONLP_STATUS_OK; + int local_id; + int r_data = 0; + int bit_data = 0; + uint8_t present_bit = 0x00; + uint8_t bit = 0x00; + dev_info_t dev_info; + + VALIDATE(id); + local_id = ONLP_OID_ID_GET(id); + *info = linfo[ONLP_OID_ID_GET(id)]; + + dev_info.bus = I2C_BUS_1; + dev_info.addr = SWPLD_1_ADDR; + dev_info.offset = SYS_LED1_REGISTER; + dev_info.flags = ONLP_I2C_F_FORCE; + r_data = onlp_i2c_readb(dev_info.bus, dev_info.addr, dev_info.offset, dev_info.flags); + + rv = dni_fanpresent_info_get(&bit_data); + + if(rv == ONLP_STATUS_OK) + { + present_bit = bit_data; + } + else + { + rv = ONLP_STATUS_E_INVALID; + } + + switch(local_id) + { + case LED_FRONT_FAN: + if((r_data & 0x03) == 0x01) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x03) == 0x02) + info->mode = ONLP_LED_MODE_ORANGE; + else if ((r_data & 0x03) == 0x03 || (r_data & 0x03) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; + break; + + case LED_FRONT_SYS: + if((r_data & 0x0c) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x0c) == 0x08) + info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0x0c) == 0x0c) + info->mode = ONLP_LED_MODE_RED; + else if ((r_data & 0x0c) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; + break; + + case LED_FRONT_PWR1: + if((r_data & 0xc0) == 0x40) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0xc0) == 0x80) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if ((r_data & 0xc0) == 0xc0 || (r_data & 0xc0) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; + break; + + case LED_FRONT_PWR2: + if((r_data & 0x30) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x30) == 0x20) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if ((r_data & 0x30) == 0x30 || (r_data & 0x30) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; + break; + + case LED_REAR_FAN_TRAY_1: + dev_info.offset = SYS_FANLED1_REGISTER; + r_data = onlp_i2c_readb(dev_info.bus, dev_info.addr, dev_info.offset, dev_info.flags); + + if((present_bit & ((bit+1) << 4)) == 0) + { + if((r_data & 0xc0) == 0x40) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0xc0) == 0x80) + info->mode = ONLP_LED_MODE_RED; + } + else + info->mode = ONLP_LED_MODE_OFF; + break; + + case LED_REAR_FAN_TRAY_2: + dev_info.offset = SYS_FANLED2_REGISTER; + r_data = onlp_i2c_readb(dev_info.bus, dev_info.addr, dev_info.offset, dev_info.flags); + + if((present_bit & ((bit+1) << 3)) == 0) + { + if((r_data & 0x03) == 0x01) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x03) == 0x02) + info->mode = ONLP_LED_MODE_RED; + } + else + info->mode = ONLP_LED_MODE_OFF; + break; + + case LED_REAR_FAN_TRAY_3: + dev_info.offset = SYS_FANLED2_REGISTER; + r_data = onlp_i2c_readb(dev_info.bus, dev_info.addr, dev_info.offset, dev_info.flags); + + if((present_bit & ((bit+1) << 2)) == 0) + { + if((r_data & 0x0c) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x0c) == 0x08) + info->mode = ONLP_LED_MODE_RED; + } + else + info->mode = ONLP_LED_MODE_OFF; + break; + + case LED_REAR_FAN_TRAY_4: + dev_info.offset = SYS_FANLED2_REGISTER; + r_data = onlp_i2c_readb(dev_info.bus, dev_info.addr, dev_info.offset, dev_info.flags); + + if((present_bit & ((bit+1) << 1)) == 0) + { + if((r_data & 0x30) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x30) == 0x20) + info->mode = ONLP_LED_MODE_RED; + } + else + info->mode = ONLP_LED_MODE_OFF; + break; + + case LED_REAR_FAN_TRAY_5: + dev_info.offset = SYS_FANLED2_REGISTER; + r_data = onlp_i2c_readb(dev_info.bus, dev_info.addr, dev_info.offset, dev_info.flags); + + if((present_bit & (bit+1)) == 0) + { + if((r_data & 0xc0) == 0x40) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0xc0) == 0x80) + info->mode = ONLP_LED_MODE_RED; + } + else + info->mode = ONLP_LED_MODE_OFF; + break; + } + + /* Set the on/off status */ + if (info->mode == ONLP_LED_MODE_OFF) + info->status |= ONLP_LED_STATUS_FAILED; + else + info->status |=ONLP_LED_STATUS_PRESENT; + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + if (!on_or_off) + { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..925fe67f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_delta_ag9032v2 +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..330bb42f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,139 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include "platform_lib.h" +#include +#include + +int dni_get_bmc_data(char *device_name, UINT4 *num, UINT4 multiplier) +{ + FILE *fpRead; + char Buf[ 10 ]={0}; + char ipmi_command[120] = {0}; + int lenth=10; + float num_f; + + sprintf(ipmi_command, "ipmitool sdr get %s |grep 'Sensor Reading'| awk -F':' '{print $2}'| awk -F' ' '{ print $1}'", device_name); + fpRead = popen(ipmi_command, "r"); + + if(fpRead == NULL){ + pclose(fpRead); + return ONLP_STATUS_E_GENERIC; + } + fgets(Buf, lenth , fpRead); + num_f = atof( Buf ); + *num = num_f * multiplier; + pclose(fpRead); + return ONLP_STATUS_OK; +} + +int +dni_fanpresent_info_get(int *r_data) +{ + int rv = ONLP_STATUS_OK; + char cmd[30] = {0}; + char str_data[100] = {0}; + FILE *fptr = NULL; + + sprintf(cmd, "ipmitool raw 0x38 0x0e"); + fptr = popen(cmd, "r"); + if(fptr != NULL) + { + if(fgets(str_data, sizeof(str_data), fptr) != NULL) + { + *r_data = strtol(str_data, NULL, 16); + } + else + { + rv = ONLP_STATUS_E_INVALID; + } + pclose(fptr); + } + else + { + pclose(fptr); + rv = ONLP_STATUS_E_INVALID; + } + + return rv; +} + +int hex_to_int(char hex_input){ + int first = hex_input / 16 - 3; + int second = hex_input % 16; + int result = first*10 + second; + if(result > 9) result--; + return result; +} + +int hex_to_ascii(char hex_high, char hex_low){ + int high = hex_to_int(hex_high) * 16; + int low = hex_to_int(hex_low); + return high+low; +} + +int +dni_psui_eeprom_info_get(char *r_data, int psu_id, int psu_reg) +{ + int i = 0; + int rv = ONLP_STATUS_OK; + FILE *fptr = NULL; + char buf; + char cmd[35] = {0}; + char str_data[50] = {0}; + + sprintf(cmd, "ipmitool raw 0x38 0x12 %d %d", psu_id, psu_reg); + fptr = popen(cmd, "r"); + + if(fptr != NULL) + { + while( (buf = fgetc(fptr)) != EOF) { + if( buf != ' '){ + str_data[i] = buf; + i++; + } + } + if(i == 0){ + pclose(fptr); + rv = ONLP_STATUS_E_INVALID; + } + else{ + /* "str_data" :psu model name or serial number in hex code + * str_data(hex) ex:0e 44 50 53 2d 38 30 30 41 42 2d 31 36 20 44 + */ + for(i = 1; i < PSU_NUM_LENGTH; i++) + { + r_data[i] = hex_to_ascii(str_data[2*i], str_data[2*i+1]); + } + pclose(fptr); + } + } + else + { + pclose(fptr); + rv = ONLP_STATUS_E_INVALID; + } + return rv; +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..dc606f90 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,151 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_delta_ag9032v2_log.h" + +typedef unsigned int UINT4; + +/* CPLD numbrt & peripherals */ +#define NUM_OF_THERMAL_ON_MAIN_BROAD (6) +#define NUM_OF_LED_ON_MAIN_BROAD (9) +#define NUM_OF_FAN_ON_MAIN_BROAD (5) +#define NUM_OF_PSU_ON_MAIN_BROAD (2) +#define NUM_OF_SENSORS (47) +#define CHASSIS_FAN_COUNT (5) +#define CHASSIS_THERMAL_COUNT (6) +#define I2C_BUS_1 (1) +#define PSU1_ID (1) +#define PSU2_ID (2) +#define NUM_OF_SFP_PORT (2) +#define NUM_OF_QSFP_PORT (32) +#define NUM_OF_ALL_PORT (34) +#define PSU_NUM_LENGTH (15) +#define UPDATE_THRESHOLD (2) //second +#define MAX_FAN_SPEED (23000) +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0053/eeprom" + +/* REG define*/ +#define SWPLD_1_ADDR (0x6A) +#define SWPLD_2_ADDR (0x73) +#define SWPLD_3_ADDR (0x75) +#define DEFAULT_FLAG (0x00) +#define CPUCPLD (0x31) +#define CPUPLD_VERSION_ADDR (0x01) +#define SWPLD (0x31) +#define SWPLD_VERSION_ADDR (0x01) +#define DEFAULT_FLAG (0x00) +#define POWER_STAT_REGISTER (0x03) +#define SYS_LED1_REGISTER (0x21) +#define SYS_FANLED2_REGISTER (0x20) +#define SYS_FANLED1_REGISTER (0x23) +#define PSU_I2C_SEL_PSU1_EEPROM (0x00) +#define PSU_I2C_SEL_PSU2_EEPROM (0x20) +#define PSU_FAN_MUX_REG (0x1E) +#define PSU_MODEL_REG (0x9A) +#define PSU_SERIAL_REG (0x9E) + +/*SFP REG define*/ +#define SFP_SIGNAL_REG (0x02) +#define SFP_MODULE_EEPROM (0x50) +#define SFP_I2C_MUX_REG (0x1F) +#define SFP_RESET_1 (0x16) +#define SFP_RESET_2 (0x17) +#define SFP_RESET_3 (0x18) +#define SFP_RESET_4 (0x19) +#define SFP_LP_MODE_1 (0x0E) +#define SFP_LP_MODE_2 (0x0F) +#define SFP_LP_MODE_3 (0x10) +#define SFP_LP_MODE_4 (0x11) +#define SFP_RESPOND_1 (0x0A) +#define SFP_RESPOND_2 (0x0B) +#define SFP_RESPOND_3 (0x0C) +#define SFP_RESPOND_4 (0x0D) +#define SFP_PRESENT_1 (0x12) +#define SFP_PRESENT_2 (0x13) +#define SFP_PRESENT_3 (0x14) +#define SFP_PRESENT_4 (0x15) + +int dni_get_bmc_data(char *device_name, UINT4 *num, UINT4 multiplier); +int dni_fanpresent_info_get(int *r_data); +int dni_psui_eeprom_info_get(char *r_data, int psu_id, int psu_reg); + +char dev_name[50][32]; +float dev_sensor[50]; + +typedef struct dev_info_s +{ + int bus; + int size; + uint8_t addr; + uint8_t data_8; + uint16_t data_16; + uint8_t offset; + uint32_t flags; +}dev_info_t; + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_CPU_BOARD, + THERMAL_2_ON_FAN_BOARD, + THERMAL_3_ON_MAIN_BOARD, + THERMAL_4_ON_MAIN_BOARD, + THERMAL_5_ON_MAIN_BOARD, + THERMAL_6_ON_PSU1, + THERMAL_7_ON_PSU2 +}; + +typedef enum +{ + FAN_RESERVED = 0, + FAN_1_ON_FAN_BOARD, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_1_ON_PSU1, + FAN_1_ON_PSU2 +} onlp_fan_id; + +typedef enum +{ + LED_RESERVED = 0, + LED_FRONT_FAN, + LED_FRONT_SYS, + LED_FRONT_PWR1, + LED_FRONT_PWR2, + LED_REAR_FAN_TRAY_1, + LED_REAR_FAN_TRAY_2, + LED_REAR_FAN_TRAY_3, + LED_REAR_FAN_TRAY_4, + LED_REAR_FAN_TRAY_5 +}onlp_led_id; + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..8a3da417 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/psui.c @@ -0,0 +1,180 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_delta_ag9032v2_int.h" +#include +#include "platform_lib.h" +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int i; + int local_id; + UINT4 multiplier = 1000; + UINT4 u4Data = 0; + + char device_name[10] = {0}; + char module_name[20] = {0}; + char *module_name_ptr = module_name; + + VALIDATE(id); + local_id = ONLP_OID_ID_GET(id); + *info = pinfo[ONLP_OID_ID_GET(id)]; + + /* Set the associated oid_table + * Set PSU's fan and thermal to child OID + */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(local_id + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(local_id + CHASSIS_THERMAL_COUNT); + + switch (local_id) { + case PSU1_ID: + case PSU2_ID: + //check PSU is present or not + if ( dni_psui_eeprom_info_get(module_name, local_id, PSU_MODEL_REG) == ONLP_STATUS_E_INVALID ){ + info->status = ONLP_PSU_STATUS_FAILED; + break; + } + //get psu Pin/Pout + sprintf(device_name, "PSU%d_Pin",local_id); + if(dni_get_bmc_data(device_name, &u4Data, multiplier) == 0){ + info->mpin = u4Data ; + info->status = ONLP_PSU_STATUS_PRESENT; + info->caps |= ONLP_PSU_CAPS_PIN; + } + else{ + info->caps |= ONLP_PSU_STATUS_UNPLUGGED; + } + + sprintf(device_name, "PSU%d_Pout",local_id); + if(dni_get_bmc_data(device_name, &u4Data, multiplier) == 0){ + info->mpout = u4Data ; + info->status = ONLP_PSU_STATUS_PRESENT; + info->caps |= ONLP_PSU_CAPS_POUT; + } + else{ + info->caps |= ONLP_PSU_STATUS_UNPLUGGED; + } + //get psu Iin/Iout + sprintf(device_name, "PSU%d_Iin",local_id); + if(dni_get_bmc_data(device_name, &u4Data, multiplier) == ONLP_STATUS_OK){ + info->miin = u4Data ; + info->status = ONLP_PSU_STATUS_PRESENT; + info->caps |= ONLP_PSU_CAPS_IIN; + } + else{ + info->caps |= ONLP_PSU_STATUS_UNPLUGGED; + } + sprintf(device_name, "PSU%d_Iout",local_id); + if(dni_get_bmc_data(device_name, &u4Data, multiplier) == ONLP_STATUS_OK){ + info->miout = u4Data; + info->status = ONLP_PSU_STATUS_PRESENT; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + else{ + info->caps |= ONLP_PSU_STATUS_UNPLUGGED; + } + //get psu Vin/Vout + sprintf(device_name, "PSU%d_Vin",local_id); + if(dni_get_bmc_data(device_name, &u4Data, multiplier) == ONLP_STATUS_OK){ + info->mvin = u4Data; + info->status = ONLP_PSU_STATUS_PRESENT; + info->caps |= ONLP_PSU_CAPS_VIN; + } + else{ + info->caps |= ONLP_PSU_STATUS_UNPLUGGED; + } + + sprintf(device_name, "PSU%d_Vout",local_id); + if(dni_get_bmc_data(device_name, &u4Data, multiplier) == ONLP_STATUS_OK){ + info->mvout = u4Data; + info->status = ONLP_PSU_STATUS_PRESENT; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + else{ + info->caps |= ONLP_PSU_STATUS_UNPLUGGED; + } + //get psu model name + if(dni_psui_eeprom_info_get(module_name, local_id, PSU_MODEL_REG) == ONLP_STATUS_OK){ + for(i = 0; i< PSU_NUM_LENGTH; i++){ + module_name[i]=*(module_name_ptr + i + 1); + } + strcpy(info->model, module_name_ptr); + } + else{ + strcpy(info->model, "ONLP_STATUS_E_UNSUPPORTED"); + } + //get psu serial number + module_name[1] = '\0'; + if(dni_psui_eeprom_info_get(module_name_ptr, local_id, PSU_SERIAL_REG) == ONLP_STATUS_OK){ + for(i = 0; i < PSU_NUM_LENGTH; i++){ + module_name[i]=*(module_name_ptr + i + 1); + } + strcpy(info->serial, module_name_ptr); + } + else{ + strcpy(info->serial, "ONLP_STATUS_E_UNSUPPORTED"); + } + break; + + default: + break; + } + + return ONLP_STATUS_OK; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..d11f97a7 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,552 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +static inline int ag9032v2_sfp_get_lp_mode_reg(int port) { + uint8_t reg_offset = 0x00; + if (port < 8) /* port 0-7 */ + reg_offset = SFP_LP_MODE_1; + else if (port > 7 && port < 16) /* port 8-15 */ + reg_offset = SFP_LP_MODE_2; + else if (port > 15 && port < 24) /* port 16-23 */ + reg_offset = SFP_LP_MODE_3; + else if (port > 23 && port < 32) /* port 24-31 */ + reg_offset = SFP_LP_MODE_4; + + return reg_offset; +} + +static inline int ag9032v2_sfp_get_reset_reg(int port) { + uint8_t reg_offset = 0x00; + if (port < 8) /* port 0-7 */ + reg_offset = SFP_RESET_1; + else if (port > 7 && port < 16) /* port 8-15 */ + reg_offset = SFP_RESET_2; + else if (port > 15 && port < 24) /* port 16-23 */ + reg_offset = SFP_RESET_3; + else if (port > 23 && port < 32) /* port 24-31 */ + reg_offset = SFP_RESET_4; + + return reg_offset; +} + +static inline int ag9032v2_sfp_get_present_reg(int port) { + uint8_t reg_offset = 0x00; + if (port < 8) /* port 0-7 */ + reg_offset = SFP_PRESENT_1; + else if (port > 7 && port < 16) /* port 8-15 */ + reg_offset = SFP_PRESENT_2; + else if (port > 15 && port < 24) /* port 16-23 */ + reg_offset = SFP_PRESENT_3; + else if (port > 23 && port < 32) /* port 24-31 */ + reg_offset = SFP_PRESENT_4; + + return reg_offset; +} + +static inline int ag9032v2_sfp_get_respond_reg(int port) { + uint8_t reg_offset = 0x00; + if (port < 8) /* port 0-7 */ + reg_offset = SFP_RESPOND_1; + else if (port > 7 && port < 16) /* port 8-15 */ + reg_offset = SFP_RESPOND_2; + else if (port > 15 && port < 24) /* port 16-23 */ + reg_offset = SFP_RESPOND_3; + else if (port > 23 && port < 32) /* port 24-31 */ + reg_offset = SFP_RESPOND_4; + + return reg_offset; +} + +static inline int ag9032v2_sfp_get_mux_reg(int port) { + uint8_t sel_channel = 0x00; + if (port >= 0 && port < NUM_OF_QSFP_PORT) /* port 0-31 ,reg : 0x01 - 0x32 */ + sel_channel = port; + else if (port == NUM_OF_QSFP_PORT){ /* port 32 */ + sel_channel = 0x20; + } + else if (port == NUM_OF_QSFP_PORT + 1){ /* port 333 */ + sel_channel = 0x21; + } + else + AIM_LOG_ERROR("qsfp port range is 0-33"); + + return sel_channel; +} + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int port; + AIM_BITMAP_CLR_ALL(bmap); + + for(port = 0; port < NUM_OF_ALL_PORT; port++) { + AIM_BITMAP_SET(bmap, port); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + uint8_t present = 0; + uint8_t present_bit = 0; + UINT4 byte_get; + + /* Read QSFP MODULE is present or not */ + if(port < NUM_OF_QSFP_PORT){ //port: QSFP(0-31) + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, ag9032v2_sfp_get_present_reg(port), ONLP_I2C_F_TENBIT); + if(byte_get < 0){ + AIM_LOG_ERROR("Error to present status from port(%d)\r\n", port); + present = ONLP_STATUS_E_GENERIC; + return present; + } + present_bit = byte_get & (1 << (7 - (port % 8))); + present_bit = present_bit >> (7 - (port % 8)); + } + else if((port > (NUM_OF_QSFP_PORT-1)) && (port < NUM_OF_ALL_PORT)){ //port: SFP(32-33) + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); + if(byte_get < 0){ + AIM_LOG_ERROR("Error to present status from port(%d)\r\n", port); + present = ONLP_STATUS_E_GENERIC; + return present; + } + if(port == NUM_OF_ALL_PORT-2){ + byte_get=byte_get >> 4; + present_bit=((byte_get & 0x08) >> 3) & 1; + } + else if(port == NUM_OF_ALL_PORT-1){ + present_bit = (byte_get & 0x08) >> 3; + present_bit = present_bit & 1; + } + } + + /* Read from sfp presence register value, + * return 0 = The module is preset + * return 1 = The module is NOT present + */ + if(present_bit == 0) { + present = 1; + } else if (present_bit == 1) { + present = 0; + AIM_LOG_ERROR("Unble to present status from port(%d)\r\n", port); + } else { + /* Port range over 0-31 and 32-33, return -1 */ + AIM_LOG_ERROR("Error to present status from port(%d)\r\n", port); + present = ONLP_STATUS_E_GENERIC; + } + return present; +} + + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + char present_all_data[12] = {'\0'}; + char *r_byte; + char *r_array[4]; + int count = 0; + int i = 0; + int j = NUM_OF_QSFP_PORT - 1; + uint8_t bytes[4]; + uint8_t byte_get; + uint8_t sfp1; + uint8_t sfp2; + uint32_t presence_all = 0 ; + + /* Read presence bitmap from SWPLD QSFP28 Presence Register + * if only port 0 is present, return 7F FF FF FF + * if only port 0 and 1 present, return 3F FF FF FF + */ + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, SFP_PRESENT_1, ONLP_I2C_F_TENBIT); + if(byte_get < 0)return ONLP_STATUS_E_GENERIC; + bytes[0] = (~byte_get) & 0xFF; + sprintf(present_all_data, "%x%c", byte_get, ' '); + + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, SFP_PRESENT_2, ONLP_I2C_F_TENBIT); + if(byte_get < 0)return ONLP_STATUS_E_GENERIC; + bytes[1] = (~byte_get) & 0xFF; + sprintf(present_all_data + 3, "%x%c", byte_get, ' '); + + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, SFP_PRESENT_3, ONLP_I2C_F_TENBIT); + if(byte_get < 0)return ONLP_STATUS_E_GENERIC; + bytes[2] = (~byte_get) & 0xFF; + sprintf(present_all_data + 6, "%x%c", byte_get, ' '); + + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, SFP_PRESENT_4, ONLP_I2C_F_TENBIT); + if(byte_get < 0)return ONLP_STATUS_E_GENERIC; + bytes[3] = (~byte_get) & 0xFF; + sprintf(present_all_data + 9, "%x%c", byte_get, '\0'); + + /* String split */ + r_byte = strtok(present_all_data, " "); + count = 0; + while (r_byte != NULL) { + r_array[count++] = r_byte; + r_byte = strtok(NULL, " "); + } + + /* Convert a string to long integer + * and saved into bytes[] + */ + for (count = 0; count < 4; count++) { + bytes[count] = ~strtol(r_array[count], NULL, 16); + } + + /* Convert to 64 bit integer in port order */ + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + /* Populate QSFP bitmap & remap*/ + for(i = 0; presence_all; i++) + { + if(23 < j) + AIM_BITMAP_MOD(dst, j - 24,(presence_all & 1)); + else if(15 < j && j < 24) + AIM_BITMAP_MOD(dst, j - 8,(presence_all & 1)); + else if(7 < j && j < 16) + AIM_BITMAP_MOD(dst, j + 8,(presence_all & 1)); + else + AIM_BITMAP_MOD(dst, j + 24,(presence_all & 1)); + presence_all >>= 1; + j--; + } + + /* Populate SFP bitmap */ + byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); + if(byte_get < 0)return ONLP_STATUS_E_GENERIC; + sfp2 = (byte_get & 0x08) >> 3; //get sfp2 present bit + byte_get = byte_get >> 4; + sfp1 = (byte_get & 0x08) >> 3; //get sfp1 present bit + + AIM_BITMAP_MOD(dst, 32, !(sfp1 & 1)); + AIM_BITMAP_MOD(dst, 33, !(sfp2 & 1)); + + return ONLP_STATUS_OK; +} + + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + uint8_t sfp_response_reg = 0x00; + uint8_t sfp_mux_reg = 0x00; + uint8_t backup_response_data = 0x00; + uint8_t response_data = 0x00; + + /* Get port respond register offset */ + sfp_response_reg = ag9032v2_sfp_get_respond_reg(port); + sfp_mux_reg = ag9032v2_sfp_get_mux_reg(port); + + /* Select qsfp port to response mode */ + backup_response_data = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, sfp_response_reg, ONLP_I2C_F_TENBIT); + if(backup_response_data < 0)return ONLP_STATUS_E_GENERIC; + response_data = ~(1 << (7 - (port % 8))); + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, sfp_response_reg, 1, &response_data, ONLP_I2C_F_TENBIT); + + /* Select QSFP port */ + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, SFP_I2C_MUX_REG, 1, &sfp_mux_reg, ONLP_I2C_F_TENBIT); + memset(data, 0, 256); + + /* Read qsfp eeprom information into data[] */ + if (onlp_i2c_read(I2C_BUS_1, SFP_MODULE_EEPROM, 0, 256, data, ONLP_I2C_F_DISABLE_READ_RETRIES)) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, sfp_response_reg, 1, &backup_response_data, ONLP_I2C_F_TENBIT); + return ONLP_STATUS_OK; +} + +int onlp_sfpi_port_map(int port, int* rport) +{ + *rport = port; + return ONLP_STATUS_OK; +} + + +int +onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) +{ + uint8_t sfp_mux_reg = 0x00; + sfp_mux_reg = ag9032v2_sfp_get_mux_reg(port); + /* Select QSFP port */ + + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, SFP_I2C_MUX_REG, 1, &sfp_mux_reg, ONLP_I2C_F_TENBIT); + + if(port < NUM_OF_QSFP_PORT){ //port: QSFP(0-31) + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_LP_MODE: + *rv = 1; + break; + case ONLP_SFP_CONTROL_RX_LOS: + case ONLP_SFP_CONTROL_TX_DISABLE: + *rv = 0; + break; + default: + break; + } + } + else if(port >= (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && port < NUM_OF_ALL_PORT ){ //port: SFP(32,33) + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_LP_MODE: + *rv = 0; + break; + case ONLP_SFP_CONTROL_RX_LOS: + case ONLP_SFP_CONTROL_TX_DISABLE: + *rv = 1; + break; + default: + break; + } + } + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + uint8_t value_t = 0; + uint8_t value_backup = 0; + uint8_t value_u8 =(uint8_t)value; + uint8_t sfp_mux_reg = 0x00; + + sfp_mux_reg = ag9032v2_sfp_get_mux_reg(port); + + /* Select QSFP port */ + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, SFP_I2C_MUX_REG, 1, &sfp_mux_reg, ONLP_I2C_F_TENBIT); + + if(port < NUM_OF_QSFP_PORT){ //port: QSFP(0-31) + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, ag9032v2_sfp_get_reset_reg(port), 1, &value_u8, ONLP_I2C_F_TENBIT); + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_LP_MODE: + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, ag9032v2_sfp_get_lp_mode_reg(port), 1, &value_u8, ONLP_I2C_F_TENBIT); + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_RX_LOS: + case ONLP_SFP_CONTROL_TX_DISABLE: + value_t = ONLP_STATUS_E_INTERNAL; + break; + default: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + else if(port >= (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && port < NUM_OF_ALL_PORT ){ //port: SFP(32,33) + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_LP_MODE: + value_t = ONLP_STATUS_E_INTERNAL; + break; + case ONLP_SFP_CONTROL_RX_LOS: + value_backup = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); + if(value_backup < 0)return ONLP_STATUS_E_GENERIC; + if(port == (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && value_backup >= 0){ + value_u8 = (value_backup | (1 << 6)) & (value << 6); + }else if(port == ( NUM_OF_ALL_PORT - 1) && value_backup >= 0){ + value_u8 = (value_backup | (1 << 2)) & (value << 2); + } + else{ + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + onlp_i2c_write(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, 1, &value_u8, ONLP_I2C_F_TENBIT); + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_TX_DISABLE: + value_backup = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); + if(value_backup < 0)return ONLP_STATUS_E_GENERIC; + if(port == (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && value_backup >= 0){ + value_u8 = (value_backup | (1 << 5)) & (value << 5); + }else if(port == (NUM_OF_ALL_PORT - 1) && value_backup >= 0){ + value_u8 = (value_backup | (1 << 1)) & (value << 1); + } + else{ + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + onlp_i2c_write(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, 1, &value_u8, ONLP_I2C_F_TENBIT); + value_t = ONLP_STATUS_OK; + break; + default: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + else{ + value_t = ONLP_STATUS_E_UNSUPPORTED; + } + return value_t; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + uint8_t value_t = 0; + uint8_t sfp_mux_reg = 0x00; + sfp_mux_reg = ag9032v2_sfp_get_mux_reg(port); + /* Select QSFP port */ + onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, SFP_I2C_MUX_REG, 1, &sfp_mux_reg, ONLP_I2C_F_TENBIT); + + if(port < NUM_OF_QSFP_PORT){ //port: QSFP(0-31) + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + *value = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, ag9032v2_sfp_get_reset_reg(port), ONLP_I2C_F_TENBIT); + if(*value < 0){ + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + *value = (1 << (7 - (*value % 8))) & 1 ; + /* From sfp_reset value, + * return 0 = The module is in Reset + * return 1 = The module is NOT in Reset + */ + if (*value == 0) + *value = 1; + else if (*value == 1) + *value = 0; + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_LP_MODE: + /* From sfp_lp_mode value, + * return 0 = The module is NOT in LP mode + * return 1 = The moduel is in LP mode */ + *value = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, ag9032v2_sfp_get_lp_mode_reg(port), ONLP_I2C_F_TENBIT); + if(*value < 0){ + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + *value = (1 << (7 - (*value % 8))) & 1 ; + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_RX_LOS: + case ONLP_SFP_CONTROL_TX_DISABLE: + *value = 0; + value_t = ONLP_STATUS_OK; + break; + default: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + else if(port >= (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && port < NUM_OF_ALL_PORT ){ //port: SFP(32,33) + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_LP_MODE: + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_RX_LOS: + value_t = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); + if(port == (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && value_t >= 0){ + *value = (value_t >> 6) & 0x01; + } + else if(port == (NUM_OF_ALL_PORT - 1) && value_t >= 0){ + *value = (value_t >> 2) & 0x01; + } + else{ + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_TX_DISABLE: + value_t = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); + if(port == (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && value_t >= 0){ + *value = (value_t >> 5) & 0x01; + } + else if(port == (NUM_OF_ALL_PORT - 1) && value_t >= 0){ + *value = (value_t >> 1) & 0x01; + } + else{ + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + value_t = ONLP_STATUS_OK; + break; + default: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + else{ + value_t = ONLP_STATUS_E_UNSUPPORTED; + } + return value_t; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_post_insert(int port, sff_info_t* info) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +void +onlp_sfpi_debug(int port, aim_pvs_t* pvs) +{ + +} + +int +onlp_sfpi_ioctl(int port, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..579b07e9 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,128 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "x86_64_delta_ag9032v2_int.h" +#include "x86_64_delta_ag9032v2_log.h" +#include "platform_lib.h" +#include +#include + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-delta-ag9032v2-r0"; +} + +int +onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) + { + if(*size == 256) + { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int cpld_version = 0; + int swpld1_version = 0; + int swpld2_version = 0; + int swpld3_version = 0; + + cpld_version = onlp_i2c_readb(I2C_BUS_1, CPUCPLD, 0x00, DEFAULT_FLAG); + swpld1_version = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, 0x27, DEFAULT_FLAG); + swpld2_version = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, 0x01, DEFAULT_FLAG); + swpld3_version = onlp_i2c_readb(I2C_BUS_1, SWPLD_3_ADDR, 0x01, DEFAULT_FLAG); + + pi->cpld_versions = aim_fstrdup("%d , SWPLD1_Versions: %d , SWPLD2_Versions: %d , SWPLD3_Versions: %d", cpld_version, swpld1_version, swpld2_version, swpld3_version); + + return ONLP_STATUS_OK; +} + +void +onlp_sysi_onie_data_free(uint8_t* data) +{ + aim_free(data); +} + +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) +{ + int i = 0; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return ONLP_STATUS_OK; +} + + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..55cf22bc --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,157 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include "platform_lib.h" +#include +#include +#include "x86_64_delta_ag9032v2_log.h" + + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define dni_onlp_thermal_threshold(WARNING_DEFAULT, ERROR_DEFAULT, SHUTDOWN_DEFAULT){ \ + WARNING_DEFAULT, \ + ERROR_DEFAULT, \ + SHUTDOWN_DEFAULT, \ +} + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input", + "/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp4_input", + "/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp8_input", + "/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp10_input", + "/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp14_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "CPU below side thermal sensor (U12, Below of CPU)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Wind thermal sensor (U334, Near FAN)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "MAC up side thermal sersor (U38, up side of MAC)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "MAC down side thermal sensor (U40, down side of MAC)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(60000,70000,75000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Surroundings thermal sensor (U240, Near front panel)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_7_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + uint8_t local_id = 0; + UINT4 multiplier = 1000; + UINT4 u4Data = 0; + char device_buf[20] = {0}; + int rv; + + VALIDATE(id); + local_id = ONLP_OID_ID_GET(id); + *info = linfo[ONLP_OID_ID_GET(id)]; + if(local_id == THERMAL_CPU_CORE) { + rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + switch(local_id) + { + case THERMAL_1_ON_CPU_BOARD: + case THERMAL_2_ON_FAN_BOARD: + case THERMAL_3_ON_MAIN_BOARD: + case THERMAL_4_ON_MAIN_BOARD: + case THERMAL_5_ON_MAIN_BOARD: + sprintf(device_buf, "Sensor_Temp_%d", local_id-1); + rv = dni_get_bmc_data(device_buf, &u4Data, multiplier); + break; + case THERMAL_6_ON_PSU1: + sprintf(device_buf, "PSU1_Temp_1"); + rv = dni_get_bmc_data(device_buf, &u4Data, multiplier); + break; + case THERMAL_7_ON_PSU2: + sprintf(device_buf, "PSU2_Temp_1"); + rv = dni_get_bmc_data(device_buf, &u4Data, multiplier); + break; + default: + AIM_LOG_ERROR("Invalid Thermal ID!!\n"); + return ONLP_STATUS_E_PARAM; + } + + if (u4Data == 0 || rv == ONLP_STATUS_E_GENERIC){ + return ONLP_STATUS_E_INTERNAL; + } + else{ + info->mcelsius = u4Data; + return 0; + } +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c new file mode 100644 index 00000000..95a5a6d2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(_x) __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(_x) +x86_64_delta_ag9032v2_config_settings_t x86_64_delta_ag9032v2_config_settings[] = +{ +#ifdef X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE +#undef __x86_64_delta_ag9032v2_config_STRINGIFY_NAME + +const char* +x86_64_delta_ag9032v2_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_delta_ag9032v2_config_settings[i].name; i++) { + if(strcmp(x86_64_delta_ag9032v2_config_settings[i].name, setting)) { + return x86_64_delta_ag9032v2_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_delta_ag9032v2_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_delta_ag9032v2_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_delta_ag9032v2_config_settings[i].name, x86_64_delta_ag9032v2_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_enums.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_enums.c new file mode 100644 index 00000000..56e964e0 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_int.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_int.h new file mode 100644 index 00000000..7864e778 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_delta_ag9032v2 Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_delta_ag9032v2_INT_H__ +#define __x86_64_delta_ag9032v2_INT_H__ + +#include + + +#endif /* __x86_64_delta_ag9032v2_INT_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.c new file mode 100644 index 00000000..3fe1b17e --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_delta_ag9032v2_log.h" +/* + * x86_64_delta_ag9032v2 log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.h new file mode 100644 index 00000000..2e613394 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_delta_ag9032v2_LOG_H__ +#define __x86_64_delta_ag9032v2_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_delta_ag9032v2 +#include + +#endif /* __x86_64_delta_ag9032v2_LOG_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_module.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_module.c new file mode 100644 index 00000000..1226a9bb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_delta_ag9032v2_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_delta_ag9032v2_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_delta_ag9032v2_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_ucli.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_ucli.c new file mode 100644 index 00000000..89afa88a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_delta_ag9032v2_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_delta_ag9032v2) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_delta_ag9032v2_ucli_module__ = + { + "x86_64_delta_ag9032v2_ucli", + NULL, + x86_64_delta_ag9032v2_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_delta_ag9032v2_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_delta_ag9032v2_ucli_module__); + n = ucli_node_create("x86_64_delta_ag9032v2", NULL, &x86_64_delta_ag9032v2_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_delta_ag9032v2")); + return n; +} + +#else +void* +x86_64_delta_ag9032v2_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/PKG.yml new file mode 100644 index 00000000..e1004778 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-ag9032v2 REVISION=r0 + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/lib/x86-64-delta-ag9032v2-r0.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/lib/x86-64-delta-ag9032v2-r0.yml new file mode 100644 index 00000000..aebd2cb2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/lib/x86-64-delta-ag9032v2-r0.yml @@ -0,0 +1,30 @@ +--- + +###################################################################### +# +# platform-config for AG9032V2 +# +###################################################################### + +x86-64-delta-ag9032v2-r0: + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-4-9 + + args: >- + nopat + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/python/x86_64_delta_ag9032v2_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/python/x86_64_delta_ag9032v2_r0/__init__.py new file mode 100644 index 00000000..219b2e88 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/platform-config/r0/src/python/x86_64_delta_ag9032v2_r0/__init__.py @@ -0,0 +1,18 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_x86_64_delta_ag9032v2_r0(OnlPlatformDelta, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-delta-ag9032v2-r0' + MODEL="AG9032V2" + SYS_OBJECT_ID=".9032.2" + + + def baseconfig(self): + + #IDEEPROM modulize + self.new_i2c_device('24c02', 0x53, 1) + + return True + + From dfb665dd3e2acb668f86c63f5bce31fc4d215143 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Mon, 15 Jan 2018 15:00:55 +0800 Subject: [PATCH 123/244] [as5712-54x] Add support for OOM driver --- .../builds/x86-64-accton-as5712-54x-cpld.c | 1154 ++++++++-- .../builds/x86-64-accton-as5712-54x-fan.c | 13 +- .../builds/x86-64-accton-as5712-54x-leds.c | 12 +- .../builds/x86-64-accton-as5712-54x-psu.c | 21 +- .../builds/x86-64-accton-as5712-54x-sfp.c | 1882 ----------------- .../onlp/builds/src/module/src/sfpi.c | 214 +- .../x86_64_accton_as5712_54x_r0/__init__.py | 24 +- 7 files changed, 1110 insertions(+), 2210 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c index ad09168d..244ed40b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c @@ -32,31 +32,13 @@ #include #include #include -#include #include +#include +#include +#include -static struct dmi_system_id as5712_dmi_table[] = { - { - .ident = "Accton AS5712", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS5712"), - }, - }, - { - .ident = "Accton AS5712", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS5712"), - }, - }, -}; - -int platform_accton_as5712_54x(void) -{ - return dmi_check_system(as5712_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as5712_54x); +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x18 @@ -64,10 +46,6 @@ EXPORT_SYMBOL(platform_accton_as5712_54x); #define CPLD_CHANNEL_SELECT_REG 0x2 #define CPLD_DESELECT_CHANNEL 0xFF -#if 0 -#define NUM_OF_ALL_CPLD_CHANS (NUM_OF_CPLD2_CHANS + NUM_OF_CPLD3_CHANS) -#endif - #define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS static LIST_HEAD(cpld_client_list); @@ -84,19 +62,14 @@ enum cpld_mux_type { as5712_54x_cpld1 }; -struct accton_i2c_cpld_mux { +struct as5712_54x_cpld_data { enum cpld_mux_type type; struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; u8 last_chan; /* last register value */ -}; -#if 0 -/* The mapping table between mux index and adapter index - array index : the mux index - the content : adapter index - */ -static int mux_adap_map[NUM_OF_ALL_CPLD_CHANS]; -#endif + struct device *hwmon_dev; + struct mutex update_lock; +}; struct chip_desc { u8 nchans; @@ -119,45 +92,835 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { +static const struct i2c_device_id as5712_54x_cpld_mux_id[] = { { "as5712_54x_cpld1", as5712_54x_cpld1 }, { "as5712_54x_cpld2", as5712_54x_cpld2 }, { "as5712_54x_cpld3", as5712_54x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); +MODULE_DEVICE_TABLE(i2c, as5712_54x_cpld_mux_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5712_54x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5712_54x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5712_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5712_54x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5712_54x_cpld1_group = { + .attrs = as5712_54x_cpld1_attributes, +}; + +static struct attribute *as5712_54x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5712_54x_cpld2_group = { + .attrs = as5712_54x_cpld2_attributes, +}; + +static struct attribute *as5712_54x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5712_54x_cpld3_group = { + .attrs = as5712_54x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x6, 0x7, 0x8, 0x14}; + struct i2c_client *client = to_i2c_client(dev); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5712_54x_cpld2) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5712_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 54 in order */ + if (data->type == as5712_54x_cpld2) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5712_54x_cpld3 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0xF, 0x10, 0x11}; + struct i2c_client *client = to_i2c_client(dev); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5712_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5712_54x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49: + reg = 0x14; + mask = 0x1; + break; + case MODULE_PRESENT_50: + reg = 0x14; + mask = 0x4; + break; + case MODULE_PRESENT_51: + reg = 0x14; + mask = 0x10; + break; + case MODULE_PRESENT_52: + reg = 0x14; + mask = 0x2; + break; + case MODULE_PRESENT_53: + reg = 0x14; + mask = 0x8; + break; + case MODULE_PRESENT_54: + reg = 0x14; + mask = 0x20; + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5712_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5712_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5712_54x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5712_54x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, +static int as5712_54x_cpld_mux_reg_write(struct i2c_adapter *adap, struct i2c_client *client, u8 val) { -#if 0 - int ret = -ENODEV; - - //if (adap->algo->master_xfer) { - if (0) - struct i2c_msg msg; - char buf[2]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - buf[0] = 0x2; - buf[1] = val; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } - else { - union i2c_smbus_data data; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - 0x2, I2C_SMBUS_BYTE, &data); - } - - return ret; -#else unsigned long orig_jiffies; unsigned short flags; union i2c_smbus_data data; @@ -184,38 +947,37 @@ static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, } return res; -#endif } -static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, +static int as5712_54x_cpld_mux_select_chan(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); u8 regval; int ret = 0; regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); + ret = as5712_54x_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int as5712_54x_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); + return as5712_54x_cpld_mux_reg_write(adap, client, data->last_chan); } -static void accton_i2c_cpld_add_client(struct i2c_client *client) +static void as5712_54x_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -231,7 +993,7 @@ static void accton_i2c_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void accton_i2c_cpld_remove_client(struct i2c_client *client) +static void as5712_54x_cpld_remove_client(struct i2c_client *client) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -257,125 +1019,178 @@ static void accton_i2c_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) { - u8 reg = 0x1; - struct i2c_client *client; - int len; + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); - client = to_i2c_client(dev); - len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); - - return len; + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); } -static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); - /* * I2C init/probing/exit functions */ -static int accton_i2c_cpld_mux_probe(struct i2c_client *client, +static int as5712_54x_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct accton_i2c_cpld_mux *data; + struct as5712_54x_cpld_data *data; int ret = -ENODEV; + const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; + goto exit; - data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); + data = kzalloc(sizeof(struct as5712_54x_cpld_data), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto err; + goto exit; } i2c_set_clientdata(client, data); - -#if 0 - /* Write the mux register at addr to verify - * that the mux is in fact present. - */ - if (i2c_smbus_write_byte(client, 0) < 0) { - dev_warn(&client->dev, "probe failed\n"); - goto exit_free; - } -#endif - + mutex_init(&data->update_lock); data->type = id->driver_data; if (data->type == as5712_54x_cpld2 || data->type == as5712_54x_cpld3) { data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ - for (chan = 0; chan < chips[data->type].nchans; chan++) { -#if 0 - int idx; -#endif - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) - I2C_CLASS_HWMON | I2C_CLASS_SPD, -#endif - accton_i2c_cpld_mux_select_chan, - accton_i2c_cpld_mux_deselect_mux); + /* Now create an adapter for each channel */ + for (chan = 0; chan < chips[data->type].nchans; chan++) { + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, + as5712_54x_cpld_mux_select_chan, + as5712_54x_cpld_mux_deselect_mux); - if (data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto virt_reg_failed; + if (data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); + goto exit_mux_register; + } } -#if 0 - idx = (data->type - as5712_54x_cpld2) * NUM_OF_CPLD2_CHANS + chan; - mux_adap_map[idx] = data->virt_adaps[chan]->nr; -#endif + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); } - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); + /* Register sysfs hooks */ + switch (data->type) { + case as5712_54x_cpld1: + group = &as5712_54x_cpld1_group; + break; + case as5712_54x_cpld2: + group = &as5712_54x_cpld2_group; + break; + case as5712_54x_cpld3: + group = &as5712_54x_cpld3_group; + break; + default: + break; } - accton_i2c_cpld_add_client(client); + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_mux_register; + } + } - ret = sysfs_create_file(&client->dev.kobj, &ver.attr); - if (ret) - goto virt_reg_failed; + as5712_54x_cpld_add_client(client); return 0; -virt_reg_failed: +exit_mux_register: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); } - - kfree(data); -err: + kfree(data); +exit: return ret; } -static int accton_i2c_cpld_mux_remove(struct i2c_client *client) +static int as5712_54x_cpld_mux_remove(struct i2c_client *client) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); const struct chip_desc *chip = &chips[data->type]; int chan; + const struct attribute_group *group = NULL; - sysfs_remove_file(&client->dev.kobj, &ver.attr); + as5712_54x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5712_54x_cpld1: + group = &as5712_54x_cpld1_group; + break; + case as5712_54x_cpld2: + group = &as5712_54x_cpld2_group; + break; + case as5712_54x_cpld3: + group = &as5712_54x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } for (chan = 0; chan < chip->nchans; ++chan) { - if (data->virt_adaps[chan]) { - i2c_del_mux_adapter(data->virt_adaps[chan]); - data->virt_adaps[chan] = NULL; - } + if (data->virt_adaps[chan]) { + i2c_del_mux_adapter(data->virt_adaps[chan]); + data->virt_adaps[chan] = NULL; + } } kfree(data); - accton_i2c_cpld_remove_client(client); return 0; } -int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) +static int as5712_54x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5712_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -385,21 +1200,21 @@ int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = as5712_54x_cpld_read_internal(cpld_node->client, reg); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5712_54x_i2c_cpld_read); +EXPORT_SYMBOL(as5712_54x_cpld_read); -int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -409,60 +1224,45 @@ int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = as5712_54x_cpld_write_internal(cpld_node->client, reg, value); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5712_54x_i2c_cpld_write); +EXPORT_SYMBOL(as5712_54x_cpld_write); -#if 0 -int accton_i2c_cpld_mux_get_index(int adap_index) -{ - int i; - - for (i = 0; i < NUM_OF_ALL_CPLD_CHANS; i++) { - if (mux_adap_map[i] == adap_index) { - return i; - } - } - - return -EINVAL; -} -EXPORT_SYMBOL(accton_i2c_cpld_mux_get_index); -#endif - -static struct i2c_driver accton_i2c_cpld_mux_driver = { +static struct i2c_driver as5712_54x_cpld_mux_driver = { .driver = { .name = "as5712_54x_cpld", .owner = THIS_MODULE, }, - .probe = accton_i2c_cpld_mux_probe, - .remove = accton_i2c_cpld_mux_remove, - .id_table = accton_i2c_cpld_mux_id, + .probe = as5712_54x_cpld_mux_probe, + .remove = as5712_54x_cpld_mux_remove, + .id_table = as5712_54x_cpld_mux_id, }; -static int __init accton_i2c_cpld_mux_init(void) +static int __init as5712_54x_cpld_mux_init(void) { mutex_init(&list_lock); - return i2c_add_driver(&accton_i2c_cpld_mux_driver); + return i2c_add_driver(&as5712_54x_cpld_mux_driver); } -static void __exit accton_i2c_cpld_mux_exit(void) +static void __exit as5712_54x_cpld_mux_exit(void) { - i2c_del_driver(&accton_i2c_cpld_mux_driver); + i2c_del_driver(&as5712_54x_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(accton_i2c_cpld_mux_init); -module_exit(accton_i2c_cpld_mux_exit); +module_init(as5712_54x_cpld_mux_init); +module_exit(as5712_54x_cpld_mux_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c index d6ffe7b6..db81a1a8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c @@ -131,8 +131,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as5712_54x_fan_group = { static int accton_as5712_54x_fan_read_value(u8 reg) { - return as5712_54x_i2c_cpld_read(0x60, reg); + return as5712_54x_cpld_read(0x60, reg); } static int accton_as5712_54x_fan_write_value(u8 reg, u8 value) { - return as5712_54x_i2c_cpld_write(0x60, reg, value); + return as5712_54x_cpld_write(0x60, reg, value); } static void accton_as5712_54x_fan_update_device(struct device *dev) @@ -394,11 +394,6 @@ static int __init accton_as5712_54x_fan_init(void) { int ret; - extern int platform_accton_as5712_54x(void); - if(!platform_accton_as5712_54x()) { - return -ENODEV; - } - ret = platform_driver_register(&accton_as5712_54x_fan_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c index cf8868e5..36704987 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as5712_54x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5712_54x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -220,12 +220,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5712_54x_led_read_value(u8 reg) { - return as5712_54x_i2c_cpld_read(0x60, reg); + return as5712_54x_cpld_read(0x60, reg); } static int accton_as5712_54x_led_write_value(u8 reg, u8 value) { - return as5712_54x_i2c_cpld_write(0x60, reg, value); + return as5712_54x_cpld_write(0x60, reg, value); } static void accton_as5712_54x_led_update(void) @@ -552,10 +552,6 @@ static int __init accton_as5712_54x_led_init(void) { int ret; - extern int platform_accton_as5712_54x(void); - if(!platform_accton_as5712_54x()) { - return -ENODEV; - } ret = platform_driver_register(&accton_as5712_54x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c index 52269933..af0c0c01 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c @@ -43,7 +43,7 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5712_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg); static int as5712_54x_psu_model_name_get(struct device *dev); /* Addresses scanned @@ -329,7 +329,7 @@ static struct as5712_54x_psu_data *as5712_54x_psu_update_device(struct device *d /* Read psu status */ - status = as5712_54x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as5712_54x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -349,24 +349,9 @@ exit: return data; } -static int __init as5712_54x_psu_init(void) -{ - extern int platform_accton_as5712_54x(void); - if(!platform_accton_as5712_54x()) { - return -ENODEV; - } - return i2c_add_driver(&as5712_54x_psu_driver); -} - -static void __exit as5712_54x_psu_exit(void) -{ - i2c_del_driver(&as5712_54x_psu_driver); -} +module_i2c_driver(as5712_54x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5712_54x_psu driver"); MODULE_LICENSE("GPL"); -module_init(as5712_54x_psu_init); -module_exit(as5712_54x_psu_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c deleted file mode 100644 index 8202b39e..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c +++ /dev/null @@ -1,1882 +0,0 @@ -/* - * SFP driver for accton as5712_54x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5712_54x_sfp" - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_loss, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -/* The table maps active port to cpld port. - * Array index 0 is for active port 1, - * index 1 for active port 2, and so on. - * The array content implies cpld port index. - */ -static const u8 cpld_to_front_port_table[] = -{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 52, 50, 53, 51, 54}; -#define CPLD_PORT_TO_FRONT_PORT(port) (cpld_to_front_port_table[port]) - -enum port_numbers { -as5712_54x_port1, as5712_54x_port2, as5712_54x_port3, as5712_54x_port4, -as5712_54x_port5, as5712_54x_port6, as5712_54x_port7, as5712_54x_port8, -as5712_54x_port9, as5712_54x_port10, as5712_54x_port11, as5712_54x_port12, -as5712_54x_port13, as5712_54x_port14, as5712_54x_port15, as5712_54x_port16, -as5712_54x_port17, as5712_54x_port18, as5712_54x_port19, as5712_54x_port20, -as5712_54x_port21, as5712_54x_port22, as5712_54x_port23, as5712_54x_port24, -as5712_54x_port25, as5712_54x_port26, as5712_54x_port27, as5712_54x_port28, -as5712_54x_port29, as5712_54x_port30, as5712_54x_port31, as5712_54x_port32, -as5712_54x_port33, as5712_54x_port34, as5712_54x_port35, as5712_54x_port36, -as5712_54x_port37, as5712_54x_port38, as5712_54x_port39, as5712_54x_port40, -as5712_54x_port41, as5712_54x_port42, as5712_54x_port43, as5712_54x_port44, -as5712_54x_port45, as5712_54x_port46, as5712_54x_port47, as5712_54x_port48, -as5712_54x_port49, as5712_54x_port52, as5712_54x_port50, as5712_54x_port53, -as5712_54x_port51, as5712_54x_port54 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as5712_54x_port1), -I2C_DEV_ID(as5712_54x_port2), -I2C_DEV_ID(as5712_54x_port3), -I2C_DEV_ID(as5712_54x_port4), -I2C_DEV_ID(as5712_54x_port5), -I2C_DEV_ID(as5712_54x_port6), -I2C_DEV_ID(as5712_54x_port7), -I2C_DEV_ID(as5712_54x_port8), -I2C_DEV_ID(as5712_54x_port9), -I2C_DEV_ID(as5712_54x_port10), -I2C_DEV_ID(as5712_54x_port11), -I2C_DEV_ID(as5712_54x_port12), -I2C_DEV_ID(as5712_54x_port13), -I2C_DEV_ID(as5712_54x_port14), -I2C_DEV_ID(as5712_54x_port15), -I2C_DEV_ID(as5712_54x_port16), -I2C_DEV_ID(as5712_54x_port17), -I2C_DEV_ID(as5712_54x_port18), -I2C_DEV_ID(as5712_54x_port19), -I2C_DEV_ID(as5712_54x_port20), -I2C_DEV_ID(as5712_54x_port21), -I2C_DEV_ID(as5712_54x_port22), -I2C_DEV_ID(as5712_54x_port23), -I2C_DEV_ID(as5712_54x_port24), -I2C_DEV_ID(as5712_54x_port25), -I2C_DEV_ID(as5712_54x_port26), -I2C_DEV_ID(as5712_54x_port27), -I2C_DEV_ID(as5712_54x_port28), -I2C_DEV_ID(as5712_54x_port29), -I2C_DEV_ID(as5712_54x_port30), -I2C_DEV_ID(as5712_54x_port31), -I2C_DEV_ID(as5712_54x_port32), -I2C_DEV_ID(as5712_54x_port33), -I2C_DEV_ID(as5712_54x_port34), -I2C_DEV_ID(as5712_54x_port35), -I2C_DEV_ID(as5712_54x_port36), -I2C_DEV_ID(as5712_54x_port37), -I2C_DEV_ID(as5712_54x_port38), -I2C_DEV_ID(as5712_54x_port39), -I2C_DEV_ID(as5712_54x_port40), -I2C_DEV_ID(as5712_54x_port41), -I2C_DEV_ID(as5712_54x_port42), -I2C_DEV_ID(as5712_54x_port43), -I2C_DEV_ID(as5712_54x_port44), -I2C_DEV_ID(as5712_54x_port45), -I2C_DEV_ID(as5712_54x_port46), -I2C_DEV_ID(as5712_54x_port47), -I2C_DEV_ID(as5712_54x_port48), -I2C_DEV_ID(as5712_54x_port49), -I2C_DEV_ID(as5712_54x_port50), -I2C_DEV_ID(as5712_54x_port51), -I2C_DEV_ID(as5712_54x_port52), -I2C_DEV_ID(as5712_54x_port53), -I2C_DEV_ID(as5712_54x_port54), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -#if (MULTIPAGE_SUPPORT == 1) - struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ -#endif -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = 0x61+i; - reg = 0x6+j; - status = as5712_54x_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-54(QSFP port) */ - cpld_addr = 0x62; - reg = 0x14; - status = as5712_54x_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)status << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as5712_54x sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 9; j++) { - u8 reg; - unsigned short cpld_addr; - reg = 0x9+j; - cpld_addr = 0x61+i; - - status = as5712_54x_i2c_cpld_read(cpld_addr, reg); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = 0x61; - cpld_reg = 0xC + data->port / 8; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = 0x62; - cpld_reg = 0xC + (data->port - 24) / 8; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = as5712_54x_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - as5712_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; - return sprintf(buf, "%d", val); -} -/* Platform dependent --- */ - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* if SFP style, offset > 255, shift to i2c addr 0x51 */ - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - if (*offset > 255) { - /* like QSFP, but shifted to client[1] */ - *client = port_data->msa->ddm_client; - *offset -= 256; - } - } - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - if ((off + len) <= 256) return len; - /* if no pages needed, we're good */ - //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - - /* Check if ddm is supported */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF8472_DIAG_MON_TYPE_ADDR, 1); - if (status < 0) return status; /* error out (no module?) */ - if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { - if (off >= 256) return -EINVAL; - maxlen = 256 - off; - } - else { - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - -#if (MULTIPAGE_SUPPORT == 1) - msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); - if (!msa->ddm_client) { - dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); - status = -EADDRINUSE; - goto exit_eeprom; - } -#endif - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_eeprom: - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - /* Bring QSFPs out of reset */ - as5712_54x_i2c_cpld_write(0x62, 0x15, 0x3F); - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as5712_54x_port1 || dev_id->driver_data > as5712_54x_port54) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as5712_54x_port1 && dev_id->driver_data <= as5712_54x_port48) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - ret = sfp_msa_probe(client, dev_id, &data->msa); - } - else { /* as5712_54x_portsfp49 ~ as5712_54x_portsfp54 */ - data->driver_type = DRIVER_TYPE_QSFP; - ret = qsfp_probe(client, dev_id, &data->qsfp); - } - - if (ret < 0) { - goto exit_kfree_buf; - } - - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); -#if (MULTIPAGE_SUPPORT == 1) - i2c_unregister_device(data->ddm_client); -#endif - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) - kfree(data->writebuf); -#endif - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5712_54x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c index 560f5762..c44d8a38 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c @@ -24,20 +24,24 @@ * ***********************************************************/ #include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include #include -#include "platform_lib.h" +#include +#include "x86_64_accton_as5712_54x_int.h" +#include "x86_64_accton_as5712_54x_log.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; #define CPLD_MUX_BUS_START_INDEX 2 -static int front_port_to_cpld_mux_index(int port) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/0-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_present_all" +#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_rx_los_all" + +static int front_port_bus_index(int port) { int rport = 0; @@ -63,38 +67,6 @@ static int front_port_to_cpld_mux_index(int port) return (rport + CPLD_MUX_BUS_START_INDEX); } -static int -as5712_54x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8] = {0}; - *value = 0; - - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as5712_54x_sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - front_port_to_cpld_mux_index(port), addr, - node_name); - return sfp_node_path; -} - -static char* -as5712_54x_sfp_get_port_path(int port, char *node_name) -{ - return as5712_54x_sfp_get_port_path_addr(port, 50, node_name); -} - - /************************************************************ * * SFPI Entry Points @@ -203,10 +175,10 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as5712_54x_sfp_get_port_path(port, "sfp_is_present"); - - if (as5712_54x_sfp_node_read_int(path, &present, 1) != 0) { - AIM_LOG_INFO("Unable to read present status from port(%d)\r\n", port); + int addr = (port < 24) ? 61 : 62; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -217,29 +189,35 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[7]; - char* path; FILE* fp; - path = as5712_54x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); - + /* Read present status of port 0~23 */ + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD2."); return ONLP_STATUS_E_INTERNAL; } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); + + int count = fscanf(fp, "%x %x %x", bytes+0, bytes+1, bytes+2); fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { + if(count != 3) { /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD2."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Read present status of port 24~53 */ + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + count = fscanf(fp, "%x %x %x %x", bytes+3, bytes+4, bytes+5, bytes+6); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); return ONLP_STATUS_E_INTERNAL; } @@ -268,33 +246,39 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char* path; + uint32_t bytes[6]; + uint32_t *ptr = bytes; FILE* fp; - path = as5712_54x_sfp_get_port_path(0, "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 61; addr <= 62; addr++) { + if (addr == 61) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; @@ -315,18 +299,22 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as5712_54x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, front_port_bus_index(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -336,11 +324,26 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - char* path = as5712_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, front_port_bus_index(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); return ONLP_STATUS_E_INTERNAL; } @@ -350,28 +353,28 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } @@ -384,13 +387,13 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) return ONLP_STATUS_E_UNSUPPORTED; } + int addr = (port < 24) ? 61 : 62; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - char* path = as5712_54x_sfp_get_port_path(port, "sfp_tx_disable"); - - if (deviceNodeWriteInt(path, value, 0) != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -412,19 +415,18 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; - char* path = NULL; if (port < 0 || port >= 48) { return ONLP_STATUS_E_UNSUPPORTED; } + int addr = (port < 24) ? 61 : 62; + switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - path = as5712_54x_sfp_get_port_path(port, "sfp_rx_loss"); - - if (as5712_54x_sfp_node_read_int(path, value, 1) != 0) { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -436,9 +438,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - path = as5712_54x_sfp_get_port_path(port, "sfp_tx_fault"); - - if (as5712_54x_sfp_node_read_int(path, value, 1) != 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -450,9 +450,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - path = as5712_54x_sfp_get_port_path(port, "sfp_tx_disable"); - - if (as5712_54x_sfp_node_read_int(path, value, 0) != 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py index 810419ce..48c9970e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py @@ -9,9 +9,10 @@ class OnlPlatform_x86_64_accton_as5712_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5712.54" def baseconfig(self): + self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: self.insmod("x86-64-accton-as5712-54x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -25,15 +26,22 @@ class OnlPlatform_x86_64_accton_as5712_54x_r0(OnlPlatformAccton, ) # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5712_54x_port%d' % port, 0x50, port+1) + self.new_i2c_device('optoe2', 0x50, port+1) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) # Initialize QSFP devices - self.new_i2c_device('as5712_54x_port49', 0x50, 50) - self.new_i2c_device('as5712_54x_port52', 0x50, 51) - self.new_i2c_device('as5712_54x_port50', 0x50, 52) - self.new_i2c_device('as5712_54x_port53', 0x50, 53) - self.new_i2c_device('as5712_54x_port51', 0x50, 54) - self.new_i2c_device('as5712_54x_port54', 0x50, 55) + self.new_i2c_device('optoe1', 0x50, 50) + self.new_i2c_device('optoe1', 0x50, 51) + self.new_i2c_device('optoe1', 0x50, 52) + self.new_i2c_device('optoe1', 0x50, 53) + self.new_i2c_device('optoe1', 0x50, 54) + self.new_i2c_device('optoe1', 0x50, 55) + subprocess.call('echo port49 > /sys/bus/i2c/devices/50-0050/port_name', shell=True) + subprocess.call('echo port52 > /sys/bus/i2c/devices/51-0050/port_name', shell=True) + subprocess.call('echo port50 > /sys/bus/i2c/devices/52-0050/port_name', shell=True) + subprocess.call('echo port53 > /sys/bus/i2c/devices/53-0050/port_name', shell=True) + subprocess.call('echo port51 > /sys/bus/i2c/devices/54-0050/port_name', shell=True) + subprocess.call('echo port54 > /sys/bus/i2c/devices/55-0050/port_name', shell=True) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From 7b5466e0bf7b77a4c32daf7eeab3b43255f8b413 Mon Sep 17 00:00:00 2001 From: Stanley Chi Date: Tue, 16 Jan 2018 16:11:57 +0800 Subject: [PATCH 124/244] 1. Fix the wrong display value of PSU. 2. Modify psui.c for PSU status. 3. Modify ledi.c for fan tray led. Signed-off-by: Stanley Chi --- .../modules/builds/dni_ag9032v1_psu.c | 55 ++++++++++++------- .../onlp/builds/src/module/src/ledi.c | 52 ++++++++++++------ .../onlp/builds/src/module/src/psui.c | 50 ++++++++--------- 3 files changed, 93 insertions(+), 64 deletions(-) mode change 100644 => 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c mode change 100644 => 100755 packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c index 8a0da3c7..8a63c372 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/modules/builds/dni_ag9032v1_psu.c @@ -290,7 +290,6 @@ static int dps_800ab_16_d_write_word(struct i2c_client *client, u8 reg, \ client->flags |= I2C_CLIENT_PEC, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, &data); - } static int dps_800ab_16_d_read_block(struct i2c_client *client, u8 command, \ @@ -344,8 +343,8 @@ static struct dps_800ab_16_d_data *dps_800ab_16_d_update_device( \ {0x8b, &data->v_out}, {0x89, &data->i_in}, {0x8c, &data->i_out}, - {0x96, &data->p_out}, {0x97, &data->p_in}, + {0x96, &data->p_out}, {0x8d, &(data->temp_input[0])}, {0x8e, &(data->temp_input[1])}, {0x3b, &(data->fan_duty_cycle[0])}, @@ -357,6 +356,37 @@ static struct dps_800ab_16_d_data *dps_800ab_16_d_update_device( \ /* one milliseconds from now */ data->last_updated = jiffies + HZ / 1000; + data->v_in = 0; + data->v_out = 0; + data->i_in = 0; + data->i_out = 0; + data->p_in = 0; + data->p_out = 0; + data->temp_input[0] = 0; + data->temp_input[1] = 0; + data->fan_duty_cycle[0] = 0; + data->fan_speed[0] = 0; + data->mfr_model[0] = '\0'; + data->mfr_serial[0] = '\0'; + + command = 0x9a; /* PSU mfr_model */ + status = dps_800ab_16_d_read_block(client, command, + data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); + data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; + if (status < 0) { + dev_dbg(&client->dev, "reg %d, err %d\n", command, + status); + } + + command = 0x9e; /* PSU mfr_serial */ + status = dps_800ab_16_d_read_block(client, command, + data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); + data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; + if (status < 0) { + dev_dbg(&client->dev, "reg %d, err %d\n", command, + status); + } + for (i = 0; i < ARRAY_SIZE(regs_byte); i++) { status = dps_800ab_16_d_read_byte(client, regs_byte[i].reg); @@ -377,26 +407,9 @@ static struct dps_800ab_16_d_data *dps_800ab_16_d_update_device( \ } else { *(regs_word[i].value) = status; } - } + } + - command = 0x9a; /* PSU mfr_model */ - status = dps_800ab_16_d_read_block(client, command, - data->mfr_model, ARRAY_SIZE(data->mfr_model) - 1); - data->mfr_model[ARRAY_SIZE(data->mfr_model) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, - status); - } - - command = 0x9e; /* PSU mfr_serial */ - status = dps_800ab_16_d_read_block(client, command, - data->mfr_serial, ARRAY_SIZE(data->mfr_serial) - 1); - data->mfr_serial[ARRAY_SIZE(data->mfr_serial) - 1] = '\0'; - if (status < 0) { - dev_dbg(&client->dev, "reg %d, err %d\n", command, - status); - } - data->valid = 1; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c old mode 100644 new mode 100755 index e72f9ab5..4163b7de --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/ledi.c @@ -48,7 +48,7 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, @@ -173,11 +173,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x80) == 0x80) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_2: /* Select fan tray 2 */ @@ -189,11 +191,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x10) == 0x10) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x20) == 0x20) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_3: /* Select fan tray 3 */ @@ -205,11 +209,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x04) == 0x04) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x08) == 0x08) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_4: /* Select fan tray 4 */ @@ -221,11 +227,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x01) == 0x01) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x02) == 0x02) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_5: /* Select fan tray 5 */ @@ -237,11 +245,13 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { if((r_data & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; - else + else if((r_data & 0x80) == 0x80) info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; default: break; @@ -389,11 +399,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x40; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + 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); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_2: fan_tray_led_reg_value &= ~0x30; @@ -402,11 +414,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x10; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + 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); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_3: fan_tray_led_reg_value &= ~0x0c; @@ -415,11 +429,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x04; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + 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); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_4: fan_tray_led_reg_value &= ~0x03; @@ -428,11 +444,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_value |= 0x01; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); } - else + 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); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_5: fan_tray_led_reg_2_value &= ~0xC0; @@ -441,11 +459,13 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) fan_tray_led_reg_2_value |= 0x40; dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG_2, fan_tray_led_reg_2_value); } - else + 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); } + else + dni_lock_swpld_write_attribute(FAN_TRAY_LED_REG, fan_tray_led_reg_value); break; } return ONLP_STATUS_OK; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c old mode 100644 new mode 100755 index 9ab696b0..56fb5eda --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/psui.c @@ -76,13 +76,8 @@ dni_psu_info_get(onlp_psu_info_t* info) char val_char[16] = {'\0'}; char node_path[PSU_NODE_MAX_PATH_LEN] = {'\0'}; - /* Set capability - */ + /* Set capability */ info->caps |= ONLP_PSU_CAPS_AC; - - if (info->status & ONLP_PSU_STATUS_FAILED) { - return ONLP_STATUS_OK; - } /* Set the associated oid_table * Set PSU's fan and thermal to child OID @@ -170,7 +165,7 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) channel = PSU_I2C_SEL_PSU1_EEPROM; break; case PSU2_ID: - channel = PSU_I2C_SEL_PSU2_EEPROM; + channel = PSU_I2C_SEL_PSU2_EEPROM; break; default: break; @@ -185,32 +180,34 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) dev_info.offset = 0x00; /* In EEPROM address 0x00 */ dev_info.flags = DEFAULT_FLAG; - /* Check PSU is PRESENT or not - * Read PSU EEPROM 1 byte from adress 0x00 - * if not present, return Negative value. - */ - if(dni_i2c_lock_read(&mux_info, &dev_info) < 0) - { - /* Unable to read PSU(%d) node(psu_present) */ - return ONLP_STATUS_OK; - } else { - info->status |= ONLP_PSU_STATUS_PRESENT; - } - - /* Select PSU member */ + /* Select PSU member(channel) */ sprintf(channel_data, "%x", channel); dni_i2c_lock_write_attribute(NULL, channel_data, PSU_SELECT_MEMBER_PATH); + /* Check PSU have voltage input or not */ dni_psu_pmbus_info_get(index, "psu_v_in", &val); - if (val == 0) { - /* Unable to read PSU(%d) node(psu_power_good) */ - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; + + /* 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(&mux_info, &dev_info) < 0) + { + /* Unable to read PSU EEPROM */ + /* Able to read PSU VIN(psu_power_not_good) */ + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + else if(val == 0){ + /* 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(info); - return ret; } @@ -218,5 +215,4 @@ int onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) { return ONLP_STATUS_E_UNSUPPORTED; -} - +} \ No newline at end of file From 2a0c85cc3a9fb01f08ad26dbb021c6bd3c49829d Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 18 Jan 2018 13:51:23 +0800 Subject: [PATCH 125/244] [as7312-54x] Add support for OOM driver --- .../builds/x86-64-accton-as7312-54x-cpld.c | 1262 +++++++++-- .../builds/x86-64-accton-as7312-54x-fan.c | 20 +- .../builds/x86-64-accton-as7312-54x-leds.c | 13 +- .../builds/x86-64-accton-as7312-54x-psu.c | 22 +- .../builds/x86-64-accton-as7312-54x-sfp.c | 1884 ----------------- .../onlp/builds/src/module/src/sfpi.c | 254 ++- .../x86_64_accton_as7312_54x_r0/__init__.py | 76 +- 7 files changed, 1263 insertions(+), 2268 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c index 576d84e8..1937c196 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-cpld.c @@ -1,227 +1,1133 @@ /* - * A hwmon driver for the accton_i2c_cpld + * Copyright (C) Brandon Chuang * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as7312_54x CPLD1/CPLD2/CPLD3 * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. */ #include -#include +#include #include -#include -#include - -static struct dmi_system_id as7312_dmi_table[] = { - { - .ident = "Accton AS7312", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS7312"), - }, - } -}; - -int platform_accton_as7312_54x(void) -{ - return dmi_check_system(as7312_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as7312_54x); +#include +#include +#include +#include +#include +#include +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; +static struct mutex list_lock; struct cpld_client_node { - struct i2c_client *client; - struct list_head list; + struct i2c_client *client; + struct list_head list; }; -/* Addresses scanned for accton_i2c_cpld +enum cpld_type { + as7312_54x_cpld1, + as7312_54x_cpld2, + as7312_54x_cpld3 +}; + +struct as7312_54x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as7312_54x_cpld_id[] = { + { "as7312_54x_cpld1", as7312_54x_cpld1 }, + { "as7312_54x_cpld2", as7312_54x_cpld2 }, + { "as7312_54x_cpld3", as7312_54x_cpld3 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as7312_54x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as7312_54x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon */ -static const unsigned short normal_i2c[] = { 0x31, 0x35, 0x60, 0x62, 0x64, I2C_CLIENT_END }; +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7312_54x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7312_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); -static void accton_i2c_cpld_add_client(struct i2c_client *client) +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as7312_54x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7312_54x_cpld1_group = { + .attrs = as7312_54x_cpld1_attributes, +}; + +static struct attribute *as7312_54x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as7312_54x_cpld2_group = { + .attrs = as7312_54x_cpld2_attributes, +}; + +static struct attribute *as7312_54x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as7312_54x_cpld3_group = { + .attrs = as7312_54x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) { - struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x9, 0xA, 0xB, 0x18}; + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); - if (!node) { - dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); - return; - } + mutex_lock(&data->update_lock); - node->client = client; + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7312_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} + values[i] = ~(u8)status; + } -static void accton_i2c_cpld_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int found = 0; + mutex_unlock(&data->update_lock); - mutex_lock(&list_lock); + /* Return values 1 -> 54 in order */ + if (data->type == as7312_54x_cpld2) { + values[3] &= 0xF; + } + else { /* as7312_54x_cpld3 */ + values[3] &= 0x3; + } - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client == client) { - found = 1; - break; - } - } - - if (found) { - list_del(list_node); - kfree(cpld_node); - } - - mutex_unlock(&list_lock); -} - -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) -{ - u8 reg = 0x1; - struct i2c_client *client; - int len; - - client = to_i2c_client(dev); - len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); - - return len; -} - -static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); - -static int accton_i2c_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); - status = -EIO; - goto exit; - } - - dev_info(&client->dev, "chip found\n"); - accton_i2c_cpld_add_client(client); - - sysfs_create_file(&client->dev.kobj, &ver.attr); - return 0; + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); exit: + mutex_unlock(&data->update_lock); return status; } -static int accton_i2c_cpld_remove(struct i2c_client *client) +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) { - sysfs_remove_file(&client->dev.kobj, &ver.attr); - accton_i2c_cpld_remove_client(client); + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x12, 0x13, 0x14}; + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7312_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as7312_54x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49: + reg = 0x18; + mask = 0x1; + break; + case MODULE_PRESENT_50: + reg = 0x18; + mask = 0x2; + break; + case MODULE_PRESENT_51: + reg = 0x18; + mask = 0x4; + break; + case MODULE_PRESENT_52: + reg = 0x18; + mask = 0x8; + break; + case MODULE_PRESENT_53: + reg = 0x18; + mask = 0x1; + break; + case MODULE_PRESENT_54: + reg = 0x18; + mask = 0x2; + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x13; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x13; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as7312_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as7312_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as7312_54x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7312_54x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as7312_54x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7312_54x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as7312_54x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as7312_54x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as7312_54x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as7312_54x_cpld1: + group = &as7312_54x_cpld1_group; + break; + case as7312_54x_cpld2: + group = &as7312_54x_cpld2_group; + break; + case as7312_54x_cpld3: + group = &as7312_54x_cpld3_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as7312_54x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as7312_54x_cpld_remove(struct i2c_client *client) +{ + struct as7312_54x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as7312_54x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as7312_54x_cpld1: + group = &as7312_54x_cpld1_group; + break; + case as7312_54x_cpld2: + group = &as7312_54x_cpld2_group; + break; + case as7312_54x_cpld3: + group = &as7312_54x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); return 0; } -static const struct i2c_device_id accton_i2c_cpld_id[] = { - { "accton_i2c_cpld", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_id); +static int as7312_54x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; -static struct i2c_driver accton_i2c_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "accton_i2c_cpld", + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7312_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as7312_54x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7312_54x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7312_54x_cpld_read); + +int as7312_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7312_54x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7312_54x_cpld_write); + +static struct i2c_driver as7312_54x_cpld_driver = { + .driver = { + .name = "as7312_54x_cpld", + .owner = THIS_MODULE, }, - .probe = accton_i2c_cpld_probe, - .remove = accton_i2c_cpld_remove, - .id_table = accton_i2c_cpld_id, - .address_list = normal_i2c, + .probe = as7312_54x_cpld_probe, + .remove = as7312_54x_cpld_remove, + .id_table = as7312_54x_cpld_id, }; -int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) +static int __init as7312_54x_cpld_init(void) { - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as7312_54x_i2c_cpld_read); - -int as7312_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as7312_54x_i2c_cpld_write); - -static int __init accton_i2c_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&accton_i2c_cpld_driver); + mutex_init(&list_lock); + return i2c_add_driver(&as7312_54x_cpld_driver); } -static void __exit accton_i2c_cpld_exit(void) +static void __exit as7312_54x_cpld_exit(void) { - i2c_del_driver(&accton_i2c_cpld_driver); + i2c_del_driver(&as7312_54x_cpld_driver); } - MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton_i2c_cpld driver"); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); MODULE_LICENSE("GPL"); -module_init(accton_i2c_cpld_init); -module_exit(accton_i2c_cpld_exit); +module_init(as7312_54x_cpld_init); +module_exit(as7312_54x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-fan.c index 57544e44..bbafaf0c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-fan.c @@ -36,8 +36,6 @@ static struct as7312_54x_fan_data *as7312_54x_fan_update_device(struct device *d static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -extern int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as7312_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /* fan related data, the index should match sysfs_fan_attributes */ @@ -467,23 +465,7 @@ static struct i2c_driver as7312_54x_fan_driver = { .address_list = normal_i2c, }; -static int __init as7312_54x_fan_init(void) -{ - extern int platform_accton_as7312_54x(void); - if (!platform_accton_as7312_54x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7312_54x_fan_driver); -} - -static void __exit as7312_54x_fan_exit(void) -{ - i2c_del_driver(&as7312_54x_fan_driver); -} - -module_init(as7312_54x_fan_init); -module_exit(as7312_54x_fan_exit); +module_i2c_driver(as7312_54x_fan_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as7312_54x_fan driver"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-leds.c index 24117847..698a387d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-leds.c @@ -30,8 +30,8 @@ #include #include -extern int as7312_54x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as7312_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as7312_54x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7312_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -175,12 +175,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as7312_54x_led_read_value(u8 reg) { - return as7312_54x_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as7312_54x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as7312_54x_led_write_value(u8 reg, u8 value) { - return as7312_54x_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as7312_54x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as7312_54x_led_update(void) @@ -397,11 +397,6 @@ static int __init accton_as7312_54x_led_init(void) { int ret; - extern int platform_accton_as7312_54x(void); - if (!platform_accton_as7312_54x()) { - return -ENODEV; - } - ret = platform_driver_register(&accton_as7312_54x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-psu.c index 1358dc4c..760d6da5 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-psu.c @@ -37,7 +37,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as7312_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as7312_54x_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -234,7 +234,7 @@ static struct as7312_54x_psu_data *as7312_54x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as7312_54x update\n"); /* Read psu status */ - status = as7312_54x_i2c_cpld_read(0x60, 0x2); + status = as7312_54x_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); @@ -269,23 +269,7 @@ static struct as7312_54x_psu_data *as7312_54x_psu_update_device(struct device *d return data; } -static int __init as7312_54x_psu_init(void) -{ - extern int platform_accton_as7312_54x(void); - if (!platform_accton_as7312_54x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7312_54x_psu_driver); -} - -static void __exit as7312_54x_psu_exit(void) -{ - i2c_del_driver(&as7312_54x_psu_driver); -} - -module_init(as7312_54x_psu_init); -module_exit(as7312_54x_psu_exit); +module_i2c_driver(as7312_54x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as7312_54x_psu driver"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c deleted file mode 100644 index 89591201..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/modules/builds/x86-64-accton-as7312-54x-sfp.c +++ /dev/null @@ -1,1884 +0,0 @@ -/* - * SFP driver for accton as7312_54x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as7312_54x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) -#define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else -#define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -/* Platform dependent +++ */ -#define I2C_ADDR_CPLD1 0x60 -#define I2C_ADDR_CPLD2 0x62 -#define I2C_ADDR_CPLD3 0x64 -/* Platform dependent --- */ -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int as7312_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as7312_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as7312_54x_port1, as7312_54x_port2, as7312_54x_port3, as7312_54x_port4, -as7312_54x_port5, as7312_54x_port6, as7312_54x_port7, as7312_54x_port8, -as7312_54x_port9, as7312_54x_port10, as7312_54x_port11, as7312_54x_port12, -as7312_54x_port13, as7312_54x_port14, as7312_54x_port15, as7312_54x_port16, -as7312_54x_port17, as7312_54x_port18, as7312_54x_port19, as7312_54x_port20, -as7312_54x_port21, as7312_54x_port22, as7312_54x_port23, as7312_54x_port24, -as7312_54x_port25, as7312_54x_port26, as7312_54x_port27, as7312_54x_port28, -as7312_54x_port29, as7312_54x_port30, as7312_54x_port31, as7312_54x_port32, -as7312_54x_port33, as7312_54x_port34, as7312_54x_port35, as7312_54x_port36, -as7312_54x_port37, as7312_54x_port38, as7312_54x_port39, as7312_54x_port40, -as7312_54x_port41, as7312_54x_port42, as7312_54x_port43, as7312_54x_port44, -as7312_54x_port45, as7312_54x_port46, as7312_54x_port47, as7312_54x_port48, -as7312_54x_port49, as7312_54x_port52, as7312_54x_port50, as7312_54x_port53, -as7312_54x_port51, as7312_54x_port54 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as7312_54x_port1), -I2C_DEV_ID(as7312_54x_port2), -I2C_DEV_ID(as7312_54x_port3), -I2C_DEV_ID(as7312_54x_port4), -I2C_DEV_ID(as7312_54x_port5), -I2C_DEV_ID(as7312_54x_port6), -I2C_DEV_ID(as7312_54x_port7), -I2C_DEV_ID(as7312_54x_port8), -I2C_DEV_ID(as7312_54x_port9), -I2C_DEV_ID(as7312_54x_port10), -I2C_DEV_ID(as7312_54x_port11), -I2C_DEV_ID(as7312_54x_port12), -I2C_DEV_ID(as7312_54x_port13), -I2C_DEV_ID(as7312_54x_port14), -I2C_DEV_ID(as7312_54x_port15), -I2C_DEV_ID(as7312_54x_port16), -I2C_DEV_ID(as7312_54x_port17), -I2C_DEV_ID(as7312_54x_port18), -I2C_DEV_ID(as7312_54x_port19), -I2C_DEV_ID(as7312_54x_port20), -I2C_DEV_ID(as7312_54x_port21), -I2C_DEV_ID(as7312_54x_port22), -I2C_DEV_ID(as7312_54x_port23), -I2C_DEV_ID(as7312_54x_port24), -I2C_DEV_ID(as7312_54x_port25), -I2C_DEV_ID(as7312_54x_port26), -I2C_DEV_ID(as7312_54x_port27), -I2C_DEV_ID(as7312_54x_port28), -I2C_DEV_ID(as7312_54x_port29), -I2C_DEV_ID(as7312_54x_port30), -I2C_DEV_ID(as7312_54x_port31), -I2C_DEV_ID(as7312_54x_port32), -I2C_DEV_ID(as7312_54x_port33), -I2C_DEV_ID(as7312_54x_port34), -I2C_DEV_ID(as7312_54x_port35), -I2C_DEV_ID(as7312_54x_port36), -I2C_DEV_ID(as7312_54x_port37), -I2C_DEV_ID(as7312_54x_port38), -I2C_DEV_ID(as7312_54x_port39), -I2C_DEV_ID(as7312_54x_port40), -I2C_DEV_ID(as7312_54x_port41), -I2C_DEV_ID(as7312_54x_port42), -I2C_DEV_ID(as7312_54x_port43), -I2C_DEV_ID(as7312_54x_port44), -I2C_DEV_ID(as7312_54x_port45), -I2C_DEV_ID(as7312_54x_port46), -I2C_DEV_ID(as7312_54x_port47), -I2C_DEV_ID(as7312_54x_port48), -I2C_DEV_ID(as7312_54x_port49), -I2C_DEV_ID(as7312_54x_port50), -I2C_DEV_ID(as7312_54x_port51), -I2C_DEV_ID(as7312_54x_port52), -I2C_DEV_ID(as7312_54x_port53), -I2C_DEV_ID(as7312_54x_port54), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -#if (MULTIPAGE_SUPPORT == 1) - struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ -#endif -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = I2C_ADDR_CPLD2 + i*2; - reg = 0x9+j; - status = as7312_54x_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-52(QSFP port) */ - cpld_addr = I2C_ADDR_CPLD2; - reg = 0x18; - status = as7312_54x_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)(status & 0xF) << 48; - } - - /* Read present status of port 53-54(QSFP port) */ - cpld_addr = I2C_ADDR_CPLD3; - reg = 0x18; - status = as7312_54x_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)(status & 0x3) << 52; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as7312_54x sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 9; j++) { - u8 reg; - unsigned short cpld_addr; - reg = 0xc+j; - cpld_addr = I2C_ADDR_CPLD2 + i*2; - - status = as7312_54x_i2c_cpld_read(cpld_addr, reg); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = I2C_ADDR_CPLD2; - cpld_reg = 0xF + data->port / 8; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = I2C_ADDR_CPLD3; - cpld_reg = 0xF + (data->port - 24) / 8; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = as7312_54x_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - as7312_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* if SFP style, offset > 255, shift to i2c addr 0x51 */ - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - if (*offset > 255) { - /* like QSFP, but shifted to client[1] */ - *client = port_data->msa->ddm_client; - *offset -= 256; - } - } - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - if ((off + len) <= 256) return len; - /* if no pages needed, we're good */ - //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - - /* Check if ddm is supported */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF8472_DIAG_MON_TYPE_ADDR, 1); - if (status < 0) return status; /* error out (no module?) */ - if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { - if (off >= 256) return -EINVAL; - maxlen = 256 - off; - } - else { - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - -#if (MULTIPAGE_SUPPORT == 1) - msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); - if (!msa->ddm_client) { - dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); - status = -EADDRINUSE; - goto exit_eeprom; - } -#endif - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_eeprom: - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as7312_54x_port1 || dev_id->driver_data > as7312_54x_port54) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as7312_54x_port1 && dev_id->driver_data <= as7312_54x_port48) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - ret = sfp_msa_probe(client, dev_id, &data->msa); - } - else { /* as7312_54x_portsfp49 ~ as7312_54x_portsfp54 */ - data->driver_type = DRIVER_TYPE_QSFP; - ret = qsfp_probe(client, dev_id, &data->qsfp); - } - - if (ret < 0) { - goto exit_kfree_buf; - } - - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); -#if (MULTIPAGE_SUPPORT == 1) - i2c_unregister_device(data->ddm_client); -#endif - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) - kfree(data->writebuf); -#endif - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7312_54x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/sfpi.c index 8bc8a716..99877571 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/sfpi.c @@ -2,7 +2,7 @@ * * * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. + * Copyright 2013 Accton Technology Corporation. * * Licensed under the Eclipse Public License, Version 1.0 (the * "License"); you may not use this file except in compliance @@ -24,30 +24,21 @@ * ***********************************************************/ #include -#include -#include -#include "platform_lib.h" - +#include +#include +#include "x86_64_accton_as7312_54x_int.h" #include "x86_64_accton_as7312_54x_log.h" -#define NUM_OF_SFP_PORT 54 -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_BUS_INDEX(port) (port+18) +#define PORT_BUS_INDEX(port) (port+18) -static char* -sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - FRONT_PORT_BUS_INDEX(port), addr, node_name); - return sfp_node_path; -} - -static char* -sfp_get_port_path(int port, char *node_name) -{ - return sfp_get_port_path_addr(port, 50, node_name); -} +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/5-0062/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/6-0064/module_rx_los_all" /************************************************************ * @@ -57,7 +48,7 @@ sfp_get_port_path(int port, char *node_name) int onlp_sfpi_init(void) { - /* Called at initialization time */ + /* Called at initialization time */ return ONLP_STATUS_OK; } @@ -68,8 +59,8 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) * Ports {0, 54} */ int p; - - for(p = 0; p < NUM_OF_SFP_PORT; p++) { + + for(p = 0; p < 54; p++) { AIM_BITMAP_SET(bmap, p); } @@ -85,55 +76,68 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char *path = sfp_get_port_path(port, "sfp_is_present"); + int bus, addr; - if (onlp_file_read_int(&present, path) < 0) { + addr = (port < 24 || (port >= 48 && port <= 51)) ? 62 : 64; + bus = (addr == 62) ? 5 : 6; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } - + return present; } int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char* path; + uint32_t bytes[8], *ptr = NULL; FILE* fp; + int addr; - AIM_BITMAP_CLR_ALL(dst); + ptr = bytes; - path = sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + for (addr = 62; addr <= 64; addr+=2) { + /* Read present status of port 0~53 */ + char file[64] = {0}; + int bus = (addr == 62) ? 5 : 6; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + int count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Mask out non-existant QSFP ports */ - bytes[6] &= 0x3F; + bytes[3] &= 0xF; + bytes[7] &= 0x3; /* Convert to 64 bit integer in port order */ int i = 0; uint64_t presence_all = 0 ; - for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all |= bytes[7]; + presence_all <<= 4; + presence_all |= bytes[3]; + + for(i = 6; i >= 4; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + for(i = 2; i >= 0; i--) { presence_all <<= 8; presence_all |= bytes[i]; } @@ -151,32 +155,38 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[6]; - char* path; + uint32_t *ptr = bytes; FILE* fp; - path = sfp_get_port_path(0, "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 62; addr <= 64; addr+=2) { + if (addr == 62) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; @@ -195,50 +205,102 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); return ONLP_STATUS_E_INTERNAL; } return ONLP_STATUS_OK; } +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 62 : 64; + int bus = (addr == 62) ? 5 : 6; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - char* path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_write_integer(path, value) != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -260,16 +322,20 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; - char* path = NULL; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 62 : 64; + int bus = (addr == 62) ? 5 : 6; switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - path = sfp_get_port_path(port, "sfp_rx_los"); - - if (onlp_file_read_int(value, path) < 0) { - AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } else { @@ -280,9 +346,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - path = sfp_get_port_path(port, "sfp_tx_fault"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -294,9 +358,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -313,11 +375,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) return rv; } - int onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py index beae7266..50743ba6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/platform-config/r0/src/python/x86_64_accton_as7312_54x_r0/__init__.py @@ -9,8 +9,9 @@ class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".7312.54" def baseconfig(self): + self.insmod('optoe') self.insmod('ym2651y') - for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: self.insmod("x86-64-accton-as7312-54x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -31,9 +32,9 @@ class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, self.new_i2c_devices([ # initialize CPLD - ('accton_i2c_cpld', 0x60, 4), - ('accton_i2c_cpld', 0x62, 5), - ('accton_i2c_cpld', 0x64, 6), + ('as7312_54x_cpld1', 0x60, 4), + ('as7312_54x_cpld2', 0x62, 5), + ('as7312_54x_cpld3', 0x64, 6), ]) self.new_i2c_device('pca9548', 0x71, 0) @@ -67,63 +68,14 @@ class OnlPlatform_x86_64_accton_as7312_54x_r0(OnlPlatformAccton, ) # initialize QSFP port 1~54 - self.new_i2c_devices( - [ - ('as7312_54x_port1', 0x50, 18), - ('as7312_54x_port2', 0x50, 19), - ('as7312_54x_port3', 0x50, 20), - ('as7312_54x_port4', 0x50, 21), - ('as7312_54x_port5', 0x50, 22), - ('as7312_54x_port6', 0x50, 23), - ('as7312_54x_port7', 0x50, 24), - ('as7312_54x_port8', 0x50, 25), - ('as7312_54x_port9', 0x50, 26), - ('as7312_54x_port10', 0x50, 27), - ('as7312_54x_port11', 0x50, 28), - ('as7312_54x_port12', 0x50, 29), - ('as7312_54x_port13', 0x50, 30), - ('as7312_54x_port14', 0x50, 31), - ('as7312_54x_port15', 0x50, 32), - ('as7312_54x_port16', 0x50, 33), - ('as7312_54x_port17', 0x50, 34), - ('as7312_54x_port18', 0x50, 35), - ('as7312_54x_port19', 0x50, 36), - ('as7312_54x_port20', 0x50, 37), - ('as7312_54x_port21', 0x50, 38), - ('as7312_54x_port22', 0x50, 39), - ('as7312_54x_port23', 0x50, 40), - ('as7312_54x_port24', 0x50, 41), - ('as7312_54x_port25', 0x50, 42), - ('as7312_54x_port26', 0x50, 43), - ('as7312_54x_port27', 0x50, 44), - ('as7312_54x_port28', 0x50, 45), - ('as7312_54x_port29', 0x50, 46), - ('as7312_54x_port30', 0x50, 47), - ('as7312_54x_port31', 0x50, 48), - ('as7312_54x_port32', 0x50, 49), - ('as7312_54x_port33', 0x50, 50), - ('as7312_54x_port34', 0x50, 51), - ('as7312_54x_port35', 0x50, 52), - ('as7312_54x_port36', 0x50, 53), - ('as7312_54x_port37', 0x50, 54), - ('as7312_54x_port38', 0x50, 55), - ('as7312_54x_port39', 0x50, 56), - ('as7312_54x_port40', 0x50, 57), - ('as7312_54x_port41', 0x50, 58), - ('as7312_54x_port42', 0x50, 59), - ('as7312_54x_port43', 0x50, 60), - ('as7312_54x_port44', 0x50, 61), - ('as7312_54x_port45', 0x50, 62), - ('as7312_54x_port46', 0x50, 63), - ('as7312_54x_port47', 0x50, 64), - ('as7312_54x_port48', 0x50, 65), - ('as7312_54x_port49', 0x50, 66), - ('as7312_54x_port50', 0x50, 67), - ('as7312_54x_port51', 0x50, 68), - ('as7312_54x_port52', 0x50, 69), - ('as7312_54x_port53', 0x50, 70), - ('as7312_54x_port54', 0x50, 71), - ] - ) + for port in range(1, 49): + self.new_i2c_device('optoe2', 0x50, port+17) + + for port in range(49, 55): + self.new_i2c_device('optoe1', 0x50, port+17) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+17), shell=True) + self.new_i2c_device('24c02', 0x57, 1) return True From fafe32df3b9e465f93cb30cb1a4239f20f60ef09 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 19 Jan 2018 15:07:26 +0000 Subject: [PATCH 126/244] Add the option to configure groups. --- tools/onlrfs.py | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index 470d95aa..d08401aa 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -85,12 +85,34 @@ class OnlRfsSystemAdmin(object): self.chmod("go-wx", pf); self.chmod("go-wx", sf); + def groupadd(self, group, gid=None, unique=True, system=False, force=False, password=None): + args = [ 'groupadd' ] + if force: + args.append("--force") + if system: + args.append("--system") + if not unique: + args.append("--non-unique") + if password: + args = args + [ '--password', password ] + if gid: + args = args + [ '--gid', str(gid) ] + + args.append(group) + + onlu.execute(args, + chroot=self.chroot, + ex=OnlRfsError("Adding group '%s' failed." % group)) + + logger.info("added group %s", group) + def useradd(self, username, uid=None, gid=None, password=None, shell='/bin/bash', home=None, groups=None, sudo=False, deleteFirst=True): args = [ 'useradd', '--create-home' ] - if uid is not None: + if uid: args = args + [ '--non-unique', '--uid', str(uid) ] - if gid is not None: + + if gid: args = args + [ '--gid', str(gid) ] if password: @@ -100,14 +122,11 @@ class OnlRfsSystemAdmin(object): if shell: args = args + [ '--shell', shell ] - if gid: - args = args + [ '--gid', gid ] - if home: args = args + [ '--home', home ] if groups: - args = args + [ '--group', groups ] + args = args + [ '--groups', ','.join(groups) ] if deleteFirst: self.userdel(username) @@ -399,9 +418,12 @@ rm -f /usr/sbin/policy-rc.d onlu.execute(command, ex=OnlRfsError("Command '%s' failed." % command)) - for (user, values) in Configure.get('users', {}).iteritems(): - ua = OnlRfsSystemAdmin(dir_) + ua = OnlRfsSystemAdmin(dir_) + for (group, values) in Configure.get('groups', {}).iteritems(): + ua.groupadd(group=group, **values if values else {}) + + for (user, values) in Configure.get('users', {}).iteritems(): if user == 'root': if 'password' in values: ua.user_password_set(user, values['password']) From b97f1f743ff5bd32067a688687eb10849b27ecfa Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 19 Jan 2018 19:26:42 +0000 Subject: [PATCH 127/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 03cd2a46..dbd5b8a7 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 03cd2a4666ac46b68234b2a9976bcdfe30dfbb4a +Subproject commit dbd5b8a71ca995d3a15aa08b9bbcdc2fb891f9cf From 033587441edde22cce04e9227d6bcb0750c3cfef Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sat, 20 Jan 2018 19:20:23 +0000 Subject: [PATCH 128/244] The blkids must be walked prior to attempting to save the config partition (msdos only). --- .../all/vendor-config-onl/src/python/onl/install/BaseInstall.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py index 2ca43c17..10878bce 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py @@ -1035,6 +1035,7 @@ class UbootInstaller(SubprocessMixin, Base): self.log.info("found a disk with %d blocks", self.partedDevice.getLength()) + self.blkidParts = BlkidParser(log=self.log.getChild("blkid")) code = self.findMsdos() if code: return code From e129347af6f9d011ec3315e7510480a17e84db22 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 21 Jan 2018 19:09:06 +0000 Subject: [PATCH 129/244] Add an option to enable root accounts after filesystem creation This is a minor hack. The code should be rearranged to allow a more natural workflow to modify filesystems post-creation. --- tools/onlrfs.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index d08401aa..be2e198f 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -109,10 +109,10 @@ class OnlRfsSystemAdmin(object): def useradd(self, username, uid=None, gid=None, password=None, shell='/bin/bash', home=None, groups=None, sudo=False, deleteFirst=True): args = [ 'useradd', '--create-home' ] - if uid: + if uid is not None: args = args + [ '--non-unique', '--uid', str(uid) ] - if gid: + if gid is not None: args = args + [ '--gid', str(gid) ] if password: @@ -574,9 +574,30 @@ if __name__ == '__main__': ap.add_argument("--no-multistrap", action='store_true') ap.add_argument("--cpio") ap.add_argument("--squash") - + ap.add_argument("--enable-root") ops = ap.parse_args() + if ops.enable_root: + # + # Fixme -- this should all be rearranged to naturally support + # arbitrary filesystem modifications. + # + sa = OnlRfsSystemAdmin(ops.dir) + sa.user_password_set('root', ops.enable_root) + config = os.path.join(ops.dir, 'etc/ssh/sshd_config') + sa.chmod('a+rw', config) + lines = open(config).readlines() + with open(config, "w") as f: + for line in lines: + if line.startswith('PermitRootLogin'): + v = "Yes" + logger.info("Setting PermitRootLogin to %s" % v) + f.write('PermitRootLogin %s\n' % v) + else: + f.write(line) + sa.chmod('644', config) + sys.exit(0) + try: x = OnlRfsBuilder(ops.config, ops.arch) From 316351ce1b856dbcc0592c9ca82ce0f8aee7e844 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 21 Jan 2018 20:04:07 +0000 Subject: [PATCH 130/244] Use ONL relative paths. --- tools/onlrfs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index be2e198f..96c4c2f5 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -615,7 +615,7 @@ if __name__ == '__main__': if not ops.no_build_packages: pkgs = x.get_packages() # Invoke onlpm to build all required (local) packages. - onlu.execute("onlpm --try-arches %s all --skip-missing --require %s" % (ops.arch, " ".join(pkgs)), + onlu.execute("%s/tools/onlpm.py --try-arches %s all --skip-missing --require %s" % (os.getenv('ONL'), ops.arch, " ".join(pkgs)), ex=OnlRfsError("Failed to build all required packages.")) if ops.only_build_packages: sys.exit(0) @@ -630,7 +630,7 @@ if __name__ == '__main__': x.configure(ops.dir) if ops.cpio: - if onlu.execute("make-cpio.sh %s %s" % (ops.dir, ops.cpio)) != 0: + if onlu.execute("%s/tools/scripts/make-cpio.sh %s %s" % (os.getenv('ONL'), ops.dir, ops.cpio)) != 0: raise OnlRfsError("cpio creation failed.") if ops.squash: From d570011c62dac9844c80af8f5e0f8777d572f5ea Mon Sep 17 00:00:00 2001 From: Wilson Ng Date: Mon, 22 Jan 2018 19:08:26 -0800 Subject: [PATCH 131/244] Add setters and getters for dns server and domain in OnlBootConfig. --- .../src/python/onl/bootconfig/__init__.py | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py index 2f0e3518..a9f86293 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py @@ -111,6 +111,8 @@ class OnlBootConfigNet(OnlBootConfig): self.delete('NETIP') self.delete('NETMASK') self.delete('NETGW') + self.delete('NETDNS') + self.delete('NETDOMAIN') self.set('NETAUTO', 'dhcp') def netauto_get(self): @@ -137,13 +139,27 @@ class OnlBootConfigNet(OnlBootConfig): def netgw_get(self): return self.keys.get('NETGW', None) + def netdns_set(self, dns): + self.delete('NETAUTO') + self.keys['NETDNS'] = dns + + def netdns_get(self): + return self.keys.get('NETDNS', None) + + def netdomain_set(self, domain): + self.delete('NETAUTO') + self.keys['NETDOMAIN'] = domain + + def netdomain_get(self): + return self.keys.get('NETDOMAIN', None) + def __validate(self): if 'NETAUTO' not in self.keys: netip = self.keys.get('NETIP', None) if netip: if not self.is_ip_address(netip): - raise ValueError("NETIP=%s is not a valid ip-address" % (netup)) + raise ValueError("NETIP=%s is not a valid ip-address" % (netip)) elif self.NET_REQUIRED: raise ValueError("No IP configuration set for the management interface.") @@ -168,6 +184,11 @@ class OnlBootConfigNet(OnlBootConfig): elif netip or netmask or netgw: raise ValueError("Incomplete static network configuration. NETIP, NETMASK, and NETGW must all be set.") + netdns = self.keys.get('NETDNS', None) + if netdns: + if not self.is_ip_address(netdns): + raise ValueError("NETDNS=%s is not a valid ip-address" % (netdns)) + elif self.keys['NETAUTO'] not in ['dhcp', 'up']: raise ValueError("The NETAUTO value '%s' is invalid." % self.keys['NETAUTO']) elif self.keys['NETAUTO'] == 'up' and self.NET_REQUIRED: @@ -214,7 +235,8 @@ class OnlBootConfigNet(OnlBootConfig): ap.add_argument("--ip", help='Set static IP address for the management interface.', type=OnlBootConfigNet.argparse_type_is_ip_address) ap.add_argument("--netmask", help='Set the static netmask for the management interface.', type=OnlBootConfigNet.argparse_type_is_netmask) ap.add_argument("--gateway", help='Set the gateway address.', type=OnlBootConfigNet.argparse_type_is_ip_address) - + ap.add_argument("--dns", help='Set the dns server.', type=OnlBootConfigNet.argparse_type_is_ip_address) + ap.add_argument("--domain", help='Set the dns domain.') def __argparse_process(self, ops): if ops.dhcp: @@ -229,6 +251,12 @@ class OnlBootConfigNet(OnlBootConfig): if ops.gateway: self.netgw_set(ops.gateway) + if ops.dns: + self.netdns_set(ops.dns) + + if ops.domain: + self.netdomain_set(ops.domain) + if __name__ == '__main__': bc = OnlBootConfigNet() From 0e3976c12d155236e8508a12012bb7b8a23ef950 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 24 Jan 2018 14:51:57 +0800 Subject: [PATCH 132/244] [as6712-32x] Add support for OOM driver --- .../builds/x86-64-accton-as6712-32x-cpld.c | 570 ++++-- .../builds/x86-64-accton-as6712-32x-fan.c | 13 +- .../builds/x86-64-accton-as6712-32x-leds.c | 13 +- .../builds/x86-64-accton-as6712-32x-psu.c | 21 +- .../builds/x86-64-accton-as6712-32x-sfp.c | 1532 ----------------- .../onlp/builds/src/module/src/sfpi.c | 104 +- .../x86_64_accton_as6712_32x_r0/__init__.py | 8 +- 7 files changed, 491 insertions(+), 1770 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-cpld.c index d1c1892e..79798b4b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-cpld.c @@ -32,36 +32,20 @@ #include #include #include -#include #include +#include +#include +#include -static struct dmi_system_id as6712_dmi_table[] = { - { - .ident = "Accton AS6712", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS6712"), - }, - }, - { - .ident = "Accton AS6712", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS6712"), - }, - }, -}; - -int platform_accton_as6712_32x(void) -{ - return dmi_check_system(as6712_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as6712_32x); +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x10 #define NUM_OF_CPLD3_CHANS 0x10 -#define NUM_OF_ALL_CPLD_CHANS (NUM_OF_CPLD2_CHANS + NUM_OF_CPLD3_CHANS) +#define CPLD_CHANNEL_SELECT_REG 0x2 +#define CPLD_DESELECT_CHANNEL 0xFF + #define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS static LIST_HEAD(cpld_client_list); @@ -78,10 +62,13 @@ enum cpld_mux_type { as6712_32x_cpld1 }; -struct accton_i2c_cpld_mux { +struct as6712_32x_cpld_data { enum cpld_mux_type type; struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; u8 last_chan; /* last register value */ + + struct device *hwmon_dev; + struct mutex update_lock; }; struct chip_desc { @@ -105,53 +92,298 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { +static const struct i2c_device_id as6712_32x_cpld_mux_id[] = { { "as6712_32x_cpld1", as6712_32x_cpld1 }, { "as6712_32x_cpld2", as6712_32x_cpld2 }, { "as6712_32x_cpld3", as6712_32x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); +MODULE_DEVICE_TABLE(i2c, as6712_32x_cpld_mux_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as6712_32x_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as6712_32x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as6712_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); + +static struct attribute *as6712_32x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as6712_32x_cpld1_group = { + .attrs = as6712_32x_cpld1_attributes, +}; + +static struct attribute *as6712_32x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + NULL +}; + +static const struct attribute_group as6712_32x_cpld2_group = { + .attrs = as6712_32x_cpld2_attributes, +}; + +static struct attribute *as6712_32x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + NULL +}; + +static const struct attribute_group as6712_32x_cpld3_group = { + .attrs = as6712_32x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[2] = {0}; + u8 regs[] = {0xA, 0xB}; + struct i2c_client *client = to_i2c_client(dev); + struct as6712_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as6712_32x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x\n", values[0], values[1]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as6712_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + default: + return 0; + } + + mutex_lock(&data->update_lock); + status = as6712_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as6712_32x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as6712_32x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, +static int as6712_32x_cpld_mux_reg_write(struct i2c_adapter *adap, struct i2c_client *client, u8 val) { -#if 0 - int ret = -ENODEV; - - //if (adap->algo->master_xfer) { - if (0) - struct i2c_msg msg; - char buf[2]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - buf[0] = 0x2; - buf[1] = val; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } - else { - union i2c_smbus_data data; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - 0x2, I2C_SMBUS_BYTE, &data); - } - - return ret; -#else unsigned long orig_jiffies; - unsigned short flags; + unsigned short flags; union i2c_smbus_data data; int try; s32 res = -EIO; - data.byte = val; - flags = client->flags; + data.byte = val; + flags = client->flags; flags &= I2C_M_TEN | I2C_CLIENT_PEC; if (adap->algo->smbus_xfer) { @@ -159,49 +391,48 @@ static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, orig_jiffies = jiffies; for (res = 0, try = 0; try <= adap->retries; try++) { res = adap->algo->smbus_xfer(adap, client->addr, flags, - I2C_SMBUS_WRITE, 0x2, - I2C_SMBUS_BYTE_DATA, &data); + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); if (res != -EAGAIN) break; if (time_after(jiffies, - orig_jiffies + adap->timeout)) + orig_jiffies + adap->timeout)) break; } } - return res; -#endif + return res; } -static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, +static int as6712_32x_cpld_mux_select_chan(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as6712_32x_cpld_data *data = i2c_get_clientdata(client); u8 regval; int ret = 0; - regval = chan; + regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); + ret = as6712_32x_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int as6712_32x_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as6712_32x_cpld_data *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); + return as6712_32x_cpld_mux_reg_write(adap, client, data->last_chan); } -static void accton_i2c_cpld_add_client(struct i2c_client *client) +static void as6712_32x_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -217,9 +448,9 @@ static void accton_i2c_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void accton_i2c_cpld_remove_client(struct i2c_client *client) +static void as6712_32x_cpld_remove_client(struct i2c_client *client) { - struct list_head *list_node = NULL; + struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; int found = 0; @@ -243,101 +474,128 @@ static void accton_i2c_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) { - u8 reg = 0x1; - struct i2c_client *client; - int len; + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); - client = to_i2c_client(dev); - len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); - - return len; + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); } -static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); - /* * I2C init/probing/exit functions */ -static int accton_i2c_cpld_mux_probe(struct i2c_client *client, +static int as6712_32x_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct accton_i2c_cpld_mux *data; + struct as6712_32x_cpld_data *data; int ret = -ENODEV; + const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; + goto exit; - data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); + data = kzalloc(sizeof(struct as6712_32x_cpld_data), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto err; + goto exit; } i2c_set_clientdata(client, data); - -#if 0 - /* Write the mux register at addr to verify - * that the mux is in fact present. - */ - if (i2c_smbus_write_byte(client, 0) < 0) { - dev_warn(&client->dev, "probe failed\n"); - goto exit_free; - } -#endif - + mutex_init(&data->update_lock); data->type = id->driver_data; if (data->type == as6712_32x_cpld2 || data->type == as6712_32x_cpld3) { data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ + /* Now create an adapter for each channel */ for (chan = 0; chan < chips[data->type].nchans; chan++) { - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) - I2C_CLASS_HWMON | I2C_CLASS_SPD, -#endif - accton_i2c_cpld_mux_select_chan, - accton_i2c_cpld_mux_deselect_mux); + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, + as6712_32x_cpld_mux_select_chan, + as6712_32x_cpld_mux_deselect_mux); if (data->virt_adaps[chan] == NULL) { ret = -ENODEV; dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto virt_reg_failed; + goto exit_mux_register; } } - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); } - accton_i2c_cpld_add_client(client); + /* Register sysfs hooks */ + switch (data->type) { + case as6712_32x_cpld1: + group = &as6712_32x_cpld1_group; + break; + case as6712_32x_cpld2: + group = &as6712_32x_cpld2_group; + break; + case as6712_32x_cpld3: + group = &as6712_32x_cpld3_group; + break; + default: + break; + } - ret = sysfs_create_file(&client->dev.kobj, &ver.attr); - if (ret) - goto virt_reg_failed; + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_mux_register; + } + } + + as6712_32x_cpld_add_client(client); return 0; -virt_reg_failed: +exit_mux_register: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); } - kfree(data); -err: + kfree(data); +exit: return ret; -} +} -static int accton_i2c_cpld_mux_remove(struct i2c_client *client) +static int as6712_32x_cpld_mux_remove(struct i2c_client *client) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as6712_32x_cpld_data *data = i2c_get_clientdata(client); const struct chip_desc *chip = &chips[data->type]; int chan; + const struct attribute_group *group = NULL; - sysfs_remove_file(&client->dev.kobj, &ver.attr); + as6712_32x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as6712_32x_cpld1: + group = &as6712_32x_cpld1_group; + break; + case as6712_32x_cpld2: + group = &as6712_32x_cpld2_group; + break; + case as6712_32x_cpld3: + group = &as6712_32x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } for (chan = 0; chan < chip->nchans; ++chan) { if (data->virt_adaps[chan]) { @@ -347,12 +605,47 @@ static int accton_i2c_cpld_mux_remove(struct i2c_client *client) } kfree(data); - accton_i2c_cpld_remove_client(client); return 0; } -int as6712_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) +static int as6712_32x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as6712_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as6712_32x_cpld_read(unsigned short cpld_addr, u8 reg) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -365,8 +658,8 @@ int as6712_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) cpld_node = list_entry(list_node, struct cpld_client_node, list); if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; + ret = as6712_32x_cpld_read_internal(cpld_node->client, reg); + break; } } @@ -374,9 +667,9 @@ int as6712_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) return ret; } -EXPORT_SYMBOL(as6712_32x_i2c_cpld_read); +EXPORT_SYMBOL(as6712_32x_cpld_read); -int as6712_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +int as6712_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -389,8 +682,8 @@ int as6712_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) cpld_node = list_entry(list_node, struct cpld_client_node, list); if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; + ret = as6712_32x_cpld_write_internal(cpld_node->client, reg, value); + break; } } @@ -398,32 +691,33 @@ int as6712_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) return ret; } -EXPORT_SYMBOL(as6712_32x_i2c_cpld_write); +EXPORT_SYMBOL(as6712_32x_cpld_write); -static struct i2c_driver accton_i2c_cpld_mux_driver = { +static struct i2c_driver as6712_32x_cpld_mux_driver = { .driver = { .name = "as6712_32x_cpld", .owner = THIS_MODULE, }, - .probe = accton_i2c_cpld_mux_probe, - .remove = accton_i2c_cpld_mux_remove, - .id_table = accton_i2c_cpld_mux_id, + .probe = as6712_32x_cpld_mux_probe, + .remove = as6712_32x_cpld_mux_remove, + .id_table = as6712_32x_cpld_mux_id, }; -static int __init accton_i2c_cpld_mux_init(void) +static int __init as6712_32x_cpld_mux_init(void) { mutex_init(&list_lock); - return i2c_add_driver(&accton_i2c_cpld_mux_driver); + return i2c_add_driver(&as6712_32x_cpld_mux_driver); } -static void __exit accton_i2c_cpld_mux_exit(void) +static void __exit as6712_32x_cpld_mux_exit(void) { - i2c_del_driver(&accton_i2c_cpld_mux_driver); + i2c_del_driver(&as6712_32x_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(accton_i2c_cpld_mux_init); -module_exit(accton_i2c_cpld_mux_exit); +module_init(as6712_32x_cpld_mux_init); +module_exit(as6712_32x_cpld_mux_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c index 569cee05..1e980efe 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c @@ -138,8 +138,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as6712_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as6712_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as6712_32x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as6712_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as6712_32x_fan_group = { static int accton_as6712_32x_fan_read_value(u8 reg) { - return as6712_32x_i2c_cpld_read(0x60, reg); + return as6712_32x_cpld_read(0x60, reg); } static int accton_as6712_32x_fan_write_value(u8 reg, u8 value) { - return as6712_32x_i2c_cpld_write(0x60, reg, value); + return as6712_32x_cpld_write(0x60, reg, value); } static void accton_as6712_32x_fan_update_device(struct device *dev) @@ -396,11 +396,6 @@ static struct platform_driver accton_as6712_32x_fan_driver = { static int __init accton_as6712_32x_fan_init(void) { int ret; - - extern int platform_accton_as6712_32x(void); - if(!platform_accton_as6712_32x()) { - return -ENODEV; - } ret = platform_driver_register(&accton_as6712_32x_fan_driver); if (ret < 0) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-leds.c index ded3baca..2b45bc87 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as6712_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as6712_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as6712_32x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as6712_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -239,12 +239,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as6712_32x_led_read_value(u8 reg) { - return as6712_32x_i2c_cpld_read(0x60, reg); + return as6712_32x_cpld_read(0x60, reg); } static int accton_as6712_32x_led_write_value(u8 reg, u8 value) { - return as6712_32x_i2c_cpld_write(0x60, reg, value); + return as6712_32x_cpld_write(0x60, reg, value); } static void accton_as6712_32x_led_update(void) @@ -571,11 +571,6 @@ static int __init accton_as6712_32x_led_init(void) { int ret; - extern int platform_accton_as6712_32x(void); - if(!platform_accton_as6712_32x()) { - return -ENODEV; - } - ret = platform_driver_register(&accton_as6712_32x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-psu.c index 3c2b03a0..73f50acb 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-psu.c @@ -42,7 +42,7 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as6712_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as6712_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as6712_32x_cpld_read(unsigned short cpld_addr, u8 reg); static int as6712_32x_psu_model_name_get(struct device *dev); /* Addresses scanned @@ -336,7 +336,7 @@ static struct as6712_32x_psu_data *as6712_32x_psu_update_device(struct device *d data->valid = 0; /* Read psu status */ - status = as6712_32x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as6712_32x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -356,24 +356,9 @@ exit: return data; } -static int __init as6712_32x_psu_init(void) -{ - extern int platform_accton_as6712_32x(void); - if(!platform_accton_as6712_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as6712_32x_psu_driver); -} - -static void __exit as6712_32x_psu_exit(void) -{ - i2c_del_driver(&as6712_32x_psu_driver); -} +module_i2c_driver(as6712_32x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as6712_32x_psu driver"); MODULE_LICENSE("GPL"); -module_init(as6712_32x_psu_init); -module_exit(as6712_32x_psu_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c deleted file mode 100644 index 7f580a89..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-sfp.c +++ /dev/null @@ -1,1532 +0,0 @@ -/* - * SFP driver for accton as6712_32x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as6712_32x_sfp" - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 32 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int as6712_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as6712_32x_port1, as6712_32x_port2, as6712_32x_port3, as6712_32x_port4, as6712_32x_port5, as6712_32x_port6, as6712_32x_port7, as6712_32x_port8, -as6712_32x_port9, as6712_32x_port10, as6712_32x_port11, as6712_32x_port12, as6712_32x_port13, as6712_32x_port14, as6712_32x_port15, as6712_32x_port16, -as6712_32x_port17, as6712_32x_port18, as6712_32x_port19, as6712_32x_port20, as6712_32x_port21, as6712_32x_port22, as6712_32x_port23, as6712_32x_port24, -as6712_32x_port25, as6712_32x_port26, as6712_32x_port27, as6712_32x_port28, as6712_32x_port29, as6712_32x_port30, as6712_32x_port31, as6712_32x_port32 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as6712_32x_port1), -I2C_DEV_ID(as6712_32x_port2), -I2C_DEV_ID(as6712_32x_port3), -I2C_DEV_ID(as6712_32x_port4), -I2C_DEV_ID(as6712_32x_port5), -I2C_DEV_ID(as6712_32x_port6), -I2C_DEV_ID(as6712_32x_port7), -I2C_DEV_ID(as6712_32x_port8), -I2C_DEV_ID(as6712_32x_port9), -I2C_DEV_ID(as6712_32x_port10), -I2C_DEV_ID(as6712_32x_port11), -I2C_DEV_ID(as6712_32x_port12), -I2C_DEV_ID(as6712_32x_port13), -I2C_DEV_ID(as6712_32x_port14), -I2C_DEV_ID(as6712_32x_port15), -I2C_DEV_ID(as6712_32x_port16), -I2C_DEV_ID(as6712_32x_port17), -I2C_DEV_ID(as6712_32x_port18), -I2C_DEV_ID(as6712_32x_port19), -I2C_DEV_ID(as6712_32x_port20), -I2C_DEV_ID(as6712_32x_port21), -I2C_DEV_ID(as6712_32x_port22), -I2C_DEV_ID(as6712_32x_port23), -I2C_DEV_ID(as6712_32x_port24), -I2C_DEV_ID(as6712_32x_port25), -I2C_DEV_ID(as6712_32x_port26), -I2C_DEV_ID(as6712_32x_port27), -I2C_DEV_ID(as6712_32x_port28), -I2C_DEV_ID(as6712_32x_port29), -I2C_DEV_ID(as6712_32x_port30), -I2C_DEV_ID(as6712_32x_port31), -I2C_DEV_ID(as6712_32x_port32), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 1~32 */ - data->present = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - status = as6712_32x_i2c_cpld_read(0x62+i*2, 0xA+j); - - if (status < 0) { - DEBUG_PRINT("cpld(0x%x) reg(0x%x) err %d", 0x62+i*2, 0xA+j, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); - data->present |= (u64)status << ((i*16) + (j*8)); - } - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[4] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as6712_32x_port1 || dev_id->driver_data > as6712_32x_port32) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - data->driver_type = DRIVER_TYPE_QSFP; - - ret = qsfp_probe(client, dev_id, &data->qsfp); - if (ret < 0) { - goto exit_kfree_buf; - } - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); -#if (MULTIPAGE_SUPPORT == 1) - kfree(data->writebuf); -#endif - - if (data->driver_type == DRIVER_TYPE_QSFP) { - ret = qsfp_remove(client, data->qsfp); - } - - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as6712_32x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/sfpi.c index 36f2b772..82ca3e5f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/sfpi.c @@ -24,44 +24,17 @@ * ***********************************************************/ #include +#include +#include +#include "x86_64_accton_as6712_32x_int.h" +#include "x86_64_accton_as6712_32x_log.h" -#include /* For O_RDWR && open */ -#include -#include -#include -#include +#define PORT_BUS_INDEX(port) (port+2) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0062/module_present_all" +#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0064/module_present_all" -#include "platform_lib.h" - -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_TO_CPLD_MUX_INDEX(port) (port+2) - -static int -as6712_32x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8]; - *value = 0; - - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as6712_32x_sfp_get_port_path(int port, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", - FRONT_PORT_TO_CPLD_MUX_INDEX(port), - node_name); - - return sfp_node_path; -} /************************************************************ * @@ -100,9 +73,9 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as6712_32x_sfp_get_port_path(port, "sfp_is_present"); - - if (as6712_32x_sfp_node_read_int(path, &present, 1) != 0) { + int addr = (port < 16) ? 62 : 64; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -114,27 +87,34 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; - char* path; + uint32_t *ptr = bytes; FILE* fp; - path = as6712_32x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~31 */ + int addr; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 62; addr <= 64; addr+=2) { + if (addr == 62) { + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x", ptr+0, ptr+1); + fclose(fp); + if(count != 2) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_present_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ @@ -163,21 +143,25 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as6712_32x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py index 54bc68dc..dbff6437 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/platform-config/r0/src/python/x86_64_accton_as6712_32x_r0/__init__.py @@ -8,9 +8,10 @@ class OnlPlatform_x86_64_accton_as6712_32x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".6712.32" def baseconfig(self): + self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: self.insmod("x86-64-accton-as6712-32x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -25,9 +26,8 @@ class OnlPlatform_x86_64_accton_as6712_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 for port in range(1, 33): - self.new_i2c_device('as6712_32x_port%d' % port, - 0x50, - port+1) + self.new_i2c_device('optoe1', 0x50, port+1) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From 9c88e1d81dc46c0e99176f70c461623a1a6d557d Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Mon, 29 Jan 2018 15:05:00 +0800 Subject: [PATCH 133/244] [as5912-54x] Add support for OOM driver --- .../builds/x86-64-accton-as5912-54x-cpld.c | 1098 ++++++++++ .../builds/x86-64-accton-as5912-54x-leds.c | 8 +- .../builds/x86-64-accton-as5912-54x-psu.c | 4 +- .../builds/x86-64-accton-as5912-54x-sfp.c | 1874 ----------------- .../onlp/builds/src/module/src/sfpi.c | 218 +- .../x86_64_accton_as5912_54x_r0/__init__.py | 15 +- 6 files changed, 1239 insertions(+), 1978 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-cpld.c new file mode 100644 index 00000000..3c8d557c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-cpld.c @@ -0,0 +1,1098 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5912_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as5912_54x_cpld1, + as5912_54x_cpld2 +}; + +struct as5912_54x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as5912_54x_cpld_id[] = { + { "as5912_54x_cpld1", as5912_54x_cpld1 }, + { "as5912_54x_cpld2", as5912_54x_cpld2 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as5912_54x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5912_54x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5912_54x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5912_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5912_54x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5912_54x_cpld1_group = { + .attrs = as5912_54x_cpld1_attributes, +}; + +static struct attribute *as5912_54x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5912_54x_cpld2_group = { + .attrs = as5912_54x_cpld2_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x10, 0x11, 0x12, 0x52}; + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5912_54x_cpld1) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5912_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + if (data->type == as5912_54x_cpld1) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5912_54x_cpld2 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x30, 0x32, 0x34}; + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5912_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5912_54x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x52; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5912_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5912_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5912_54x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5912_54x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as5912_54x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5912_54x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as5912_54x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as5912_54x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as5912_54x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as5912_54x_cpld1: + group = &as5912_54x_cpld1_group; + break; + case as5912_54x_cpld2: + group = &as5912_54x_cpld2_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as5912_54x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as5912_54x_cpld_remove(struct i2c_client *client) +{ + struct as5912_54x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as5912_54x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5912_54x_cpld1: + group = &as5912_54x_cpld1_group; + break; + case as5912_54x_cpld2: + group = &as5912_54x_cpld2_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as5912_54x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5912_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5912_54x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5912_54x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5912_54x_cpld_read); + +int as5912_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5912_54x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5912_54x_cpld_write); + +static struct i2c_driver as5912_54x_cpld_driver = { + .driver = { + .name = "as5912_54x_cpld", + .owner = THIS_MODULE, + }, + .probe = as5912_54x_cpld_probe, + .remove = as5912_54x_cpld_remove, + .id_table = as5912_54x_cpld_id, +}; + +static int __init as5912_54x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5912_54x_cpld_driver); +} + +static void __exit as5912_54x_cpld_exit(void) +{ + i2c_del_driver(&as5912_54x_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as5912_54x_cpld_init); +module_exit(as5912_54x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-leds.c index 2c821d4d..8dbe1e64 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-leds.c @@ -38,8 +38,8 @@ #define DEBUG_PRINT(fmt, args...) #endif -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5912_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5912_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); struct accton_as5912_54x_led_data { struct platform_device *pdev; @@ -148,12 +148,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5912_54x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as5912_54x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as5912_54x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as5912_54x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as5912_54x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-psu.c index 0efa5b7e..def9b533 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-psu.c @@ -37,7 +37,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5912_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5912_54x_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -234,7 +234,7 @@ static struct as5912_54x_psu_data *as5912_54x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as5912_54x update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as5912_54x_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c deleted file mode 100644 index 2416142f..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/modules/builds/x86-64-accton-as5912-54x-sfp.c +++ /dev/null @@ -1,1874 +0,0 @@ -/* - * SFP driver for accton as5912_54x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5912_54x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - - -/* Platform dependent +++ */ -#define I2C_ADDR_CPLD1 0x60 -#define I2C_ADDR_CPLD2 0x62 -/* Platform dependent --- */ - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as5912_54x_port1, as5912_54x_port2, as5912_54x_port3, as5912_54x_port4, -as5912_54x_port5, as5912_54x_port6, as5912_54x_port7, as5912_54x_port8, -as5912_54x_port9, as5912_54x_port10, as5912_54x_port11, as5912_54x_port12, -as5912_54x_port13, as5912_54x_port14, as5912_54x_port15, as5912_54x_port16, -as5912_54x_port17, as5912_54x_port18, as5912_54x_port19, as5912_54x_port20, -as5912_54x_port21, as5912_54x_port22, as5912_54x_port23, as5912_54x_port24, -as5912_54x_port25, as5912_54x_port26, as5912_54x_port27, as5912_54x_port28, -as5912_54x_port29, as5912_54x_port30, as5912_54x_port31, as5912_54x_port32, -as5912_54x_port33, as5912_54x_port34, as5912_54x_port35, as5912_54x_port36, -as5912_54x_port37, as5912_54x_port38, as5912_54x_port39, as5912_54x_port40, -as5912_54x_port41, as5912_54x_port42, as5912_54x_port43, as5912_54x_port44, -as5912_54x_port45, as5912_54x_port46, as5912_54x_port47, as5912_54x_port48, -as5912_54x_port49, as5912_54x_port52, as5912_54x_port50, as5912_54x_port53, -as5912_54x_port51, as5912_54x_port54 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as5912_54x_port1), -I2C_DEV_ID(as5912_54x_port2), -I2C_DEV_ID(as5912_54x_port3), -I2C_DEV_ID(as5912_54x_port4), -I2C_DEV_ID(as5912_54x_port5), -I2C_DEV_ID(as5912_54x_port6), -I2C_DEV_ID(as5912_54x_port7), -I2C_DEV_ID(as5912_54x_port8), -I2C_DEV_ID(as5912_54x_port9), -I2C_DEV_ID(as5912_54x_port10), -I2C_DEV_ID(as5912_54x_port11), -I2C_DEV_ID(as5912_54x_port12), -I2C_DEV_ID(as5912_54x_port13), -I2C_DEV_ID(as5912_54x_port14), -I2C_DEV_ID(as5912_54x_port15), -I2C_DEV_ID(as5912_54x_port16), -I2C_DEV_ID(as5912_54x_port17), -I2C_DEV_ID(as5912_54x_port18), -I2C_DEV_ID(as5912_54x_port19), -I2C_DEV_ID(as5912_54x_port20), -I2C_DEV_ID(as5912_54x_port21), -I2C_DEV_ID(as5912_54x_port22), -I2C_DEV_ID(as5912_54x_port23), -I2C_DEV_ID(as5912_54x_port24), -I2C_DEV_ID(as5912_54x_port25), -I2C_DEV_ID(as5912_54x_port26), -I2C_DEV_ID(as5912_54x_port27), -I2C_DEV_ID(as5912_54x_port28), -I2C_DEV_ID(as5912_54x_port29), -I2C_DEV_ID(as5912_54x_port30), -I2C_DEV_ID(as5912_54x_port31), -I2C_DEV_ID(as5912_54x_port32), -I2C_DEV_ID(as5912_54x_port33), -I2C_DEV_ID(as5912_54x_port34), -I2C_DEV_ID(as5912_54x_port35), -I2C_DEV_ID(as5912_54x_port36), -I2C_DEV_ID(as5912_54x_port37), -I2C_DEV_ID(as5912_54x_port38), -I2C_DEV_ID(as5912_54x_port39), -I2C_DEV_ID(as5912_54x_port40), -I2C_DEV_ID(as5912_54x_port41), -I2C_DEV_ID(as5912_54x_port42), -I2C_DEV_ID(as5912_54x_port43), -I2C_DEV_ID(as5912_54x_port44), -I2C_DEV_ID(as5912_54x_port45), -I2C_DEV_ID(as5912_54x_port46), -I2C_DEV_ID(as5912_54x_port47), -I2C_DEV_ID(as5912_54x_port48), -I2C_DEV_ID(as5912_54x_port49), -I2C_DEV_ID(as5912_54x_port50), -I2C_DEV_ID(as5912_54x_port51), -I2C_DEV_ID(as5912_54x_port52), -I2C_DEV_ID(as5912_54x_port53), -I2C_DEV_ID(as5912_54x_port54), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -#if (MULTIPAGE_SUPPORT == 1) - struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ -#endif -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = I2C_ADDR_CPLD1 + i*2; - reg = 0x10+j; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-52(QSFP port) */ - cpld_addr = I2C_ADDR_CPLD2; - reg = 0x52; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)(status & 0x3F) << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - u8 tx_rx_regs[] = {0x14, 0x16, 0x18, 0x20, 0x22, 0x24, 0x30, 0x32, 0x34}; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as5912_54x sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < ARRAY_SIZE(tx_rx_regs); j++) { - unsigned short cpld_addr = I2C_ADDR_CPLD1 + i*2; - - status = accton_i2c_cpld_read(cpld_addr, tx_rx_regs[j]); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, tx_rx_regs[i], status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - u8 tx_disable_regs[] = {0x20, 0x22, 0x24}; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = I2C_ADDR_CPLD1; - cpld_reg = tx_disable_regs[data->port / 8]; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = I2C_ADDR_CPLD2; - cpld_reg = tx_disable_regs[(data->port - 24) / 8]; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = accton_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - accton_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* if SFP style, offset > 255, shift to i2c addr 0x51 */ - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - if (*offset > 255) { - /* like QSFP, but shifted to client[1] */ - *client = port_data->msa->ddm_client; - *offset -= 256; - } - } - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - if ((off + len) <= 256) return len; - /* if no pages needed, we're good */ - //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - - /* Check if ddm is supported */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF8472_DIAG_MON_TYPE_ADDR, 1); - if (status < 0) return status; /* error out (no module?) */ - if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { - if (off >= 256) return -EINVAL; - maxlen = 256 - off; - } - else { - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - -#if (MULTIPAGE_SUPPORT == 1) - msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); - if (!msa->ddm_client) { - dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); - status = -EADDRINUSE; - goto exit_eeprom; - } -#endif - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_eeprom: - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as5912_54x_port1 || dev_id->driver_data > as5912_54x_port54) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as5912_54x_port1 && dev_id->driver_data <= as5912_54x_port48) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - ret = sfp_msa_probe(client, dev_id, &data->msa); - } - else { /* as5912_54x_portsfp49 ~ as5912_54x_portsfp54 */ - data->driver_type = DRIVER_TYPE_QSFP; - ret = qsfp_probe(client, dev_id, &data->qsfp); - } - - if (ret < 0) { - goto exit_kfree_buf; - } - - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); -#if (MULTIPAGE_SUPPORT == 1) - i2c_unregister_device(data->ddm_client); -#endif - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) - kfree(data->writebuf); -#endif - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5912_54x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/sfpi.c index 4d489dbe..2e87684a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/sfpi.c @@ -24,29 +24,21 @@ * ***********************************************************/ #include +#include #include -#include "platform_lib.h" - +#include "x86_64_accton_as5912_54x_int.h" #include "x86_64_accton_as5912_54x_log.h" -#define NUM_OF_SFP_PORT 54 -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_BUS_INDEX(port) (port+26) +#define PORT_BUS_INDEX(port) (port+26) -static char* -sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - FRONT_PORT_BUS_INDEX(port), addr, node_name); - return sfp_node_path; -} - -static char* -sfp_get_port_path(int port, char *node_name) -{ - return sfp_get_port_path_addr(port, 50, node_name); -} +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD1 "/sys/bus/i2c/devices/4-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/5-0062/module_rx_los_all" /************************************************************ * @@ -67,8 +59,8 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) * Ports {0, 54} */ int p; - - for(p = 0; p < NUM_OF_SFP_PORT; p++) { + + for(p = 0; p < 54; p++) { AIM_BITMAP_SET(bmap, p); } @@ -84,9 +76,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char *path = sfp_get_port_path(port, "sfp_is_present"); + int bus, addr; - if (onlp_file_read_int(&present, path) < 0) { + addr = (port < 24) ? 60 : 62; + bus = (addr == 60) ? 4 : 5; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -97,33 +92,45 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char* path; + uint32_t bytes[7], *ptr = NULL; FILE* fp; + int addr; - AIM_BITMAP_CLR_ALL(dst); + ptr = bytes; - path = sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + for (addr = 60; addr <= 62; addr+=2) { + /* Read present status of port 0~53 */ + int count = 0; + char file[64] = {0}; + int bus = (addr == 60) ? 4 : 5; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + if (addr == 60) { /* CPLD1 */ + count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + else { /* CPLD2 */ + count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + + ptr += count; } /* Mask out non-existant QSFP ports */ @@ -150,34 +157,40 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[6]; - char* path; + uint32_t *ptr = bytes; FILE* fp; - path = sfp_get_port_path(0, "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 60; addr <= 62; addr+=2) { + if (addr == 60) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; - for(i = 5; i >= 0; i--) { + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } @@ -194,32 +207,51 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); return ONLP_STATUS_E_INTERNAL; } @@ -231,13 +263,18 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 4 : 5; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - char* path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_write_integer(path, value) != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -259,16 +296,20 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; - char* path = NULL; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 4 : 5; switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - path = sfp_get_port_path(port, "sfp_rx_los"); - - if (onlp_file_read_int(value, path) < 0) { - AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } else { @@ -279,9 +320,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - path = sfp_get_port_path(port, "sfp_tx_fault"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -293,9 +332,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -312,12 +349,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) return rv; } - int onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py index 6ba3a28b..3cb317c3 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/platform-config/r0/src/python/x86_64_accton_as5912_54x_r0/__init__.py @@ -8,9 +8,9 @@ class OnlPlatform_x86_64_accton_as5912_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5912.54" def baseconfig(self): - self.insmod("accton_i2c_cpld") + self.insmod('optoe') self.insmod("ym2651y") - for m in [ "sfp", "psu", "fan", "leds" ]: + for m in [ "cpld", "psu", "fan", "leds" ]: self.insmod("x86-64-accton-as5912-54x-%s" % m) ########### initialize I2C bus 0 ########### @@ -29,8 +29,8 @@ class OnlPlatform_x86_64_accton_as5912_54x_r0(OnlPlatformAccton, ('lm75', 0x4b, 3), # initialize CPLDs - ('accton_i2c_cpld', 0x60, 4), - ('accton_i2c_cpld', 0x62, 5), + ('as5912_54x_cpld1', 0x60, 4), + ('as5912_54x_cpld2', 0x62, 5), ] ) @@ -69,11 +69,14 @@ class OnlPlatform_x86_64_accton_as5912_54x_r0(OnlPlatformAccton, # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5912_54x_port%d' % port, 0x50, port+25) + self.new_i2c_device('optoe2', 0x50, port+25) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5912_54x_port%d' % port, 0x50, port+25) + self.new_i2c_device('optoe1', 0x50, port+25) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+25), shell=True) return True From 36465787fbaa0c427720a57adcf08b61194f67b4 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 31 Jan 2018 14:38:13 +0800 Subject: [PATCH 134/244] [as5812-54t] Add support for OOM driver --- .../builds/x86-64-accton-as5812-54t-cpld.c | 457 +++++ .../builds/x86-64-accton-as5812-54t-fan.c | 15 +- .../builds/x86-64-accton-as5812-54t-leds.c | 15 +- .../builds/x86-64-accton-as5812-54t-psu.c | 22 +- .../builds/x86-64-accton-as5812-54t-sfp.c | 1502 ----------------- .../onlp/builds/src/module/src/sfpi.c | 131 +- .../x86_64_accton_as5812_54t_r0/__init__.py | 21 +- 7 files changed, 520 insertions(+), 1643 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c new file mode 100644 index 00000000..f4da9e76 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c @@ -0,0 +1,457 @@ +/* + * A hwmon driver for the as5812_54t_cpld + * + * Copyright (C) 2013 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static ssize_t show_present(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5812_54t_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5812_54t_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +struct as5812_54t_cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/* Addresses scanned for as5812_54t_cpld + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index + +enum as5812_54t_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), +}; + +/* sysfs attributes for hwmon + */ + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_present, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(54); + +static struct attribute *as5812_54t_cpld_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_ATTR(49), + DECLARE_TRANSCEIVER_ATTR(50), + DECLARE_TRANSCEIVER_ATTR(51), + DECLARE_TRANSCEIVER_ATTR(52), + DECLARE_TRANSCEIVER_ATTR(53), + DECLARE_TRANSCEIVER_ATTR(54), + NULL +}; + +static const struct attribute_group as5812_54t_cpld_group = { + .attrs = as5812_54t_cpld_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + u8 value = 0; + u8 reg = 0x22; + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + status = as5812_54t_cpld_read_internal(client, reg); + if (status < 0) { + goto exit; + } + + value = ~(u8)status; + value &= 0x3F; + + mutex_unlock(&data->update_lock); + + /* Return values 49 -> 54 in order */ + return sprintf(buf, "%.2x\n", value); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_present(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 as5812_54t_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + + mutex_lock(&data->update_lock); + status = as5812_54t_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 reg = 0, mask = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + + switch (attr->index) { + case CPLD_VERSION: + reg = 0x1; + mask = 0xFF; + break; + default: + break; + } + + mutex_lock(&data->update_lock); + status = as5812_54t_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%d\n", (status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5812_54t_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static int as5812_54t_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5812_54t_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static void as5812_54t_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5812_54t_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static int as5812_54t_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int status; + struct as5812_54t_cpld_data *data = NULL; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as5812_54t_cpld_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5812_54t_cpld_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + as5812_54t_cpld_add_client(client); + + dev_info(&client->dev, "%s: cpld '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as5812_54t_cpld_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as5812_54t_cpld_remove(struct i2c_client *client) +{ + struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as5812_54t_cpld_group); + kfree(data); + as5812_54t_cpld_remove_client(client); + + return 0; +} + +int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5812_54t_cpld_read); + +int as5812_54t_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5812_54t_cpld_write); + +static const struct i2c_device_id as5812_54t_cpld_id[] = { + { "as5812_54t_cpld", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as5812_54t_cpld_id); + +static struct i2c_driver as5812_54t_cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as5812_54t_cpld", + }, + .probe = as5812_54t_cpld_probe, + .remove = as5812_54t_cpld_remove, + .id_table = as5812_54t_cpld_id, + .address_list = normal_i2c, +}; + +static int __init as5812_54t_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5812_54t_cpld_driver); +} + +static void __exit as5812_54t_cpld_exit(void) +{ + i2c_del_driver(&as5812_54t_cpld_driver); +} + +module_init(as5812_54t_cpld_init); +module_exit(as5812_54t_cpld_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as5812_54t_cpld driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c index bad9245e..d6554637 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c @@ -131,8 +131,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54t_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as5812_54t_fan_group = { static int accton_as5812_54t_fan_read_value(u8 reg) { - return accton_i2c_cpld_read(0x60, reg); + return as5812_54t_cpld_read(0x60, reg); } static int accton_as5812_54t_fan_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(0x60, reg, value); + return as5812_54t_cpld_write(0x60, reg, value); } static void accton_as5812_54t_fan_update_device(struct device *dev) @@ -394,12 +394,7 @@ static int __init accton_as5812_54t_fan_init(void) { int ret; - extern int platform_accton_as5812_54t(void); - if (!platform_accton_as5812_54t()) { - return -ENODEV; - } - - ret = platform_driver_register(&accton_as5812_54t_fan_driver); + ret = platform_driver_register(&accton_as5812_54t_fan_driver); if (ret < 0) { goto exit; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c index 011f62e7..2d70aa18 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c @@ -29,8 +29,8 @@ #include #include -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54t_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -223,12 +223,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5812_54t_led_read_value(u8 reg) { - return accton_i2c_cpld_read(0x60, reg); + return as5812_54t_cpld_read(0x60, reg); } static int accton_as5812_54t_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(0x60, reg, value); + return as5812_54t_cpld_write(0x60, reg, value); } static void accton_as5812_54t_led_update(void) @@ -555,12 +555,7 @@ static int __init accton_as5812_54t_led_init(void) { int ret; - extern int platform_accton_as5812_54t(void); - if (!platform_accton_as5812_54t()) { - return -ENODEV; - } - - ret = platform_driver_register(&accton_as5812_54t_led_driver); + ret = platform_driver_register(&accton_as5812_54t_led_driver); if (ret < 0) { goto exit; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c index a77014e8..75a2d823 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c @@ -43,7 +43,7 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5812_54t_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg); static int as5812_54t_psu_model_name_get(struct device *dev); /* Addresses scanned @@ -328,7 +328,7 @@ static struct as5812_54t_psu_data *as5812_54t_psu_update_device(struct device *d data->valid = 0; /* Read psu status */ - status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as5812_54t_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -348,25 +348,9 @@ exit: return data; } -static int __init as5812_54t_psu_init(void) -{ - extern int platform_accton_as5812_54t(void); - if (!platform_accton_as5812_54t()) { - return -ENODEV; - } - - return i2c_add_driver(&as5812_54t_psu_driver); -} - -static void __exit as5812_54t_psu_exit(void) -{ - i2c_del_driver(&as5812_54t_psu_driver); -} +module_i2c_driver(as5812_54t_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5812_54t_psu driver"); MODULE_LICENSE("GPL"); -module_init(as5812_54t_psu_init); -module_exit(as5812_54t_psu_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c deleted file mode 100644 index 0f1b7aac..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c +++ /dev/null @@ -1,1502 +0,0 @@ -/* - * SFP driver for accton as5812_54t sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5812_54t_sfp" - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 32 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+49) - -enum port_numbers { -as5812_54t_port49, -as5812_54t_port50, -as5812_54t_port51, -as5812_54t_port52, -as5812_54t_port53, -as5812_54t_port54 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as5812_54t_port49), -I2C_DEV_ID(as5812_54t_port50), -I2C_DEV_ID(as5812_54t_port51), -I2C_DEV_ID(as5812_54t_port52), -I2C_DEV_ID(as5812_54t_port53), -I2C_DEV_ID(as5812_54t_port54), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int status = -1; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 49~54 */ - data->present = 0; - - status = accton_i2c_cpld_read(0x60, 0x22); - if (status < 0) { - DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); - goto exit; - } - - data->present |= (u64)status; - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - /* Return values 49 -> 54 in order */ - return sprintf(buf, "%.2x\n", (unsigned int)~data->present); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - /* - * Bring QSFPs out of reset, - * This is a temporary fix until the QSFP+_MOD_RST register - * can be exposed through the driver. - */ - accton_i2c_cpld_write(0x60, 0x23, 0x3F); - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as5812_54t_port49 || dev_id->driver_data > as5812_54t_port54) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - data->driver_type = DRIVER_TYPE_QSFP; - - ret = qsfp_probe(client, dev_id, &data->qsfp); - if (ret < 0) { - goto exit_kfree_buf; - } - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); -#if (MULTIPAGE_SUPPORT == 1) - kfree(data->writebuf); -#endif - - if (data->driver_type == DRIVER_TYPE_QSFP) { - ret = qsfp_remove(client, data->qsfp); - } - - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5812_54t_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c index 8840ee26..cefe9dbf 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c @@ -25,80 +25,23 @@ ***********************************************************/ #include -#include /* For O_RDWR && open */ -#include -#include -#include -#include - +#include +#include #include "platform_lib.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; #define MUX_START_INDEX 2 +#define NUM_OF_SFP_PORT 6 +static const int port_bus_index[NUM_OF_SFP_PORT] = { + 2, 4, 1, 3, 5, 0 +}; -static int front_port_to_cpld_mux_index(int port) -{ - int rport = 0; +#define PORT_BUS_INDEX(port) (port_bus_index[port-48]+MUX_START_INDEX) +#define PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" - switch (port) - { - case 48: - rport = 2; - break; - case 49: - rport = 4; - break; - case 50: - rport = 1; - break; - case 51: - rport = 3; - break; - case 52: - rport = 5; - break; - case 53: - rport = 0; - break; - default: - break; - } - - return (rport + MUX_START_INDEX); -} - -static int -as5812_54t_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8] = {0}; - *value = 0; - - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as5812_54t_sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - front_port_to_cpld_mux_index(port), addr, - node_name); - return sfp_node_path; -} - -static char* -as5812_54t_sfp_get_port_path(int port, char *node_name) -{ - return as5812_54t_sfp_get_port_path_addr(port, 50, node_name); -} +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-0060/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/0-0060/module_present_all" +#define VALIDATE_PORT(p) { if ((p < 48) || (p > 53)) return ONLP_STATUS_E_PARAM; } /************************************************************ * @@ -136,10 +79,9 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as5812_54t_sfp_get_port_path(port, "sfp_is_present"); - if (as5812_54t_sfp_node_read_int(path, &present, 1) != 0) { - AIM_LOG_INFO("Unable to read present status from port(%d)\r\n", port); + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -150,11 +92,9 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[1]; - char* path; FILE* fp; - path = as5812_54t_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); @@ -188,24 +128,23 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - return ONLP_STATUS_OK; + return ONLP_STATUS_E_UNSUPPORTED; } int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as5812_54t_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if(onlp_file_read(data, 256, &size, PORT_FORMAT, PORT_BUS_INDEX(port), "eeprom") != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -213,29 +152,35 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) } int -onlp_sfpi_dom_read(int port, uint8_t data[256]) +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - char* path = as5812_54t_sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); - - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; + VALIDATE_PORT(port); + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - return ONLP_STATUS_E_UNSUPPORTED; + VALIDATE_PORT(port); + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - return ONLP_STATUS_E_UNSUPPORTED; + VALIDATE_PORT(port); + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + VALIDATE_PORT(port); + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py index 2326fb41..f1b37214 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py @@ -10,25 +10,28 @@ class OnlPlatform_x86_64_accton_as5812_54t_r0(OnlPlatformAccton, def baseconfig(self): ########### initialize I2C bus 0 ########### - self.insmod("accton_i2c_cpld") + self.insmod("optoe") self.insmod("cpr_4011_4mxx") self.insmod("ym2651y") - for m in [ "sfp", "psu", "fan", "leds" ]: + for m in [ "cpld", "psu", "fan", "leds" ]: self.insmod("x86-64-accton-as5812-54t-%s" % m) # initialize CPLDs - self.new_i2c_device('accton_i2c_cpld', 0x60, 0) + self.new_i2c_device('as5812_54t_cpld', 0x60, 0) # initiate multiplexer (PCA9548) self.new_i2c_device('pca9548', 0x71, 0) # Initialize QSFP devices - self.new_i2c_device('as5812_54t_port49', 0x50, 4) - self.new_i2c_device('as5812_54t_port50', 0x50, 6) - self.new_i2c_device('as5812_54t_port51', 0x50, 3) - self.new_i2c_device('as5812_54t_port52', 0x50, 5) - self.new_i2c_device('as5812_54t_port53', 0x50, 7) - self.new_i2c_device('as5812_54t_port54', 0x50, 2) + for bus in range(2, 8): + self.new_i2c_device('optoe1', 0x50, bus) + + subprocess.call('echo port54 > /sys/bus/i2c/devices/2-0050/port_name', shell=True) + subprocess.call('echo port51 > /sys/bus/i2c/devices/3-0050/port_name', shell=True) + subprocess.call('echo port49 > /sys/bus/i2c/devices/4-0050/port_name', shell=True) + subprocess.call('echo port52 > /sys/bus/i2c/devices/5-0050/port_name', shell=True) + subprocess.call('echo port50 > /sys/bus/i2c/devices/6-0050/port_name', shell=True) + subprocess.call('echo port53 > /sys/bus/i2c/devices/7-0050/port_name', shell=True) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From 6c4ee843ca88cbdfa152835d055db00568bb9049 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 2 Feb 2018 18:19:42 +0000 Subject: [PATCH 135/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index dbd5b8a7..751d0b2a 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit dbd5b8a71ca995d3a15aa08b9bbcdc2fb891f9cf +Subproject commit 751d0b2a603a184626f412e120532559dedf6c7d From e8fb96d1ff021c9a94b594bdd6b067a20e5f4c63 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Fri, 2 Feb 2018 19:28:34 -0800 Subject: [PATCH 136/244] Support local file paths with colons --- packages/base/all/initrds/loader-initrd-files/src/bin/swiget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget index 333674a9..841ea130 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget @@ -221,7 +221,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): blkid = BlkidParser(log=self.log) - if ':' in SWI: + if not SWI.startswith('/') and ':' in SWI: devspec, sep, r = SWI.partition(':') p = "/dev/%s" % devspec From 2161a60bce86afd3bf9130cbece62bf3ecb5e4a4 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 4 Feb 2018 15:13:36 +0000 Subject: [PATCH 137/244] No platform modules. --- .../platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml index 21c8ec67..180f0fad 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/modules/PKG.yml @@ -1 +1 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=delta BASENAME=x86-64-delta-ag9064 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" +!include $ONL_TEMPLATES/no-platform-modules.yml VENDOR=delta BASENAME=x86-64-delta-ag9064 ARCH=amd64 From 3fe92a69f1d2c60b413884ccec430aba57175d70 Mon Sep 17 00:00:00 2001 From: Jonathan Tsai Date: Mon, 12 Feb 2018 14:27:15 +0800 Subject: [PATCH 138/244] Add Support for QuantaMesh T4048-IX8: 1. Port IX8 platform driver 2. Port IX8 ONLP: board info 3. Port IX8 ONLP: GPIO 4. Port IX8 ONLP: led 5. Port IX8 ONLP: sfp 6. Set SYS_OBJECT_ID as ".4048.3800" --- .../x86-64-quanta-ix8-rglbmc/.gitignore | 2 + .../x86-64/x86-64-quanta-ix8-rglbmc/Makefile | 1 + .../x86-64-quanta-ix8-rglbmc/modules/Makefile | 1 + .../x86-64-quanta-ix8-rglbmc/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../modules/builds/qci_platform_ix8.c | 403 +++++++++++++++++ .../x86-64-quanta-ix8-rglbmc/onlp/Makefile | 1 + .../x86-64-quanta-ix8-rglbmc/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++ .../onlp/builds/onlpdump/Makefile | 45 ++ .../src/x86_64_quanta_ix8_rglbmc/.module | 1 + .../src/x86_64_quanta_ix8_rglbmc/Makefile | 9 + .../module/auto/make.mk | 9 + .../module/auto/x86_64_quanta_ix8_rglbmc.yml | 134 ++++++ .../x86_64_quanta_ix8_rglbmc.x | 14 + .../x86_64_quanta_ix8_rglbmc_config.h | 167 +++++++ .../x86_64_quanta_ix8_rglbmc_dox.h | 26 ++ .../x86_64_quanta_ix8_rglbmc_gpio_table.h | 51 +++ .../x86_64_quanta_ix8_rglbmc_porting.h | 87 ++++ .../x86_64_quanta_ix8_rglbmc/module/make.mk | 10 + .../module/src/Makefile | 9 + .../module/src/fani.c | 31 ++ .../module/src/ledi.c | 78 ++++ .../module/src/make.mk | 9 + .../module/src/psui.c | 15 + .../module/src/sfpi.c | 413 ++++++++++++++++++ .../module/src/sysi.c | 66 +++ .../module/src/thermali.c | 31 ++ .../src/x86_64_quanta_ix8_rglbmc_config.c | 95 ++++ .../src/x86_64_quanta_ix8_rglbmc_enums.c | 10 + .../module/src/x86_64_quanta_ix8_rglbmc_int.h | 281 ++++++++++++ .../module/src/x86_64_quanta_ix8_rglbmc_log.c | 18 + .../module/src/x86_64_quanta_ix8_rglbmc_log.h | 12 + .../src/x86_64_quanta_ix8_rglbmc_module.c | 24 + .../src/x86_64_quanta_ix8_rglbmc_ucli.c | 50 +++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-quanta-ix8-rglbmc-r0.yml | 31 ++ .../x86_64_quanta_ix8_rglbmc_r0/__init__.py | 22 + 42 files changed, 2215 insertions(+) create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/PKG.yml create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/qci_platform_ix8.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/PKG.yml create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/lib/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.module create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/make.mk create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_config.h create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_dox.h create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_gpio_table.h create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_porting.h create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/make.mk create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/fani.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/ledi.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/make.mk create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/psui.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sysi.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/thermali.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/Makefile create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/PKG.yml create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/.gitignore new file mode 100644 index 00000000..d5614b88 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/.gitignore @@ -0,0 +1,2 @@ +*x86*64*quanta*ix8*rglbmc.mk +onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/PKG.yml new file mode 100644 index 00000000..9b4098f3 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix8-rglbmc KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/Makefile new file mode 100644 index 00000000..29395ebb --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := quanta +BASENAME := x86-64-quanta-ix8-rglbmc +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/qci_platform_ix8.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/qci_platform_ix8.c new file mode 100644 index 00000000..fe38f3fe --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/modules/builds/qci_platform_ix8.c @@ -0,0 +1,403 @@ +/* + * Quanta IX8 platform driver + * + * + * Copyright (C) 2017 Quanta Computer inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)) +#include +#else +#include +#endif + +#define MUX_INFO(bus, deselect) \ + {.adap_id = bus, .deselect_on_exit = deselect} + +static struct pca954x_platform_mode pca9548sfp1_modes[] = { + MUX_INFO(0x20, 1), + MUX_INFO(0x21, 1), + MUX_INFO(0x22, 1), + MUX_INFO(0x23, 1), + MUX_INFO(0x24, 1), + MUX_INFO(0x25, 1), + MUX_INFO(0x26, 1), + MUX_INFO(0x27, 1), +}; + +static struct pca954x_platform_data pca9548sfp1_data = { + .modes = pca9548sfp1_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp2_modes[] = { + MUX_INFO(0x28, 1), + MUX_INFO(0x29, 1), + MUX_INFO(0x2a, 1), + MUX_INFO(0x2b, 1), + MUX_INFO(0x2c, 1), + MUX_INFO(0x2d, 1), + MUX_INFO(0x2e, 1), + MUX_INFO(0x2f, 1), +}; + +static struct pca954x_platform_data pca9548sfp2_data = { + .modes = pca9548sfp2_modes, + .num_modes = 8, +}; +static struct pca954x_platform_mode pca9548sfp3_modes[] = { + MUX_INFO(0x30, 1), + MUX_INFO(0x31, 1), + MUX_INFO(0x32, 1), + MUX_INFO(0x33, 1), + MUX_INFO(0x34, 1), + MUX_INFO(0x35, 1), + MUX_INFO(0x36, 1), + MUX_INFO(0x37, 1), +}; + +static struct pca954x_platform_data pca9548sfp3_data = { + .modes = pca9548sfp3_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp4_modes[] = { + MUX_INFO(0x38, 1), + MUX_INFO(0x39, 1), + MUX_INFO(0x3a, 1), + MUX_INFO(0x3b, 1), + MUX_INFO(0x3c, 1), + MUX_INFO(0x3d, 1), + MUX_INFO(0x3e, 1), + MUX_INFO(0x3f, 1), +}; + +static struct pca954x_platform_data pca9548sfp4_data = { + .modes = pca9548sfp4_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp5_modes[] = { + MUX_INFO(0x40, 1), + MUX_INFO(0x41, 1), + MUX_INFO(0x42, 1), + MUX_INFO(0x43, 1), + MUX_INFO(0x44, 1), + MUX_INFO(0x45, 1), + MUX_INFO(0x46, 1), + MUX_INFO(0x47, 1), +}; + +static struct pca954x_platform_data pca9548sfp5_data = { + .modes = pca9548sfp5_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp6_modes[] = { + MUX_INFO(0x48, 1), + MUX_INFO(0x49, 1), + MUX_INFO(0x4a, 1), + MUX_INFO(0x4b, 1), + MUX_INFO(0x4c, 1), + MUX_INFO(0x4d, 1), + MUX_INFO(0x4e, 1), + MUX_INFO(0x4f, 1), +}; + +static struct pca954x_platform_data pca9548sfp6_data = { + .modes = pca9548sfp6_modes, + .num_modes = 8, +}; + +//ZQSFP +static struct pca954x_platform_mode pca9548sfp7_modes[] = { + MUX_INFO(0x50, 1), + MUX_INFO(0x51, 1), + MUX_INFO(0x52, 1), + MUX_INFO(0x53, 1), + MUX_INFO(0x54, 1), + MUX_INFO(0x55, 1), + MUX_INFO(0x56, 1), + MUX_INFO(0x57, 1), +}; + +static struct pca954x_platform_data pca9548sfp7_data = { + .modes = pca9548sfp7_modes, + .num_modes = 8, +}; + +// end port + +static struct pca954x_platform_mode pca9546_modes[] = { + MUX_INFO(0x10, 1), + MUX_INFO(0x11, 1), + MUX_INFO(0x12, 1), + MUX_INFO(0x13, 1), +}; + +static struct pca954x_platform_data pca9546_data = { + .modes = pca9546_modes, + .num_modes = 4, +}; + +static struct pca954x_platform_mode pca9548_modes[] = { + MUX_INFO(0x14, 1), + MUX_INFO(0x15, 1), + MUX_INFO(0x16, 1), + MUX_INFO(0x17, 1), + MUX_INFO(0x18, 1), + MUX_INFO(0x19, 1), + MUX_INFO(0x1a, 1), + MUX_INFO(0x1b, 1), +}; + +static struct pca954x_platform_data pca9548_data = { + .modes = pca9548_modes, + .num_modes = 8, +}; + +/* CPU Board i2c device */ +static struct pca954x_platform_mode pca9546_cpu_modes[] = { + MUX_INFO(0x02, 1), + MUX_INFO(0x03, 1), + MUX_INFO(0x04, 1), + MUX_INFO(0x05, 1), +}; + +static struct pca954x_platform_data pca9546_cpu_data = { + .modes = pca9546_cpu_modes, + .num_modes = 4, +}; +//MB Board Data +static struct pca953x_platform_data pca9555_1_data = { + .gpio_base = 0x10, +}; +//QSFP28 49-56 IO Expander +static struct pca953x_platform_data pca9698_2_data = { + .gpio_base = 0x20, +}; +//CPU Board pca9555 +static struct pca953x_platform_data pca9555_CPU_data = { + .gpio_base = 0x40, +}; +static struct i2c_board_info ix8_i2c_devices[] = { + { + I2C_BOARD_INFO("pca9546", 0x72), // 0 + .platform_data = &pca9546_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x77), // 1 + .platform_data = &pca9548_data, + }, + { + I2C_BOARD_INFO("24c02", 0x54), // 2 eeprom + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 3 0x77 ch0 + .platform_data = &pca9548sfp1_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 4 0x77 ch1 + .platform_data = &pca9548sfp2_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 5 0x77 ch2 + .platform_data = &pca9548sfp3_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 6 0x77 ch3 + .platform_data = &pca9548sfp4_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 7 0x77 ch4 + .platform_data = &pca9548sfp5_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 8 0x77 ch5 + .platform_data = &pca9548sfp6_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 9 0x77 ch6 + .platform_data = &pca9548sfp7_data, + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 10 0x72 ch0 CPLD1_:SFP28 1~16 + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 11 0x72 ch1 CPLD2_:SFP28 17~32 + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 12 0x72 ch2 CPLD_3:SFP28 33~48 + }, + { + I2C_BOARD_INFO("pca9555", 0x23), // 13 0x72 ch3 MB Board Data + .platform_data = &pca9555_1_data, + }, + { + I2C_BOARD_INFO("pca9698", 0x21), // 14 0x72 ch3 QSFP:49~52 + .platform_data = &pca9698_2_data, + }, + { + I2C_BOARD_INFO("24c02", 0x50), // 15 0x50 SFP28, QSFP EEPROM + }, + { + I2C_BOARD_INFO("pca9546", 0x71), // 16 + .platform_data = &pca9546_cpu_data, + }, + { + I2C_BOARD_INFO("pca9555", 0x20), // 17 0x71 ch0 CPU Board Data + .platform_data = &pca9555_CPU_data, + }, +}; + +static struct platform_driver ix8_platform_driver = { + .driver = { + .name = "qci-ix8", + .owner = THIS_MODULE, + }, +}; + +static struct platform_device *ix8_device; + +static int __init ix8_platform_init(void) +{ + struct i2c_client *client; + struct i2c_adapter *adapter; + int ret, i; + + ret = platform_driver_register(&ix8_platform_driver); + if (ret < 0) + return ret; + + /* Register platform stuff */ + ix8_device = platform_device_alloc("qci-ix8", -1); + if (!ix8_device) { + ret = -ENOMEM; + goto fail_platform_driver; + } + + ret = platform_device_add(ix8_device); + if (ret) + goto fail_platform_device; + + adapter = i2c_get_adapter(0); + client = i2c_new_device(adapter, &ix8_i2c_devices[0]); // pca9546 + client = i2c_new_device(adapter, &ix8_i2c_devices[1]); // pca9548 + client = i2c_new_device(adapter, &ix8_i2c_devices[16]); // pca9546cpu + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x02); + client = i2c_new_device(adapter, &ix8_i2c_devices[17]); // CPU Board Data + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x10); + client = i2c_new_device(adapter, &ix8_i2c_devices[10]); // CPLD_1 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x11); + client = i2c_new_device(adapter, &ix8_i2c_devices[11]); // CPLD_2 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x12); + client = i2c_new_device(adapter, &ix8_i2c_devices[12]); // CPLD_3 + client = i2c_new_device(adapter, &ix8_i2c_devices[2]); // MB_BOARDINFO_EEPROM + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x13); + client = i2c_new_device(adapter, &ix8_i2c_devices[13]); // MB Board Data + client = i2c_new_device(adapter, &ix8_i2c_devices[14]); // QSFP:49~52 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x14); + client = i2c_new_device(adapter, &ix8_i2c_devices[3]); // pca9548_1 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x15); + client = i2c_new_device(adapter, &ix8_i2c_devices[4]); // pca9548_2 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x16); + client = i2c_new_device(adapter, &ix8_i2c_devices[5]); // pca9548_3 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x17); + client = i2c_new_device(adapter, &ix8_i2c_devices[6]); // pca9548_4 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x18); + client = i2c_new_device(adapter, &ix8_i2c_devices[7]); // pca9548_5 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x19); + client = i2c_new_device(adapter, &ix8_i2c_devices[8]); // pca9548_6 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x1a); + client = i2c_new_device(adapter, &ix8_i2c_devices[9]); // pca9548_7 QSFP + i2c_put_adapter(adapter); + + for(i = 32; i < 88; i ++){ // SFP28 1~48 & QSFP 49~56 EEPROM + adapter = i2c_get_adapter(i); + client = i2c_new_device(adapter, &ix8_i2c_devices[15]); + i2c_put_adapter(adapter); + } + + return 0; + +fail_platform_device: + platform_device_put(ix8_device); + +fail_platform_driver: + platform_driver_unregister(&ix8_platform_driver); + return ret; +} + +static void __exit ix8_platform_exit(void) +{ + platform_device_unregister(ix8_device); + platform_driver_unregister(&ix8_platform_driver); +} + +module_init(ix8_platform_init); +module_exit(ix8_platform_exit); + + +MODULE_AUTHOR("Jonathan Tsai "); +MODULE_VERSION("1.0"); +MODULE_DESCRIPTION("Quanta IX8 Platform Driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/PKG.yml new file mode 100644 index 00000000..4d7ca269 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-quanta-ix8-rglbmc ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/lib/Makefile new file mode 100644 index 00000000..87d1fba3 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-quanta-ix8-rglbmc +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_quanta_ix8_rglbmc quanta_sys_eeprom onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-quanta-ix8-rglbmc.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..5a5e759b --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_quanta_ix8_rglbmc quanta_sys_eeprom onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.module b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.module new file mode 100644 index 00000000..162aede1 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.module @@ -0,0 +1 @@ +name: x86_64_quanta_ix8_rglbmc diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/Makefile new file mode 100644 index 00000000..032c31da --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_quanta_ix8_rglbmc +AUTOMODULE := x86_64_quanta_ix8_rglbmc +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/make.mk new file mode 100644 index 00000000..11cb2a9f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_quanta_ix8_rglbmc Autogeneration +# +############################################################################### +x86_64_quanta_ix8_rglbmc_AUTO_DEFS := module/auto/x86_64_quanta_ix8_rglbmc.yml +x86_64_quanta_ix8_rglbmc_AUTO_DIRS := module/inc/x86_64_quanta_ix8_rglbmc module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml new file mode 100644 index 00000000..36f1796c --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml @@ -0,0 +1,134 @@ +############################################################################### +# +# x86_64_quanta_ix8_rglbmc Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: + doc: "RPM Threshold at which the fan is considered to have failed." + default: 3000 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX: + doc: "Maximum system front-to-back fan speed." + default: 18000 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX: + doc: "Maximum system back-to-front fan speed." + default: 18000 +- X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS: + doc: "Time to hold Phy GPIO in reset, in ms" + default: 100 + +definitions: + cdefs: + X86_64_QUANTA_IX8_RGLBMC_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_quanta_ix8_rglbmc_config + + enum: &enums + + fan_id: + members: + - FAN1 : 1 + - FAN2 : 2 + - FAN3 : 3 + - FAN4 : 4 + - FAN5 : 5 + - FAN6 : 6 + - FAN7 : 7 + - FAN8 : 8 + - FAN9 : 9 + - FAN10 : 10 + + fan_oid: + members: + - FAN1 : ONLP_FAN_ID_CREATE(1) + - FAN2 : ONLP_FAN_ID_CREATE(2) + - FAN3 : ONLP_FAN_ID_CREATE(3) + - FAN4 : ONLP_FAN_ID_CREATE(4) + - FAN5 : ONLP_FAN_ID_CREATE(5) + - FAN6 : ONLP_FAN_ID_CREATE(6) + - FAN7 : ONLP_FAN_ID_CREATE(7) + - FAN8 : ONLP_FAN_ID_CREATE(8) + - FAN9 : ONLP_FAN_ID_CREATE(9) + - FAN10 : ONLP_FAN_ID_CREATE(10) + + psu_id: + members: + - PSU1 : 1 + - PSU2 : 2 + + psu_oid: + members: + - PSU1 : ONLP_PSU_ID_CREATE(1) + - PSU2 : ONLP_PSU_ID_CREATE(2) + + thermal_id: + members: + - THERMAL1 : 1 + - THERMAL2 : 2 + - THERMAL3 : 3 + - THERMAL4 : 4 + - THERMAL5 : 5 + - THERMAL6 : 6 + - THERMAL7 : 7 + - THERMAL8 : 8 + - THERMAL9 : 9 + - THERMAL10 : 10 + - THERMAL11 : 11 + - THERMAL12 : 12 + - THERMAL13 : 13 + - THERMAL14 : 14 + - THERMAL15 : 15 + - THERMAL16 : 16 + + + thermal_oid: + members: + - THERMAL1 : ONLP_THERMAL_ID_CREATE(1) + - THERMAL2 : ONLP_THERMAL_ID_CREATE(2) + - THERMAL3 : ONLP_THERMAL_ID_CREATE(3) + - THERMAL4 : ONLP_THERMAL_ID_CREATE(4) + - THERMAL5 : ONLP_THERMAL_ID_CREATE(5) + - THERMAL6 : ONLP_THERMAL_ID_CREATE(6) + - THERMAL7 : ONLP_THERMAL_ID_CREATE(7) + - THERMAL8 : ONLP_THERMAL_ID_CREATE(8) + - THERMAL9 : ONLP_THERMAL_ID_CREATE(9) + - THERMAL10 : ONLP_THERMAL_ID_CREATE(10) + - THERMAL11 : ONLP_THERMAL_ID_CREATE(11) + - THERMAL12 : ONLP_THERMAL_ID_CREATE(12) + - THERMAL13 : ONLP_THERMAL_ID_CREATE(13) + - THERMAL14 : ONLP_THERMAL_ID_CREATE(14) + - THERMAL15 : ONLP_THERMAL_ID_CREATE(15) + - THERMAL16 : ONLP_THERMAL_ID_CREATE(16) + + + portingmacro: + X86_64_QUANTA_IX8_RGLBMC: + macros: + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x new file mode 100644 index 00000000..183f8c66 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_config.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_config.h new file mode 100644 index 00000000..6f4439d9 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_config.h @@ -0,0 +1,167 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ix8_rglbmc Configuration Header + * + * @addtogroup x86_64_quanta_ix8_rglbmc-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX8_RGLBMC_CONFIG_H__ +#define __X86_64_QUANTA_IX8_RGLBMC_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + * + * RPM Threshold at which the fan is considered to have failed. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + * + * Maximum system front-to-back fan speed. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + * + * Maximum system back-to-front fan speed. */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + * + * Time to hold Phy GPIO in reset, in ms */ + + +#ifndef X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS +#define X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS 100 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_quanta_ix8_rglbmc_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_quanta_ix8_rglbmc_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_quanta_ix8_rglbmc_config_settings table. */ +extern x86_64_quanta_ix8_rglbmc_config_settings_t x86_64_quanta_ix8_rglbmc_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_quanta_ix8_rglbmc_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_quanta_ix8_rglbmc_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_quanta_ix8_rglbmc_porting.h" + +#endif /* __X86_64_QUANTA_IX8_RGLBMC_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_dox.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_dox.h new file mode 100644 index 00000000..4fbdd451 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_quanta_ix8_rglbmc Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX8_RGLBMC_DOX_H__ +#define __X86_64_QUANTA_IX8_RGLBMC_DOX_H__ + +/** + * @defgroup x86_64_quanta_ix8_rglbmc x86_64_quanta_ix8_rglbmc - x86_64_quanta_ix8_rglbmc Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_quanta_ix8_rglbmc-x86_64_quanta_ix8_rglbmc Public Interface + * @defgroup x86_64_quanta_ix8_rglbmc-config Compile Time Configuration + * @defgroup x86_64_quanta_ix8_rglbmc-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_QUANTA_IX8_RGLBMC_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_gpio_table.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_gpio_table.h new file mode 100644 index 00000000..de9008ef --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_gpio_table.h @@ -0,0 +1,51 @@ +#ifndef __X86_64_QUANTA_IX8_RGLBMC_GPIO_TABLE_H__ +#define __X86_64_QUANTA_IX8_RGLBMC_GPIO_TABLE_H__ + +/* + * defined within platform/quanta_switch.c + * Quanta Switch Platform driver + */ +#define QUANTA_IX8_PCA953x_GPIO(P1, P2) (P1*8+P2) + +#define QUANTA_IX8_PCA9555_GPIO_SIZE 0x10 + +#define QUANTA_IX8_I2C_GPIO_BASE 0x10 + +#define QUANTA_IX8_I2C_GPIO_CPU_BASE 0x40 + +#define QUANTA_IX8_CPU_BOARD_GPIO_BASE (QUANTA_IX8_I2C_GPIO_CPU_BASE) +#define QUANTA_IX8_CPU_BOARD_SYS_P1 (QUANTA_IX8_CPU_BOARD_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,2)) +#define QUANTA_IX8_CPU_BOARD_SYS_P2 (QUANTA_IX8_CPU_BOARD_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,3)) + +#define QUANTA_IX8_ZQSFP_EN_GPIO_BASE QUANTA_IX8_I2C_GPIO_BASE +#define QUANTA_IX8_ZQSFP_EN_GPIO_SIZE QUANTA_IX8_PCA9555_GPIO_SIZE +#define QUANTA_IX8_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_IX8_ZQSFP_EN_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,4)) +#define QUANTA_IX8_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_IX8_ZQSFP_EN_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,5)) + +#define QUANTA_IX8_PCA9698_2_GPIO_BASE (QUANTA_IX8_I2C_GPIO_BASE + QUANTA_IX8_PCA9555_GPIO_SIZE) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_49_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,0)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_49_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,2)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_49_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,3)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_50_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,4)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_50_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,6)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_50_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(0,7)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_51_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,0)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_51_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,2)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_51_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,3)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_52_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,4)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_52_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,6)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_52_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(1,7)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_53_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(2,0)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_53_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(2,2)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_53_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(2,3)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_54_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(2,4)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_54_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(2,6)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_54_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(2,7)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_55_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(3,0)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_55_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(3,2)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_55_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(3,3)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_56_RESET_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(3,4)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_56_PRSNT_N (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(3,6)) +#define QUANTA_IX8_PCA9698_2_GPIO_QSFP_56_LPMOD_P (QUANTA_IX8_PCA9698_2_GPIO_BASE + QUANTA_IX8_PCA953x_GPIO(3,7)) + +#endif /* __X86_64_QUANTA_IX8_RGLBMC_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_porting.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_porting.h new file mode 100644 index 00000000..509b038a --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_porting.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ix8_rglbmc Porting Macros. + * + * @addtogroup x86_64_quanta_ix8_rglbmc-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX8_RGLBMC_PORTING_H__ +#define __X86_64_QUANTA_IX8_RGLBMC_PORTING_H__ + + +/* */ +#if X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_QUANTA_IX8_RGLBMC_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_QUANTA_IX8_RGLBMC_MEMSET GLOBAL_MEMSET + #elif X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX8_RGLBMC_MEMSET memset + #else + #error The macro X86_64_QUANTA_IX8_RGLBMC_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX8_RGLBMC_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_QUANTA_IX8_RGLBMC_MEMCPY GLOBAL_MEMCPY + #elif X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX8_RGLBMC_MEMCPY memcpy + #else + #error The macro X86_64_QUANTA_IX8_RGLBMC_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX8_RGLBMC_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_QUANTA_IX8_RGLBMC_STRNCPY GLOBAL_STRNCPY + #elif X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX8_RGLBMC_STRNCPY strncpy + #else + #error The macro X86_64_QUANTA_IX8_RGLBMC_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX8_RGLBMC_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_QUANTA_IX8_RGLBMC_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX8_RGLBMC_VSNPRINTF vsnprintf + #else + #error The macro X86_64_QUANTA_IX8_RGLBMC_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX8_RGLBMC_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_QUANTA_IX8_RGLBMC_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX8_RGLBMC_SNPRINTF snprintf + #else + #error The macro X86_64_QUANTA_IX8_RGLBMC_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_IX8_RGLBMC_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_QUANTA_IX8_RGLBMC_STRLEN GLOBAL_STRLEN + #elif X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_IX8_RGLBMC_STRLEN strlen + #else + #error The macro X86_64_QUANTA_IX8_RGLBMC_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_QUANTA_IX8_RGLBMC_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/make.mk new file mode 100644 index 00000000..f60f0421 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_quanta_ix8_rglbmc_INCLUDES := -I $(THIS_DIR)inc +x86_64_quanta_ix8_rglbmc_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_quanta_ix8_rglbmc_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ix8_rglbmc ucli:x86_64_quanta_ix8_rglbmc + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/Makefile new file mode 100644 index 00000000..66798ec3 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_quanta_ix8_rglbmc_ucli.c + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/fani.c new file mode 100644 index 00000000..7594b0ca --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/fani.c @@ -0,0 +1,31 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_fani_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/ledi.c new file mode 100644 index 00000000..d88abc98 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/ledi.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include + +#include "x86_64_quanta_ix8_rglbmc_int.h" +#include +#include + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t led_info[] = +{ + { }, /* Not used */ + { + { LED_OID_SYSTEM, "System LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + } +}; + +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + + int led_id; + + led_id = ONLP_OID_ID_GET(id); + + *info = led_info[led_id]; + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_ON; + + return ONLP_STATUS_OK; +} + +void +Sysfs_Set_System_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_IX8_CPU_BOARD_SYS_P1, 0); + onlp_gpio_set(QUANTA_IX8_CPU_BOARD_SYS_P2, 1); + } + else if(mode == ONLP_LED_MODE_ORANGE){ + onlp_gpio_set(QUANTA_IX8_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_IX8_CPU_BOARD_SYS_P2, 0); + } + else{ + onlp_gpio_set(QUANTA_IX8_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_IX8_CPU_BOARD_SYS_P2, 1); + } +} + +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int led_id; + + led_id = ONLP_OID_ID_GET(id); + switch (led_id) { + case LED_ID_SYSTEM: + Sysfs_Set_System_LED(mode); + break; + default: + return ONLP_STATUS_E_INTERNAL; + break; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/make.mk new file mode 100644 index 00000000..f915b63d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_quanta_ix8_rglbmc +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/psui.c new file mode 100644 index 00000000..b5cedce1 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/psui.c @@ -0,0 +1,15 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c new file mode 100644 index 00000000..a6653a58 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c @@ -0,0 +1,413 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * SFPI Interface for the Quanta IX8 + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "x86_64_quanta_ix8_rglbmc_log.h" +#include +#include +#include + +/** + * This table maps the presence gpio, reset gpio, and eeprom file + * for each SFP port. + */ +typedef struct sfpmap_s { + int port; + const char* present_cpld; + const char* reset_gpio; + const char* eeprom; + const char* dom; +} sfpmap_t; + +static sfpmap_t sfpmap__[] = + { + { 1, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-1/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-32/32-0050/eeprom", NULL }, + { 2, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-2/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-33/33-0050/eeprom", NULL }, + { 3, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-3/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-34/34-0050/eeprom", NULL }, + { 4, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-4/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-35/35-0050/eeprom", NULL }, + { 5, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-5/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-36/36-0050/eeprom", NULL }, + { 6, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-6/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-37/37-0050/eeprom", NULL }, + { 7, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-7/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-38/38-0050/eeprom", NULL }, + { 8, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-8/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-39/39-0050/eeprom", NULL }, + { 9, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-9/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-40/40-0050/eeprom", NULL }, + { 10, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-10/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-41/41-0050/eeprom", NULL }, + { 11, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-11/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-42/42-0050/eeprom", NULL }, + { 12, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-12/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-43/43-0050/eeprom", NULL }, + { 13, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-13/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-44/44-0050/eeprom", NULL }, + { 14, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-14/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-45/45-0050/eeprom", NULL }, + { 15, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-15/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-46/46-0050/eeprom", NULL }, + { 16, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-16/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-47/47-0050/eeprom", NULL }, + { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-17/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-48/48-0050/eeprom", NULL }, + { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-18/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-49/49-0050/eeprom", NULL }, + { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-19/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-50/50-0050/eeprom", NULL }, + { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-20/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-51/51-0050/eeprom", NULL }, + { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-21/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-52/52-0050/eeprom", NULL }, + { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-22/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-53/53-0050/eeprom", NULL }, + { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-23/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-54/54-0050/eeprom", NULL }, + { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-24/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-55/55-0050/eeprom", NULL }, + { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-25/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-56/56-0050/eeprom", NULL }, + { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-26/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-57/57-0050/eeprom", NULL }, + { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-27/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-58/58-0050/eeprom", NULL }, + { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-28/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-59/59-0050/eeprom", NULL }, + { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-29/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-60/60-0050/eeprom", NULL }, + { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-30/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-61/61-0050/eeprom", NULL }, + { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-31/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-62/62-0050/eeprom", NULL }, + { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-63/63-0050/eeprom", NULL }, + { 33, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-33/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-64/64-0050/eeprom", NULL }, + { 34, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-34/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-65/65-0050/eeprom", NULL }, + { 35, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-35/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-66/66-0050/eeprom", NULL }, + { 36, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-36/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-67/67-0050/eeprom", NULL }, + { 37, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-37/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-68/68-0050/eeprom", NULL }, + { 38, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-38/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-69/69-0050/eeprom", NULL }, + { 39, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-39/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-70/70-0050/eeprom", NULL }, + { 40, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-40/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-71/71-0050/eeprom", NULL }, + { 41, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-41/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-72/72-0050/eeprom", NULL }, + { 42, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-42/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-73/73-0050/eeprom", NULL }, + { 43, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-43/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-74/74-0050/eeprom", NULL }, + { 44, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-44/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-75/75-0050/eeprom", NULL }, + { 45, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-45/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-76/76-0050/eeprom", NULL }, + { 46, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-46/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-77/77-0050/eeprom", NULL }, + { 47, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-47/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-78/78-0050/eeprom", NULL }, + { 48, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-48/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-79/79-0050/eeprom", NULL }, + }; + +typedef struct qsfpmap_s { + int port; + int present_gpio; + int reset_gpio; + int lplmod_gpio; + const char* eeprom; + const char* dom; +} qsfpmap_t; + +static qsfpmap_t qsfpmap__[] = + { + { 49, QUANTA_IX8_PCA9698_2_GPIO_QSFP_49_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_49_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_49_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-80/80-0050/eeprom", NULL }, + { 50, QUANTA_IX8_PCA9698_2_GPIO_QSFP_50_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_50_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_50_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-81/81-0050/eeprom", NULL }, + { 51, QUANTA_IX8_PCA9698_2_GPIO_QSFP_51_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_51_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_51_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-82/82-0050/eeprom", NULL }, + { 52, QUANTA_IX8_PCA9698_2_GPIO_QSFP_52_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_52_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_52_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-83/83-0050/eeprom", NULL }, + { 53, QUANTA_IX8_PCA9698_2_GPIO_QSFP_53_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_53_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_53_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-84/84-0050/eeprom", NULL }, + { 54, QUANTA_IX8_PCA9698_2_GPIO_QSFP_54_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_54_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_54_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-85/85-0050/eeprom", NULL }, + { 55, QUANTA_IX8_PCA9698_2_GPIO_QSFP_55_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_55_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_55_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-86/86-0050/eeprom", NULL }, + { 56, QUANTA_IX8_PCA9698_2_GPIO_QSFP_56_PRSNT_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_56_RESET_N, QUANTA_IX8_PCA9698_2_GPIO_QSFP_56_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-87/87-0050/eeprom", NULL }, + }; + +#define SFP_GET(_port) (sfpmap__ + _port - 1) +#define QSFP_GET(_port) (qsfpmap__ + _port - 49) +#define MAX_SFP_PATH 128 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sfpmap_t* sfp = SFP_GET(port); + + sprintf(sfp_node_path, sfp->present_cpld, + node_name); + return sfp_node_path; +} + +int +onlp_sfpi_init(void) +{ + int ret, i; + qsfpmap_t* qsfp; + + onlp_gpio_export(QUANTA_IX8_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); + ret = onlp_gpio_set(QUANTA_IX8_ZQSFP_EN_GPIO_P3V3_PW_EN, 1); + sleep(1); + + for(i = 49; i < 57 ; i ++) { + qsfp = QSFP_GET(i); + onlp_gpio_export(qsfp->present_gpio, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(qsfp->reset_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(qsfp->reset_gpio, 1); + onlp_gpio_export(qsfp->lplmod_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(qsfp->lplmod_gpio, 0); + } + + return ret; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + + for(p = 1; p < 57; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + if(port > 48){ + int value = 0; + qsfpmap_t* qsfp = QSFP_GET(port); + + if(qsfp->present_gpio > 0) { + if(onlp_gpio_get(qsfp->present_gpio, &value) == ONLP_STATUS_OK) + return (value == 0); + else + return ONLP_STATUS_E_MISSING; + } + else { + /** + * If we can open and read a byte from the EEPROM file + * then we consider it present. + */ + int fd = open(qsfp->eeprom, O_RDONLY); + if (fd < 0) { + /* Not Present */ + return 0; + } + int rv; + uint8_t byte; + + if(read(fd, &byte, 1) == 1) { + /* Present */ + rv = 1; + } + else { + /* No Present */ + rv = 0; + } + close(fd); + return rv; + } + } + else{ + return onlplib_sfp_is_present_file(sfp_get_port_path(port, "pre_n"), /* Present */ "1\n", /* Absent */ "0\n"); + } +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + return onlplib_sfp_eeprom_read_file(qsfp->eeprom, data); + } + else{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->eeprom, data); + } +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + return onlplib_sfp_eeprom_read_file(qsfp->dom, data); + } + else{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->dom, data); + } +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + if(onlp_gpio_set(qsfp->reset_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set reset status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + if(onlp_gpio_set(qsfp->lplmod_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + else{ + switch(control){ + case ONLP_SFP_CONTROL_TX_DISABLE: + { + char* path = sfp_get_port_path(port, "tx_dis"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + char* path = NULL; + + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + if(onlp_gpio_get(qsfp->reset_gpio, value) == ONLP_STATUS_OK){ + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + if(onlp_gpio_get(qsfp->lplmod_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read lp_mode status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_RX_LOS: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + else{ + switch(control){ + case ONLP_SFP_CONTROL_RX_LOS: + { + path = sfp_get_port_path(port, "rx_los"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + path = sfp_get_port_path(port, "tx_fault"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + path = sfp_get_port_path(port, "tx_dis"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read tx_disable status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + + return rv; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sysi.c new file mode 100644 index 00000000..81b54da5 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/sysi.c @@ -0,0 +1,66 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_quanta_ix8_rglbmc_int.h" +#include "x86_64_quanta_ix8_rglbmc_log.h" +#include +#include +#include +#include +#include + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-quanta-ix8-rglbmc-r0"; +} + +int +onlp_sysi_init(void) +{ + /* Config GPIO */ + /* LED Output */ + onlp_gpio_export(QUANTA_IX8_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_IX8_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); + + /* Set LED to green */ + onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); + + return ONLP_STATUS_OK; +} + +#define QUANTA_SYS_EEPROM_PATH \ +"/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0054/eeprom" + +int +onlp_sysi_onie_info_get(onlp_onie_info_t* onie) +{ + int rv; + + rv = onlp_onie_decode_file(onie, QUANTA_SYS_EEPROM_PATH); + if(rv >= 0) { + onie->platform_name = aim_strdup("x86-64-quanta-ix8-rglbmc-r0"); + rv = quanta_onie_sys_eeprom_custom_format(onie); + } + return rv; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* + * 1 LEDs + */ + *e++ = LED_OID_SYSTEM; + + return 0; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/thermali.c new file mode 100644 index 00000000..2a84c017 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/thermali.c @@ -0,0 +1,31 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c new file mode 100644 index 00000000..2a275c76 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c @@ -0,0 +1,95 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(_x) +x86_64_quanta_ix8_rglbmc_config_settings_t x86_64_quanta_ix8_rglbmc_config_settings[] = +{ +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_STDLIB(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + { __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS) }, +#else +{ X86_64_QUANTA_IX8_RGLBMC_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_VALUE +#undef __x86_64_quanta_ix8_rglbmc_config_STRINGIFY_NAME + +const char* +x86_64_quanta_ix8_rglbmc_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_quanta_ix8_rglbmc_config_settings[i].name; i++) { + if(strcmp(x86_64_quanta_ix8_rglbmc_config_settings[i].name, setting)) { + return x86_64_quanta_ix8_rglbmc_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_quanta_ix8_rglbmc_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_quanta_ix8_rglbmc_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_quanta_ix8_rglbmc_config_settings[i].name, x86_64_quanta_ix8_rglbmc_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c new file mode 100644 index 00000000..947764e7 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h new file mode 100644 index 00000000..43541398 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h @@ -0,0 +1,281 @@ +/**************************************************************************//** + * + * x86_64_quanta_ix8_rglbmc Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX8_RGLBMC_INT_H__ +#define __X86_64_QUANTA_IX8_RGLBMC_INT_H__ + +#include +#include + +/* */ +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; + +/** Enum names. */ +const char* thermal_oid_name(thermal_oid_t e); + +/** Enum values. */ +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_oid_desc(thermal_oid_t e); + +/** Enum validator. */ +int thermal_oid_valid(thermal_oid_t e); + +/** validator */ +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) + +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; + +/** psu_oid */ +typedef enum psu_oid_e { + PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), + PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), +} psu_oid_t; + +/** Enum names. */ +const char* psu_oid_name(psu_oid_t e); + +/** Enum values. */ +int psu_oid_value(const char* str, psu_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_oid_desc(psu_oid_t e); + +/** Enum validator. */ +int psu_oid_valid(psu_oid_t e); + +/** validator */ +#define PSU_OID_VALID(_e) \ + (psu_oid_valid((_e))) + +/** psu_oid_map table. */ +extern aim_map_si_t psu_oid_map[]; +/** psu_oid_desc_map table. */ +extern aim_map_si_t psu_oid_desc_map[]; + +/** thermal_id */ +typedef enum thermal_id_e { + THERMAL_ID_THERMAL1 = 1, + THERMAL_ID_THERMAL2 = 2, + THERMAL_ID_THERMAL3 = 3, + THERMAL_ID_THERMAL4 = 4, + THERMAL_ID_THERMAL5 = 5, + THERMAL_ID_THERMAL6 = 6, + THERMAL_ID_THERMAL7 = 7, + THERMAL_ID_THERMAL8 = 8, + THERMAL_ID_THERMAL9 = 9, + THERMAL_ID_THERMAL10 = 10, + THERMAL_ID_THERMAL11 = 11, + THERMAL_ID_THERMAL12 = 12, + THERMAL_ID_THERMAL13 = 13, + THERMAL_ID_THERMAL14 = 14, + THERMAL_ID_THERMAL15 = 15, + THERMAL_ID_THERMAL16 = 16, +} thermal_id_t; + +/** Enum names. */ +const char* thermal_id_name(thermal_id_t e); + +/** Enum values. */ +int thermal_id_value(const char* str, thermal_id_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_id_desc(thermal_id_t e); + +/** Enum validator. */ +int thermal_id_valid(thermal_id_t e); + +/** validator */ +#define THERMAL_ID_VALID(_e) \ + (thermal_id_valid((_e))) + +/** thermal_id_map table. */ +extern aim_map_si_t thermal_id_map[]; +/** thermal_id_desc_map table. */ +extern aim_map_si_t thermal_id_desc_map[]; + +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; + +/** Enum names. */ +const char* fan_id_name(fan_id_t e); + +/** Enum values. */ +int fan_id_value(const char* str, fan_id_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_id_desc(fan_id_t e); + +/** Enum validator. */ +int fan_id_valid(fan_id_t e); + +/** validator */ +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) + +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; +/* */ + +/* psu info table */ +struct psu_info_s { + char path[PATH_MAX]; + int present; + int busno; + int addr; +}; + +/** led_id */ +typedef enum led_id_e { + LED_ID_SYSTEM = 1, +} led_id_t; + +/** Enum names. */ +const char* led_id_name(led_id_t e); + +/** Enum values. */ +int led_id_value(const char* str, led_id_t* e, int substr); + +/** Enum descriptions. */ +const char* led_id_desc(led_id_t e); + +/** Enum validator. */ +int led_id_valid(led_id_t e); + +/** validator */ +#define LED_ID_VALID(_e) \ + (led_id_valid((_e))) + +/** led_id_map table. */ +extern aim_map_si_t led_id_map[]; +/** led_id_desc_map table. */ +extern aim_map_si_t led_id_desc_map[]; + +/** led_oid */ +typedef enum led_oid_e { + LED_OID_SYSTEM = ONLP_LED_ID_CREATE(LED_ID_SYSTEM), +} led_oid_t; + +/** Enum names. */ +const char* led_oid_name(led_oid_t e); + +/** Enum values. */ +int led_oid_value(const char* str, led_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* led_oid_desc(led_oid_t e); + +/** Enum validator. */ +int led_oid_valid(led_oid_t e); + +/** validator */ +#define LED_OID_VALID(_e) \ + (led_oid_valid((_e))) + +/** led_oid_map table. */ +extern aim_map_si_t led_oid_map[]; +/** led_oid_desc_map table. */ +extern aim_map_si_t led_oid_desc_map[]; +/* */ + +#endif /* __X86_64_QUANTA_IX8_RGLBMC_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c new file mode 100644 index 00000000..ba2b3cf8 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ix8_rglbmc_log.h" +/* + * x86_64_quanta_ix8_rglbmc log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_QUANTA_IX8_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h new file mode 100644 index 00000000..d69cac1e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_IX8_RGLBMC_LOG_H__ +#define __X86_64_QUANTA_IX8_RGLBMC_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_quanta_ix8_rglbmc +#include + +#endif /* __X86_64_QUANTA_IX8_RGLBMC_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c new file mode 100644 index 00000000..d388ea9c --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ix8_rglbmc_log.h" + +static int +datatypes_init__(void) +{ +#define X86_64_QUANTA_IX8_RGLBMC_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_quanta_ix8_rglbmc_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c new file mode 100644 index 00000000..ee793610 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_QUANTA_IX8_RGLBMC_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_quanta_ix8_rglbmc_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ix8_rglbmc) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_quanta_ix8_rglbmc_ucli_module__ = + { + "x86_64_quanta_ix8_rglbmc_ucli", + NULL, + x86_64_quanta_ix8_rglbmc_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_quanta_ix8_rglbmc_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_quanta_ix8_rglbmc_ucli_module__); + n = ucli_node_create("x86_64_quanta_ix8_rglbmc", NULL, &x86_64_quanta_ix8_rglbmc_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ix8_rglbmc")); + return n; +} + +#else +void* +x86_64_quanta_ix8_rglbmc_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/PKG.yml new file mode 100644 index 00000000..d3eb1818 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix8-rglbmc REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml new file mode 100644 index 00000000..2115b155 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for IX8 +# +###################################################################### + +x86-64-quanta-ix8-rglbmc-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + console=ttyS1,115200n8 + reboot=c,p + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py new file mode 100644 index 00000000..24e6c3d8 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py @@ -0,0 +1,22 @@ +from onl.platform.base import * +from onl.platform.quanta import * + +class OnlPlatform_x86_64_quanta_ix8_rglbmc_r0(OnlPlatformQuanta, + OnlPlatformPortConfig_48x25_8x100): + PLATFORM='x86-64-quanta-ix8-rglbmc-r0' + MODEL="IX8" + """ Define Quanta SYS_OBJECT_ID rule. + + SYS_OBJECT_ID = .xxxx.ABCC + "xxxx" define QCT device mark. For example, LB9->1048, LY2->3048 + "A" define QCT switch series name: LB define 1, LY define 2, IX define 3 + "B" define QCT switch series number 1: For example, LB9->9, LY2->2 + "CC" define QCT switch series number 2: For example, LY2->00, LY4R->18(R is 18th english letter) + """ + SYS_OBJECT_ID=".4048.3800" + + def baseconfig(self): + self.insmod("qci_cpld_sfp28") + self.insmod("qci_platform_ix8") + + return True From 1861e74aa1f0774c1677168edca340920d05fc08 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 12 Feb 2018 17:27:00 +0000 Subject: [PATCH 139/244] Fix format warnings. --- .../onlp/builds/src/module/src/sfpi.c | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c index d11f97a7..acfcd426 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/sfpi.c @@ -30,7 +30,7 @@ static inline int ag9032v2_sfp_get_lp_mode_reg(int port) { uint8_t reg_offset = 0x00; if (port < 8) /* port 0-7 */ - reg_offset = SFP_LP_MODE_1; + reg_offset = SFP_LP_MODE_1; else if (port > 7 && port < 16) /* port 8-15 */ reg_offset = SFP_LP_MODE_2; else if (port > 15 && port < 24) /* port 16-23 */ @@ -44,7 +44,7 @@ static inline int ag9032v2_sfp_get_lp_mode_reg(int port) { static inline int ag9032v2_sfp_get_reset_reg(int port) { uint8_t reg_offset = 0x00; if (port < 8) /* port 0-7 */ - reg_offset = SFP_RESET_1; + reg_offset = SFP_RESET_1; else if (port > 7 && port < 16) /* port 8-15 */ reg_offset = SFP_RESET_2; else if (port > 15 && port < 24) /* port 16-23 */ @@ -58,7 +58,7 @@ static inline int ag9032v2_sfp_get_reset_reg(int port) { static inline int ag9032v2_sfp_get_present_reg(int port) { uint8_t reg_offset = 0x00; if (port < 8) /* port 0-7 */ - reg_offset = SFP_PRESENT_1; + reg_offset = SFP_PRESENT_1; else if (port > 7 && port < 16) /* port 8-15 */ reg_offset = SFP_PRESENT_2; else if (port > 15 && port < 24) /* port 16-23 */ @@ -72,7 +72,7 @@ static inline int ag9032v2_sfp_get_present_reg(int port) { static inline int ag9032v2_sfp_get_respond_reg(int port) { uint8_t reg_offset = 0x00; if (port < 8) /* port 0-7 */ - reg_offset = SFP_RESPOND_1; + reg_offset = SFP_RESPOND_1; else if (port > 7 && port < 16) /* port 8-15 */ reg_offset = SFP_RESPOND_2; else if (port > 15 && port < 24) /* port 16-23 */ @@ -86,10 +86,10 @@ static inline int ag9032v2_sfp_get_respond_reg(int port) { static inline int ag9032v2_sfp_get_mux_reg(int port) { uint8_t sel_channel = 0x00; if (port >= 0 && port < NUM_OF_QSFP_PORT) /* port 0-31 ,reg : 0x01 - 0x32 */ - sel_channel = port; + sel_channel = port; else if (port == NUM_OF_QSFP_PORT){ /* port 32 */ sel_channel = 0x20; - } + } else if (port == NUM_OF_QSFP_PORT + 1){ /* port 333 */ sel_channel = 0x21; } @@ -188,14 +188,14 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) char *r_array[4]; int count = 0; int i = 0; - int j = NUM_OF_QSFP_PORT - 1; + int j = NUM_OF_QSFP_PORT - 1; uint8_t bytes[4]; uint8_t byte_get; uint8_t sfp1; uint8_t sfp2; uint32_t presence_all = 0 ; - - /* Read presence bitmap from SWPLD QSFP28 Presence Register + + /* Read presence bitmap from SWPLD QSFP28 Presence Register * if only port 0 is present, return 7F FF FF FF * if only port 0 and 1 present, return 3F FF FF FF */ @@ -223,7 +223,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) r_byte = strtok(present_all_data, " "); count = 0; while (r_byte != NULL) { - r_array[count++] = r_byte; + r_array[count++] = r_byte; r_byte = strtok(NULL, " "); } @@ -254,14 +254,14 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) j--; } - /* Populate SFP bitmap */ + /* Populate SFP bitmap */ byte_get = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); if(byte_get < 0)return ONLP_STATUS_E_GENERIC; sfp2 = (byte_get & 0x08) >> 3; //get sfp2 present bit byte_get = byte_get >> 4; sfp1 = (byte_get & 0x08) >> 3; //get sfp1 present bit - AIM_BITMAP_MOD(dst, 32, !(sfp1 & 1)); + AIM_BITMAP_MOD(dst, 32, !(sfp1 & 1)); AIM_BITMAP_MOD(dst, 33, !(sfp2 & 1)); return ONLP_STATUS_OK; @@ -283,9 +283,9 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) /* Select qsfp port to response mode */ backup_response_data = onlp_i2c_readb(I2C_BUS_1, SWPLD_1_ADDR, sfp_response_reg, ONLP_I2C_F_TENBIT); if(backup_response_data < 0)return ONLP_STATUS_E_GENERIC; - response_data = ~(1 << (7 - (port % 8))); + response_data = ~(1 << (7 - (port % 8))); onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, sfp_response_reg, 1, &response_data, ONLP_I2C_F_TENBIT); - + /* Select QSFP port */ onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, SFP_I2C_MUX_REG, 1, &sfp_mux_reg, ONLP_I2C_F_TENBIT); memset(data, 0, 256); @@ -320,11 +320,11 @@ onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) switch (control) { case ONLP_SFP_CONTROL_RESET_STATE: case ONLP_SFP_CONTROL_LP_MODE: - *rv = 1; - break; + *rv = 1; + break; case ONLP_SFP_CONTROL_RX_LOS: case ONLP_SFP_CONTROL_TX_DISABLE: - *rv = 0; + *rv = 0; break; default: break; @@ -334,11 +334,11 @@ onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) switch (control) { case ONLP_SFP_CONTROL_RESET_STATE: case ONLP_SFP_CONTROL_LP_MODE: - *rv = 0; - break; + *rv = 0; + break; case ONLP_SFP_CONTROL_RX_LOS: case ONLP_SFP_CONTROL_TX_DISABLE: - *rv = 1; + *rv = 1; break; default: break; @@ -359,7 +359,7 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) /* Select QSFP port */ onlp_i2c_write(I2C_BUS_1, SWPLD_1_ADDR, SFP_I2C_MUX_REG, 1, &sfp_mux_reg, ONLP_I2C_F_TENBIT); - + if(port < NUM_OF_QSFP_PORT){ //port: QSFP(0-31) switch (control) { case ONLP_SFP_CONTROL_RESET_STATE: @@ -384,7 +384,7 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) case ONLP_SFP_CONTROL_RESET_STATE: case ONLP_SFP_CONTROL_LP_MODE: value_t = ONLP_STATUS_E_INTERNAL; - break; + break; case ONLP_SFP_CONTROL_RX_LOS: value_backup = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); if(value_backup < 0)return ONLP_STATUS_E_GENERIC; @@ -448,11 +448,13 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) * return 0 = The module is in Reset * return 1 = The module is NOT in Reset */ - if (*value == 0) - *value = 1; - else if (*value == 1) - *value = 0; - value_t = ONLP_STATUS_OK; + if (*value == 0) { + *value = 1; + } + else if (*value == 1) { + *value = 0; + } + value_t = ONLP_STATUS_OK; break; case ONLP_SFP_CONTROL_LP_MODE: /* From sfp_lp_mode value, @@ -465,12 +467,12 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) } *value = (1 << (7 - (*value % 8))) & 1 ; value_t = ONLP_STATUS_OK; - break; + break; case ONLP_SFP_CONTROL_RX_LOS: case ONLP_SFP_CONTROL_TX_DISABLE: - *value = 0; + *value = 0; value_t = ONLP_STATUS_OK; - break; + break; default: value_t = ONLP_STATUS_E_UNSUPPORTED; break; @@ -481,11 +483,11 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_RESET_STATE: case ONLP_SFP_CONTROL_LP_MODE: value_t = ONLP_STATUS_OK; - break; + break; case ONLP_SFP_CONTROL_RX_LOS: value_t = onlp_i2c_readb(I2C_BUS_1, SWPLD_2_ADDR, SFP_SIGNAL_REG, ONLP_I2C_F_TENBIT); if(port == (NUM_OF_ALL_PORT - NUM_OF_SFP_PORT) && value_t >= 0){ - *value = (value_t >> 6) & 0x01; + *value = (value_t >> 6) & 0x01; } else if(port == (NUM_OF_ALL_PORT - 1) && value_t >= 0){ *value = (value_t >> 2) & 0x01; From fc98fd4c0f2b86818971de0df447bdc833876bcd Mon Sep 17 00:00:00 2001 From: Krishna Kolakaluri Date: Tue, 13 Feb 2018 17:06:20 -0800 Subject: [PATCH 140/244] Fixed PSU thermal issue. --- Makefile | 2 +- .../onlp/builds/src/module/src/platform_lib.h | 3 +- .../onlp/builds/src/module/src/psui.c | 5 +- .../onlp/builds/src/module/src/thermali.c | 104 ++++++++++++++++-- 4 files changed, 102 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index c183f82e..cbfe14b5 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ endif include $(ONL)/make/config.mk # All available architectures. -ALL_ARCHES := amd64 powerpc armel arm64 +ALL_ARCHES := amd64 armel # Build rule for each architecture. define build_arch_template diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h index 3981c47f..45fc4106 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/platform_lib.h @@ -33,7 +33,7 @@ #define PSU2_ID 2 #define CHASSIS_FAN_COUNT 6 -#define CHASSIS_THERMAL_COUNT 4 +#define CHASSIS_THERMAL_COUNT 6 #define CHASSIS_PSU_COUNT 2 @@ -145,4 +145,5 @@ typedef enum platform_id_e { } platform_id_t; extern platform_id_t platform_id; +extern int psu_status_info_get(int id, char *node); #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c index cdde1a5e..fda9d5ae 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/psui.c @@ -34,7 +34,7 @@ #define CPLD_PSU_NAME "MASTERCPLD" #define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 +#define PSU_STATUS_POWER_GOOD 0 #define PSU_STATUS_REG (0X03) #define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1)) #define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1)) @@ -79,7 +79,7 @@ static long psu_data_convert_16(unsigned int d, int mult) } -static int +int psu_status_info_get(int id, char *node) { int ret; @@ -246,6 +246,7 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) if (val != PSU_STATUS_POWER_GOOD) { info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; } /* Get PSU type diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c index c11239ff..fd3b9602 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/thermali.c @@ -31,6 +31,7 @@ #include "platform_lib.h" #include "x86_64_delta_ag7648_log.h" #include +#include "x86_64_delta_i2c.h" #define prefix_path "/sys/bus/i2c/devices/" #define LOCAL_DEBUG 0 @@ -59,8 +60,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */ "3-004c/hwmon/hwmon2/temp1_input", "3-004d/hwmon/hwmon3/temp1_input", "3-004e/hwmon/hwmon4/temp1_input", - "4-0058/psu_temp1_input", - "5-0058/psu_temp1_input", }; /* Static values */ @@ -83,15 +82,30 @@ static onlp_thermal_info_t linfo[] = { ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, - ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, - ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS } }; +/*thermali val to real tempeture*/ +static int +_onlp_psu_thermali_val_to_temperature (int v,int mult) +{ + long X, Y, N, n; + Y = v & 0x07FF; + N = (v >> 11) & 0x0f; + n = v & 0x8000 ? 1 : 0; + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = Y * mult * (N=(1<<(N&0xf))); + return X; +} + /* * This will be called to intiialize the thermali subsystem. */ @@ -112,17 +126,15 @@ onlp_thermali_init(void) * structure even if the sensor described by the OID is not present. */ int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +_onlp_thermali_info_get(int id, onlp_thermal_info_t* info) { int len, nbytes = 10, temp_base=1, local_id; uint8_t r_data[10]={0}; char fullpath[50] = {0}; - VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); + local_id = id; DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); - /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[local_id]; /* get fullpath */ @@ -138,3 +150,79 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) return ONLP_STATUS_OK; } +/*psu temperture info get*/ +static int +_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info) +{ + int psu_present,psu_good; + int psu_id,local_id; + int r_data,temperature_v; + enum ag7648_product_id pid; + + local_id=id; + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + + psu_id=(local_id-THERMAL_1_ON_PSU1)+1; + pid=get_product_id(); + //if the psu is not, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + if(psu_present != 1){ + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + psu_good= psu_status_info_get(psu_id,"good"); + if(psu_good != 0){ + info->status |= ONLP_THERMAL_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + //read the pus temperture register value + if(pid == PID_AG7648){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); + } + else{ + DEBUG_PRINT("\n[Debug][%s][%d][unsupported board:%d]", __FUNCTION__, __LINE__, pid); + return ONLP_STATUS_E_UNSUPPORTED; + } + if(r_data<0) + return ONLP_STATUS_E_INVALID; + //get the real temperture value + temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000); + + info->mcelsius=temperature_v; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; + +} + +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rc; + int local_id; + + VALIDATE(id); + + local_id=ONLP_OID_ID_GET(id); + + if((local_id > THERMAL_1_ON_PSU2) || (local_id < THERMAL_1_CLOSE_TO_CPU)){ + DEBUG_PRINT("\n[Debug][%s][%d][outside addr:%d]", __FUNCTION__, __LINE__, local_id); + return ONLP_STATUS_E_INVALID; + } + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2)) + rc= _onlp_thermali_psu_info_get(local_id,info); + else + rc= _onlp_thermali_info_get(local_id,info); + + return rc; +} From 234cbabf4fa1a99fc50dd415e02f9ce506b36615 Mon Sep 17 00:00:00 2001 From: Krishna Kolakaluri Date: Thu, 15 Feb 2018 11:23:54 -0800 Subject: [PATCH 141/244] Reverting Makefile changes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cbfe14b5..c183f82e 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ endif include $(ONL)/make/config.mk # All available architectures. -ALL_ARCHES := amd64 armel +ALL_ARCHES := amd64 powerpc armel arm64 # Build rule for each architecture. define build_arch_template From 4919cc9118ce1081145f7c64087a51a4c2133f69 Mon Sep 17 00:00:00 2001 From: Joe Chan Date: Thu, 25 Jan 2018 13:55:35 -0800 Subject: [PATCH 142/244] Add support for Inventec d7054q28b. --- .../x86-64/x86-64-inventec-d7054q28b/Makefile | 1 + .../modules/Makefile | 1 + .../x86-64-inventec-d7054q28b/modules/PKG.yml | 1 + .../modules/builds/Makefile | 6 + .../modules/builds/inv_cpld.c | 415 +++++++ .../modules/builds/inv_platform.c | 219 ++++ .../modules/builds/inv_psoc.c | 1046 +++++++++++++++++ .../x86-64-inventec-d7054q28b/onlp/Makefile | 1 + .../x86-64-inventec-d7054q28b/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/module/auto/make.mk | 9 + .../module/auto/x86_64_inventec_d7054q28b.yml | 50 + .../x86_64_inventec_d7054q28b.x | 14 + .../x86_64_inventec_d7054q28b_config.h | 137 +++ .../x86_64_inventec_d7054q28b_dox.h | 26 + .../x86_64_inventec_d7054q28b_porting.h | 107 ++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 329 ++++++ .../onlp/builds/src/module/src/ledi.c | 253 ++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 189 +++ .../onlp/builds/src/module/src/platform_lib.h | 82 ++ .../onlp/builds/src/module/src/psui.c | 272 +++++ .../onlp/builds/src/module/src/sfpi.c | 223 ++++ .../onlp/builds/src/module/src/sysi.c | 295 +++++ .../onlp/builds/src/module/src/thermali.c | 141 +++ .../src/x86_64_inventec_d7054q28b_config.c | 81 ++ .../src/x86_64_inventec_d7054q28b_enums.c | 10 + .../src/x86_64_inventec_d7054q28b_int.h | 12 + .../src/x86_64_inventec_d7054q28b_log.c | 18 + .../src/x86_64_inventec_d7054q28b_log.h | 12 + .../src/x86_64_inventec_d7054q28b_module.c | 24 + .../src/x86_64_inventec_d7054q28b_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-inventec-d7054q28b-r0.yml | 31 + .../x86_64_inventec_d7054q28b_r0/__init__.py | 15 + 43 files changed, 4205 insertions(+) create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_cpld.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_platform.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_psoc.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.module create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/x86_64_inventec_d7054q28b.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_config.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_enums.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_int.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.h create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_module.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_ucli.c create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/Makefile create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/PKG.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/PKG.yml new file mode 100644 index 00000000..f2339799 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d7054q28b ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/Makefile new file mode 100644 index 00000000..5ebf3b73 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := inventec +BASENAME := x86-64-inventec-d7054q28b +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_cpld.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_cpld.c new file mode 100644 index 00000000..683ffa0f --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_cpld.c @@ -0,0 +1,415 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "I2CHostCommunication.h" + +#define USE_SMBUS 1 + +/* definition */ +#define CPLD_INFO_OFFSET 0x00 +#define CPLD_PSU_OFFSET 0x08 +#define CPLD_LED_OFFSET 0x0E +#define CPLD_LED_STATU_OFFSET 0x0D +#define CPLD_CTL_OFFSET 0x0C + + + +/* Each client has this additional data */ +struct cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/*-----------------------------------------------------------------------*/ + +static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg[0].buf = msgbuf; + msg[0].len = 1; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + + status = i2c_transfer(client->adapter, msg, 2); + + if(status == 2) + status = count; + + return status; +#endif +} + +static ssize_t cpld_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + + return status; +#endif +} + +/*-----------------------------------------------------------------------*/ + +/* sysfs attributes for hwmon */ + +static ssize_t show_info(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //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 b[4]; + + memset(b, 0, 4); + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, b, CPLD_INFO_OFFSET, 4); + mutex_unlock(&data->update_lock); + + if(status != 4) return sprintf(buf, "read cpld info fail\n"); + + status = sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", b[2] & 0xf, (b[3] & 0x1f), 2014+(b[2] >> 4)); /* mm/dd/yyyy*/ + status = sprintf (buf, "%sThe PCB version is %X%X\n", buf, b[0]>>4, b[0]&0xf); + status = sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, b[1]>>4, b[1]&0xf); + + return strlen(buf); +} + + +static ssize_t show_ctl(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //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 b[1]; + + mutex_lock(&data->update_lock); + + status = cpld_i2c_read(client, b, CPLD_CTL_OFFSET, 1); + + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld ctl fail\n"); + + + status = sprintf (buf, "0x%X\n", b[0]); + + return strlen(buf); +} + +static ssize_t set_ctl(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 byte; + + u8 temp = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + cpld_i2c_read(client, &byte, CPLD_CTL_OFFSET, 1); + if(temp) byte |= (1<<0); + else byte &= ~(1<<0); + cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + + +static char* led_str[] = { + "OFF", //000 + "0.5 Hz", //001 + "1 Hz", //010 + "2 Hz", //011 + "NA", //100 + "NA", //101 + "NA", //110 + "ON", //111 +}; + +static ssize_t show_led(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + 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 byte; + int shift = (attr->index == 0)?3:0; + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld offset 0x%x\n", CPLD_LED_OFFSET); + + byte = (byte >> shift) & 0x7; + + /* + 0: off + 1: 0.5hz + 2: 1 hz + 3: 2 hz + 4~6: not define + 7: on + */ + + status = sprintf (buf, "%d: %s\n", byte, led_str[byte]); + + return strlen(buf); +} + +static ssize_t set_led(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + + u8 temp = simple_strtol(buf, NULL, 16); + u8 byte; + int shift = (attr->index == 0)?3:0; + + temp &= 0x7; + //validate temp value: 0,1,2,3,7, TBD + + mutex_lock(&data->update_lock); + cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); + byte &= ~(0x7<update_lock); + + return count; +} + +/* +CPLD report the PSU0 status +000 = PSU normal operation +100 = PSU fault +010 = PSU unpowered +111 = PSU not installed + +7 6 | 5 4 3 | 2 1 0 +---------------------- + | psu0 | psu1 +*/ +static char* psu_str[] = { + "normal", //000 + "NA", //001 + "unpowered", //010 + "NA", //011 + "fault", //100 + "NA", //101 + "NA", //110 + "not installed", //111 +}; + +static ssize_t show_psu(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + 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 byte; + int shift = (attr->index == 1)?0:3; + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1); + mutex_unlock(&data->update_lock); + + byte = (byte >> shift) & 0x7; + + status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); + + return strlen(buf); +} + + +static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0); +static SENSOR_DEVICE_ATTR(ctl, S_IWUSR|S_IRUGO, show_ctl, set_ctl, 0); + +static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_led, set_led, 0); +static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, 1); + +static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0); +static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1); + +static struct attribute *cpld_attributes[] = { + //info + &sensor_dev_attr_info.dev_attr.attr, + &sensor_dev_attr_ctl.dev_attr.attr, + + &sensor_dev_attr_grn_led.dev_attr.attr, + &sensor_dev_attr_red_led.dev_attr.attr, + + &sensor_dev_attr_psu0.dev_attr.attr, + &sensor_dev_attr_psu1.dev_attr.attr, + + NULL +}; + +static const struct attribute_group cpld_group = { + .attrs = cpld_attributes, +}; + +/*-----------------------------------------------------------------------*/ + +/* device probe and removal */ + +static int +cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct cpld_data *data; + int status; + + printk("+%s\n", __func__); + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + return -EIO; + + data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &cpld_group); + if (status) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sensor '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &cpld_group); +exit_free: + i2c_set_clientdata(client, NULL); + kfree(data); + return status; +} + +static int cpld_remove(struct i2c_client *client) +{ + struct cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &cpld_group); + i2c_set_clientdata(client, NULL); + kfree(data); + return 0; +} + +static const struct i2c_device_id cpld_ids[] = { + { "inv_cpld", 0, }, + { /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, cpld_ids); + +static struct i2c_driver cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "inv_cpld", + }, + .probe = cpld_probe, + .remove = cpld_remove, + .id_table = cpld_ids, +}; + +/*-----------------------------------------------------------------------*/ + +/* module glue */ + +static int __init inv_cpld_init(void) +{ + return i2c_add_driver(&cpld_driver); +} + +static void __exit inv_cpld_exit(void) +{ + i2c_del_driver(&cpld_driver); +} + +MODULE_AUTHOR("eddie.lan "); +MODULE_DESCRIPTION("inv cpld driver"); +MODULE_LICENSE("GPL"); + +module_init(inv_cpld_init); +module_exit(inv_cpld_exit); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_platform.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_platform.c new file mode 100644 index 00000000..ea269700 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/modules/builds/inv_platform.c @@ -0,0 +1,219 @@ +#include +//#include +#include +#include +#include +#include +#include + +#include +//#include +//#include + +//#include +//#define IO_EXPAND_BASE 64 +//#define IO_EXPAND_NGPIO 16 + +struct inv_i2c_board_info { + int ch; + int size; + struct i2c_board_info *board_info; +}; + +#define bus_id(id) (id) +static struct pca954x_platform_mode mux_modes_0[] = { + {.adap_id = bus_id(2),}, {.adap_id = bus_id(3),}, + {.adap_id = bus_id(4),}, {.adap_id = bus_id(5),}, + {.adap_id = bus_id(6),}, {.adap_id = bus_id(7),}, + {.adap_id = bus_id(8),}, {.adap_id = bus_id(9),}, +}; +static struct pca954x_platform_mode mux_modes_0_0[] = { + {.adap_id = bus_id(10),}, {.adap_id = bus_id(11),}, + {.adap_id = bus_id(12),}, {.adap_id = bus_id(13),}, + {.adap_id = bus_id(14),}, {.adap_id = bus_id(15),}, + {.adap_id = bus_id(16),}, {.adap_id = bus_id(17),}, +}; + +static struct pca954x_platform_mode mux_modes_0_1[] = { + {.adap_id = bus_id(18),}, {.adap_id = bus_id(19),}, + {.adap_id = bus_id(20),}, {.adap_id = bus_id(21),}, + {.adap_id = bus_id(22),}, {.adap_id = bus_id(23),}, + {.adap_id = bus_id(24),}, {.adap_id = bus_id(25),}, +}; + +static struct pca954x_platform_mode mux_modes_0_2[] = { + {.adap_id = bus_id(26),}, {.adap_id = bus_id(27),}, + {.adap_id = bus_id(28),}, {.adap_id = bus_id(29),}, + {.adap_id = bus_id(30),}, {.adap_id = bus_id(31),}, + {.adap_id = bus_id(32),}, {.adap_id = bus_id(33),}, +}; + +static struct pca954x_platform_mode mux_modes_0_3[] = { + {.adap_id = bus_id(34),}, {.adap_id = bus_id(35),}, + {.adap_id = bus_id(36),}, {.adap_id = bus_id(37),}, + {.adap_id = bus_id(38),}, {.adap_id = bus_id(39),}, + {.adap_id = bus_id(40),}, {.adap_id = bus_id(41),}, +}; + +static struct pca954x_platform_mode mux_modes_0_4[] = { + {.adap_id = bus_id(42),}, {.adap_id = bus_id(43),}, + {.adap_id = bus_id(44),}, {.adap_id = bus_id(45),}, + {.adap_id = bus_id(46),}, {.adap_id = bus_id(47),}, + {.adap_id = bus_id(48),}, {.adap_id = bus_id(49),}, +}; + +static struct pca954x_platform_mode mux_modes_0_5[] = { + {.adap_id = bus_id(50),}, {.adap_id = bus_id(51),}, + {.adap_id = bus_id(52),}, {.adap_id = bus_id(53),}, + {.adap_id = bus_id(54),}, {.adap_id = bus_id(55),}, + {.adap_id = bus_id(56),}, {.adap_id = bus_id(57),}, +}; + +static struct pca954x_platform_mode mux_modes_0_6[] = { + {.adap_id = bus_id(58),}, {.adap_id = bus_id(59),}, + {.adap_id = bus_id(60),}, {.adap_id = bus_id(61),}, + {.adap_id = bus_id(62),}, {.adap_id = bus_id(63),}, + {.adap_id = bus_id(64),}, {.adap_id = bus_id(65),}, +}; + +//no i2c device driver attach to mux 7 + + +static struct pca954x_platform_data mux_data_0 = { + .modes = mux_modes_0, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_0 = { + .modes = mux_modes_0_0, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_1 = { + .modes = mux_modes_0_1, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_2 = { + .modes = mux_modes_0_2, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_3 = { + .modes = mux_modes_0_3, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_4 = { + .modes = mux_modes_0_4, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_5 = { + .modes = mux_modes_0_5, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_6 = { + .modes = mux_modes_0_6, + .num_modes = 8, +}; + +static struct i2c_board_info i2c_device_info0[] __initdata = { + {"inv_psoc", 0, 0x66, 0, 0, 0},//psoc + {"inv_cpld", 0, 0x55, 0, 0, 0},//cpld + {"pca9548", 0, 0x71, &mux_data_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info2[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, +}; +static struct i2c_board_info i2c_device_info3[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, +}; +static struct i2c_board_info i2c_device_info4[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, +}; +static struct i2c_board_info i2c_device_info5[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_3, 0, 0}, +}; +static struct i2c_board_info i2c_device_info6[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_4, 0, 0}, +}; +static struct i2c_board_info i2c_device_info7[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_5, 0, 0}, +}; +static struct i2c_board_info i2c_device_info8[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_6, 0, 0}, +}; + + +static struct inv_i2c_board_info i2cdev_list[] = { + {0, ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //smbus 0 + + {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //mux 0 + {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //mux 1 + {bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //mux 2 + {bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, //mux 3 + {bus_id(6), ARRAY_SIZE(i2c_device_info6), i2c_device_info6 }, //mux 4 + {bus_id(7), ARRAY_SIZE(i2c_device_info7), i2c_device_info7 }, //mux 5 + {bus_id(8), ARRAY_SIZE(i2c_device_info8), i2c_device_info8 }, //mux 6 + +}; + +///////////////////////////////////////////////////////////////////////////////////////// +#if 0 +static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { + .scl_pin = 58, + .sda_pin = 75, + + .udelay = 5, //5:100kHz + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, + .scl_is_output_only = 0 +}; + +static struct platform_device device_i2c_gpio0 = { + .name = "i2c-gpio", + .id = 0, // adapter number + .dev.platform_data = &i2c_gpio_platdata0, +}; +#endif +static int __init inv_platform_init(void) +{ + struct i2c_adapter *adap = NULL; + struct i2c_client *e = NULL; + int ret = 0; + int i,j; + + printk("%s \n", __func__); + +#if 0 + //use i2c-gpio + //register i2c gpio + //config gpio58,75 to gpio function 58=32+3*8+2 75=32*2+8*1+3 + outl( inl(0x533) | (1<<2), 0x533); + outl( inl(0x541) | (1<<3), 0x541); + + ret = platform_device_register(&device_i2c_gpio0); + if (ret) { + printk(KERN_ERR "i2c-gpio: device_i2c_gpio0 register fail %d\n", ret); + } + #endif + for(i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "I2CHostCommunication.h" + +#define IMPLEMENT_IPMI_CODE 1 +int USE_IPMI=0; +//================================= +#if IMPLEMENT_IPMI_CODE +#include +#include +#include +#include + +#define IPMI_MAX_INTF (4) +#define NETFN_OEM 0x30 +#define CMD_GETDATA 0x31 +#define CMD_SETDATA 0x32 + +struct mutex ipmi_mutex; + +static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data); +static ipmi_user_t ipmi_mh_user = NULL; +static struct ipmi_user_hndl ipmi_hndlrs = { .ipmi_recv_hndl = msg_handler,}; + +static atomic_t dummy_count = ATOMIC_INIT(0); +static void dummy_smi_free(struct ipmi_smi_msg *msg) +{ + atomic_dec(&dummy_count); +} +static void dummy_recv_free(struct ipmi_recv_msg *msg) +{ + atomic_dec(&dummy_count); +} +static struct ipmi_smi_msg halt_smi_msg = { + .done = dummy_smi_free +}; +static struct ipmi_recv_msg halt_recv_msg = { + .done = dummy_recv_free +}; +#endif +//================================= + +#define USE_SMBUS 1 + +#define FAN_NUM 4 +#define PSU_NUM 2 + +struct __attribute__ ((__packed__)) psoc_psu_layout { + u16 psu1_iin; + u16 psu2_iin; + u16 psu1_iout; + u16 psu2_iout; + + u16 psu1_pin; + u16 psu2_pin; + u16 psu1_pout; + u16 psu2_pout; + + u16 psu1_vin; + u16 psu2_vin; + u16 psu1_vout; + u16 psu2_vout; +}; + +struct __attribute__ ((__packed__)) psoc_layout { + u8 ctl; //offset: 0 + u16 switch_temp; //offset: 1 + u8 reserve0; //offset: 3 + + u8 fw_upgrade; //offset: 4 + + //i2c bridge + u8 i2c_st; //offset: 5 + u8 i2c_ctl; //offset: 6 + u8 i2c_addr; //offset: 7 + u8 i2c_data[0x20]; //offset: 8 + + //gpo + u8 led_ctl; //offset: 28 + + u8 gpio; //offset: 29 + + //pwm duty + u8 pwm[FAN_NUM]; //offset: 2a + u8 pwm_psu[PSU_NUM]; //offset: 2e + + //fan rpm + u16 fan[FAN_NUM*2]; //offset: 30 + + u8 reserve1[4]; //offset: 40 + + //gpi + u8 gpi_fan; //offset: 44 + + //psu state + u8 psu_state; //offset: 45 + + //temperature + u16 temp[5]; //offset: 46 + u16 temp_psu[PSU_NUM]; //offset: 50 + + //version + u8 version[2]; //offset: 54 + + u8 reserve2[4]; //offset: 56 + struct psoc_psu_layout psu_info; //offset: 5a +}; + +/* definition */ +/* definition */ +#define PSOC_OFF(m) offsetof(struct psoc_layout, m) +#define PSOC_PSU_OFF(m) offsetof(struct psoc_psu_layout, m) + +#define SWITCH_TMP_OFFSET PSOC_OFF(switch_temp) +#define PWM_OFFSET PSOC_OFF(pwm) +#define THERMAL_OFFSET PSOC_OFF(temp) +#define RPM_OFFSET PSOC_OFF(fan) +#define DIAG_FLAG_OFFSET PSOC_OFF(ctl) +#define FAN_LED_OFFSET PSOC_OFF(led_ctl) +#define FAN_GPI_OFFSET PSOC_OFF(gpi_fan) +#define PSOC_PSU_OFFSET PSOC_OFF(psu_state) +#define VERSION_OFFSET PSOC_OFF(version) +#define PSU_INFO_OFFSET PSOC_OFF(psu_info) + +/* Each client has this additional data */ +struct psoc_data { + struct device *hwmon_dev; + struct mutex update_lock; + u32 diag; +}; + +/*-----------------------------------------------------------------------*/ +#if IMPLEMENT_IPMI_CODE +static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data) +{ + struct completion *comp = recv_msg->user_msg_data; + if (comp) + complete(comp); + else + ipmi_free_recv_msg(recv_msg); + return; +} + +int ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) +{ + int rv=0,i; + struct ipmi_system_interface_addr addr; + uint8_t _data[data_length]; + struct kernel_ipmi_msg msg; + struct completion comp; + + if(!mutex_trylock(&ipmi_mutex)) return 0; + +// for (i=0,rv=1; iaddr; + msg[0].buf = msgbuf; + msg[0].len = 1; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + + status = i2c_transfer(client->adapter, msg, 2); + + if(status == 2) + status = count; + + return status; +#endif +} + +static ssize_t psoc_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) +{ +#if USE_SMBUS +if(USE_IPMI==0) +{ + int i; + + for(i=0; iaddr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + + return status; +#endif +} + +#if 0 +static u32 psoc_read32(struct i2c_client *client, u8 offset) +{ + u32 value = 0; + u8 buf[4]; + + if( psoc_i2c_read(client, buf, offset, 4) == 4) + value = (buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3]); + + return value; +} +#endif + +static u16 psoc_read16(struct i2c_client *client, u8 offset) +{ + u16 value = 0; + u8 buf[2]; + + if(psoc_i2c_read(client, buf, offset, 2) == 2) + value = (buf[0]<<8 | buf[1]<<0); + + return value; +} + +static u8 psoc_read8(struct i2c_client *client, u8 offset) +{ + u8 value = 0; + u8 buf = 0; + + if(psoc_i2c_read(client, &buf, offset, 1) == 1) + value = buf; + + return value; +} + +//PSOC i2c bridge regsters +#define PSOC_I2C_STATUS 0x05 +#define PSOC_I2C_CNTRL 0x06 +#define PSOC_I2C_ADDR 0x07 +#define PSOC_I2C_DATA 0x08 + +//status bit definition +#define PSOC_I2C_START (1 << 0) +#define PSOC_PMB_SEL (1 << 7) + +//addr bits definition +#define PSOC_I2C_READ (1 << 0) + +//PMBUS registers definition +#define PMBUS_READ_VIN (0x88) +#define PMBUS_READ_IIN (0x89) +#define PMBUS_READ_VOUT (0x8B) +#define PMBUS_READ_IOUT (0x8C) +#define PMBUS_READ_POUT (0x96) +#define PMBUS_READ_PIN (0x97) + +/* +CPLD report the PSU0 status +000 = PSU normal operation +100 = PSU fault +010 = PSU unpowered +111 = PSU not installed + +7 6 | 5 4 3 | 2 1 0 +---------------------- + | psu1 | psu0 +*/ +static char* psu_str[] = { + "normal", //000 + "NA", //001 + "unpowered", //010 + "NA", //011 + "fault", //100 + "NA", //101 + "NA", //110 + "not installed", //111 +}; + +static ssize_t show_psu_st(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 byte; + int shift = (attr->index == 0)?3:0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET, 1); + mutex_unlock(&data->update_lock); + + byte = (byte >> shift) & 0x7; + + status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); + + return strlen(buf); +} + +/*-----------------------------------------------------------------------*/ + +/* sysfs attributes for hwmon */ +#define PSU1 0x5800 +#define PSU2 0x5900 +#define BMC_I2cBus 3 //BMC's I2C-1 +#define PMBus_Vender 0x99 +#define PMBus_Serial 0x9E +#define PMBus_Temp2 0x8E +#define PMBus_Version 0x9B +#define MaxLeng_Result 0x20 +#define MaxLog +static long pmbus_reg2data_linear(int data, int linear16); + + +static ssize_t show_ipmi_i2c(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + uint8_t data[4],result[MaxLeng_Result]; + int result_len; + + data[0] = BMC_I2cBus; + data[1] = (attr->index & 0xFF00 ) >>7; + data[3] = attr->index & 0xff; + if(data[3]==PMBus_Temp2) + data[2]=2; + else + data[2]=MaxLeng_Result; + + if(ipmi_command(0x06, 0x52,data,4, result, &result_len)==0) + { + if(data[3]==PMBus_Temp2) + { + return sprintf(buf, "%ld \n", pmbus_reg2data_linear(result[0] | (result[1]<<8), 0 )); + } + result[result[0]+1]='\0'; + + return sprintf(buf, "%s\n",&result[1] ); + } + else + return 0; +} + +static ssize_t show_ipmi_sollog(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + uint8_t data[5],result[256]; + int result_len; + uint32_t i; + + for(i=0;i<0xffffff;i+=255) + { + data[0] = attr->index; + data[1] = (i & 0x0000ff); + data[2] = (i & 0x00ff00)>>8; + data[3] = (i & 0xff0000)>>16; + data[4] = 0; + + result_len=0; + + if(ipmi_command(0x32, 0xFE, data, 5, result, &result_len)==0) + { + if(result_len==0) break; + result[result_len+1]='\0'; + printk("%s",result); + } + else break; + + if(result_len==0) break; + } + + return 0; +} + +static ssize_t show_thermal(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index * 2 + THERMAL_OFFSET; + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + (s8)(status>>8) * 1000 ); +} + + + +static ssize_t show_pwm(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index + PWM_OFFSET; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + status); +} + +static ssize_t set_pwm(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index + PWM_OFFSET; + + u8 pwm = simple_strtol(buf, NULL, 10); + if(pwm > 255) pwm = 255; + + if(data->diag) { + mutex_lock(&data->update_lock); + psoc_i2c_write(client, &pwm, offset, 1); + mutex_unlock(&data->update_lock); + } + + return count; +} + + +static ssize_t show_rpm(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index*2 + RPM_OFFSET; + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + status); +} + +static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u16 temp = 0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, (u8*)&temp, SWITCH_TMP_OFFSET, 2); + mutex_unlock(&data->update_lock); + + status = sprintf (buf, "%d\n", (s8)(temp>>8) * 1000 ); + + return strlen(buf); +} + +static ssize_t set_switch_tmp(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + + long temp = simple_strtol(buf, NULL, 10); + u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; + + //printk("set_switch_tmp temp=%d, temp2=0x%x (%x,%x)\n", temp, temp2, ( ( (temp/1000) <<8 ) & 0xFF00 ), (( (temp%1000) / 10 ) & 0xFF)); + + mutex_lock(&data->update_lock); + psoc_i2c_write(client, (u8*)&temp2, SWITCH_TMP_OFFSET, 2); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_diag(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 diag_flag = 0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, (u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); + mutex_unlock(&data->update_lock); + + data->diag = (diag_flag & 0x80)?1:0; + status = sprintf (buf, "%d\n", data->diag); + + return strlen(buf); +} + +static ssize_t set_diag(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 value = 0; + u8 diag = simple_strtol(buf, NULL, 10); + + diag = diag?1:0; + data->diag = diag; + + mutex_lock(&data->update_lock); + psoc_i2c_read(client, (u8*)&value, DIAG_FLAG_OFFSET, 1); + if(diag) value |= (1<<7); + else value &= ~(1<<7); + psoc_i2c_write(client, (u8*)&value, DIAG_FLAG_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, VERSION_OFFSET); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "ver: %x.%x\n", (status & 0xFF00)>>8, (status & 0xFF) ); +} + + +static ssize_t show_fan_led(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 bit = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, FAN_LED_OFFSET); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + (status & (1<index; + u8 led_state = 0; + + u8 v = simple_strtol(buf, NULL, 10); + + if(data->diag) { + mutex_lock(&data->update_lock); + led_state = psoc_read8(client, FAN_LED_OFFSET); + if(v) led_state |= (1<update_lock); + } + + return count; +} + +static ssize_t show_value8(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "0x%02X\n", status ); +} + +static long pmbus_reg2data_linear(int data, int linear16) +{ + s16 exponent; + s32 mantissa; + long val; + + if (linear16) { /* LINEAR16 */ + exponent = -9; + mantissa = (u16) data; + } else { /* LINEAR11 */ + exponent = ((s16)data) >> 11; + exponent = ((s16)( data & 0xF800) ) >> 11; + mantissa = ((s32)((data & 0x7ff) << 5)) >> 5; + } + + //printk("data=%d, m=%d, e=%d\n", data, exponent, mantissa); + val = mantissa; + + /* scale result to micro-units for power sensors */ + val = val * 1000L; + + if (exponent >= 0) + val <<= exponent; + else + val >>= -exponent; + + return val; +} + +static ssize_t show_psu_psoc(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index + PSU_INFO_OFFSET; + + mutex_lock(&data->update_lock); + status = psoc_read16(client, offset); + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, strstr(attr->dev_attr.attr.name, "vout")? 1:0 )); +} + + + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_thermal, 0, 0); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_thermal, 0, 1); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_thermal, 0, 2); +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_thermal, 0, 3); +static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_thermal, 0, 4); +static SENSOR_DEVICE_ATTR(thermal_psu1, S_IRUGO, show_thermal, 0, 5); +static SENSOR_DEVICE_ATTR(thermal_psu2, S_IRUGO, show_thermal, 0, 6); + +static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0); +static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 1); +static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 2); +static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 3); +static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4); +static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5); + +static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu_st, 0, 0); +static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 1); + +static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_rpm, 0, 0); +static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_rpm, 0, 1); +static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_rpm, 0, 2); +static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_rpm, 0, 3); +static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_rpm, 0, 4); +static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_rpm, 0, 5); +static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_rpm, 0, 6); +static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_rpm, 0, 7); +static SENSOR_DEVICE_ATTR(rpm_psu1, S_IRUGO, show_rpm, 0, 8); +static SENSOR_DEVICE_ATTR(rpm_psu2, S_IRUGO, show_rpm, 0, 9); + +static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); + +static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0); +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, 0, 0); + +static SENSOR_DEVICE_ATTR(fan_led_grn1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); +static SENSOR_DEVICE_ATTR(fan_led_grn2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1); +static SENSOR_DEVICE_ATTR(fan_led_grn3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2); +static SENSOR_DEVICE_ATTR(fan_led_grn4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3); +static SENSOR_DEVICE_ATTR(fan_led_red1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4); +static SENSOR_DEVICE_ATTR(fan_led_red2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5); +static SENSOR_DEVICE_ATTR(fan_led_red3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6); +static SENSOR_DEVICE_ATTR(fan_led_red4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 7); + +static SENSOR_DEVICE_ATTR(fan_gpi, S_IRUGO, show_value8, 0, FAN_GPI_OFFSET); +static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); +static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); +static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pout)); + + +static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); +static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); +static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); + +//IPMI +static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_i2c, 0, PSU1 | PMBus_Temp2); +static SENSOR_DEVICE_ATTR(psoc_psu1_vender, S_IRUGO, show_ipmi_i2c, 0, PSU1 | PMBus_Vender); +static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_i2c, 0, PSU1 | PMBus_Serial); +static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_i2c, 0, PSU1 | PMBus_Version); + +static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_i2c, 0, PSU2 | PMBus_Temp2); +static SENSOR_DEVICE_ATTR(psoc_psu2_vender, S_IRUGO, show_ipmi_i2c, 0, PSU2 | PMBus_Vender); +static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_i2c, 0, PSU2 | PMBus_Serial); +static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_i2c, 0, PSU2 | PMBus_Version); + +static SENSOR_DEVICE_ATTR(sollog1, S_IRUGO, show_ipmi_sollog, 0, 1); +static SENSOR_DEVICE_ATTR(sollog2, S_IRUGO, show_ipmi_sollog, 0, 2); + +static struct attribute *psoc_attributes[] = { + //thermal + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp4_input.dev_attr.attr, + &sensor_dev_attr_temp5_input.dev_attr.attr, + + &sensor_dev_attr_thermal_psu1.dev_attr.attr, + &sensor_dev_attr_thermal_psu2.dev_attr.attr, + + + //pwm + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm2.dev_attr.attr, + &sensor_dev_attr_pwm3.dev_attr.attr, + &sensor_dev_attr_pwm4.dev_attr.attr, + &sensor_dev_attr_pwm_psu1.dev_attr.attr, + &sensor_dev_attr_pwm_psu2.dev_attr.attr, + + //rpm + &sensor_dev_attr_fan1_input.dev_attr.attr, + &sensor_dev_attr_fan2_input.dev_attr.attr, + &sensor_dev_attr_fan3_input.dev_attr.attr, + &sensor_dev_attr_fan4_input.dev_attr.attr, + &sensor_dev_attr_fan5_input.dev_attr.attr, + &sensor_dev_attr_fan6_input.dev_attr.attr, + &sensor_dev_attr_fan7_input.dev_attr.attr, + &sensor_dev_attr_fan8_input.dev_attr.attr, + + &sensor_dev_attr_rpm_psu1.dev_attr.attr, + &sensor_dev_attr_rpm_psu2.dev_attr.attr, + + //switch temperature + &sensor_dev_attr_switch_tmp.dev_attr.attr, + + //diag flag + &sensor_dev_attr_diag.dev_attr.attr, + + //version + &sensor_dev_attr_version.dev_attr.attr, + + //fan led + &sensor_dev_attr_fan_led_grn1.dev_attr.attr, + &sensor_dev_attr_fan_led_grn2.dev_attr.attr, + &sensor_dev_attr_fan_led_grn3.dev_attr.attr, + &sensor_dev_attr_fan_led_grn4.dev_attr.attr, + &sensor_dev_attr_fan_led_red1.dev_attr.attr, + &sensor_dev_attr_fan_led_red2.dev_attr.attr, + &sensor_dev_attr_fan_led_red3.dev_attr.attr, + &sensor_dev_attr_fan_led_red4.dev_attr.attr, + + //fan GPI + &sensor_dev_attr_fan_gpi.dev_attr.attr, + &sensor_dev_attr_psu0.dev_attr.attr, + &sensor_dev_attr_psu1.dev_attr.attr, + + + //psu_psoc, new added on psoc 1.9 + &sensor_dev_attr_psoc_psu1_vin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_vout.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_iin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_iout.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_pin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_pout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_iin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_iout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_pin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_pout.dev_attr.attr, + + //ipmi_command + &sensor_dev_attr_thermal2_psu1.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_vender.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_serial.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_version.dev_attr.attr, + + &sensor_dev_attr_thermal2_psu2.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vender.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_serial.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, + + &sensor_dev_attr_sollog1.dev_attr.attr, + &sensor_dev_attr_sollog2.dev_attr.attr, + + NULL +}; + +static const struct attribute_group psoc_group = { + .attrs = psoc_attributes, +}; + +/*-----------------------------------------------------------------------*/ + +/* device probe and removal */ + +static int +psoc_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct psoc_data *data; + int status,i,rv; + + printk("+%s\n", __func__); + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + return -EIO; + + data = kzalloc(sizeof(struct psoc_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->diag = 0; + +#if IMPLEMENT_IPMI_CODE + for (i=0,rv=1; idev.kobj, &psoc_group); + if (status) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sensor '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &psoc_group); +exit_free: + i2c_set_clientdata(client, NULL); + kfree(data); + return status; +} + +static int psoc_remove(struct i2c_client *client) +{ + struct psoc_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &psoc_group); + i2c_set_clientdata(client, NULL); + kfree(data); + return 0; +} + +static const struct i2c_device_id psoc_ids[] = { + { "inv_psoc", 0, }, + { /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, psoc_ids); + +static struct i2c_driver psoc_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "inv_psoc", + }, + .probe = psoc_probe, + .remove = psoc_remove, + .id_table = psoc_ids, +}; + +/*-----------------------------------------------------------------------*/ + +/* module glue */ + +static int __init inv_psoc_init(void) +{ + return i2c_add_driver(&psoc_driver); +} + +static void __exit inv_psoc_exit(void) +{ + i2c_del_driver(&psoc_driver); +} + +MODULE_AUTHOR("eddie.lan "); +MODULE_DESCRIPTION("inv psoc driver"); +MODULE_LICENSE("GPL"); + +module_init(inv_psoc_init); +module_exit(inv_psoc_exit); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/PKG.yml new file mode 100644 index 00000000..a81555f9 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d7054q28b ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/Makefile new file mode 100644 index 00000000..e874a161 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-inventec-d7054q28b +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_inventec_d7054q28b onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-inventec-d7054q28b.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..433f17e5 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_inventec_d7054q28b onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.module b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.module new file mode 100644 index 00000000..b7de4f1f --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_inventec_d7054q28b diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/Makefile new file mode 100644 index 00000000..9773a348 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_inventec_d7054q28b +AUTOMODULE := x86_64_inventec_d7054q28b +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..05bad579 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_inventec_d7054q28b Autogeneration +# +############################################################################### +x86_64_inventec_d7054q28b_AUTO_DEFS := module/auto/x86_64_inventec_d7054q28b.yml +x86_64_inventec_d7054q28b_AUTO_DIRS := module/inc/x86_64_inventec_d7054q28b module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/x86_64_inventec_d7054q28b.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/x86_64_inventec_d7054q28b.yml new file mode 100644 index 00000000..e4fee295 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/auto/x86_64_inventec_d7054q28b.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_inventec_d7054q28b Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_INVENTEC_D7032Q28B_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_inventec_d7054q28b_config + + portingmacro: + X86_64_INVENTEC_D7032Q28B: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x new file mode 100644 index 00000000..603d93f3 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h new file mode 100644 index 00000000..b141a03a --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_inventec_d7054q28b Configuration Header + * + * @addtogroup x86_64_inventec_d7054q28b-config + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7054q28b_CONFIG_H__ +#define __x86_64_inventec_d7054q28b_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef x86_64_inventec_d7054q28b_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING +#define x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT +#define x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT +#define x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB +#define x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI +#define x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_inventec_d7054q28b_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_inventec_d7054q28b_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_inventec_d7054q28b_config_settings table. */ +extern x86_64_inventec_d7054q28b_config_settings_t x86_64_inventec_d7054q28b_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_inventec_d7054q28b_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_inventec_d7054q28b_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_inventec_d7054q28b_porting.h" + +#endif /* __x86_64_inventec_d7054q28b_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h new file mode 100644 index 00000000..9d35e4de --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_inventec_d7054q28b Doxygen Header + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7054q28b_DOX_H__ +#define __x86_64_inventec_d7054q28b_DOX_H__ + +/** + * @defgroup x86_64_inventec_d7054q28b x86_64_inventec_d7054q28b - x86_64_inventec_d7054q28b Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_inventec_d7054q28b-x86_64_inventec_d7054q28b Public Interface + * @defgroup x86_64_inventec_d7054q28b-config Compile Time Configuration + * @defgroup x86_64_inventec_d7054q28b-porting Porting Macros + * + * @} + * + */ + +#endif /* __x86_64_inventec_d7054q28b_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h new file mode 100644 index 00000000..5d26beff --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_inventec_d7054q28b Porting Macros. + * + * @addtogroup x86_64_inventec_d7054q28b-porting + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7054q28b_PORTING_H__ +#define __x86_64_inventec_d7054q28b_PORTING_H__ + + +/* */ +#if x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_inventec_d7054q28b_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_inventec_d7054q28b_MALLOC GLOBAL_MALLOC + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_MALLOC malloc + #else + #error The macro x86_64_inventec_d7054q28b_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_FREE + #if defined(GLOBAL_FREE) + #define x86_64_inventec_d7054q28b_FREE GLOBAL_FREE + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_FREE free + #else + #error The macro x86_64_inventec_d7054q28b_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_inventec_d7054q28b_MEMSET GLOBAL_MEMSET + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_MEMSET memset + #else + #error The macro x86_64_inventec_d7054q28b_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_inventec_d7054q28b_MEMCPY GLOBAL_MEMCPY + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_MEMCPY memcpy + #else + #error The macro x86_64_inventec_d7054q28b_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_inventec_d7054q28b_STRNCPY GLOBAL_STRNCPY + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_STRNCPY strncpy + #else + #error The macro x86_64_inventec_d7054q28b_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_inventec_d7054q28b_VSNPRINTF GLOBAL_VSNPRINTF + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_VSNPRINTF vsnprintf + #else + #error The macro x86_64_inventec_d7054q28b_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_inventec_d7054q28b_SNPRINTF GLOBAL_SNPRINTF + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_SNPRINTF snprintf + #else + #error The macro x86_64_inventec_d7054q28b_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7054q28b_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_inventec_d7054q28b_STRLEN GLOBAL_STRLEN + #elif x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7054q28b_STRLEN strlen + #else + #error The macro x86_64_inventec_d7054q28b_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __x86_64_inventec_d7054q28b_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..1b13eecc --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_inventec_d7054q28b_INCLUDES := -I $(THIS_DIR)inc +x86_64_inventec_d7054q28b_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_inventec_d7054q28b_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d7054q28b ucli:x86_64_inventec_d7054q28b + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..2fea5242 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_inventec_d7054q28b_ucli.c + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/fani.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..25addc7f --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/fani.c @@ -0,0 +1,329 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" + +#define PREFIX_PATH_ON_MAIN_BOARD "/sys/bus/i2c/devices/2-0066/" +#define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 18000 +#define MAX_PSU_FAN_SPEED 25500 + +#define PROJECT_NAME +#define LEN_FILE_NAME 80 + +#define FAN_RESERVED 0 +#define FAN_1_ON_MAIN_BOARD 1 +#define FAN_2_ON_MAIN_BOARD 2 +#define FAN_3_ON_MAIN_BOARD 3 +#define FAN_4_ON_MAIN_BOARD 4 +#define FAN_5_ON_MAIN_BOARD 5 +#define FAN_6_ON_MAIN_BOARD 6 +#define FAN_1_ON_PSU1 7 +#define FAN_1_ON_PSU2 8 + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ + { #prj"fan"#id"_present", #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \ + #prj"fan"#id"_direction", #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) + +#define MAKE_FAN_PATH_ON_PSU(folder) \ + {"", #folder"/psu_fan1_fault", #folder"/psu_fan1_speed_rpm", \ + "", #folder"/psu_fan1_duty_cycle_percentage", "" } + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value, ret; + + /* get fan present status + */ + ret = onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_B2F : ONLP_FAN_STATUS_F2B; + + + /* get front fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + ret = onlp_file_read_int(&value, "%s""fan_max_speed_rpm", FAN_BOARD_PATH); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->percentage = (info->rpm * 100)/value; + + return ONLP_STATUS_OK; +} + + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan fault status + */ + if (psu_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + /* get fan speed + */ + if (psu_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } + + return ONLP_STATUS_OK; +} + + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = linfo[local_id]; + + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + rc = _onlp_fani_info_get_fan_on_psu(local_id, info); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + case FAN_3_ON_MAIN_BOARD: + case FAN_4_ON_MAIN_BOARD: + case FAN_5_ON_MAIN_BOARD: + case FAN_6_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_pmbus_info_set(PSU1_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_pmbus_info_set(PSU2_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + if (onlp_file_write_int(p, path, NULL) != 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/ledi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..1a907343 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,253 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/inventec_d7054q28b_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * Diag LED Off + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (onlp_file_write_int(onlp_to_driver_led_mode(local_id, mode), fullpath, NULL) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..f36bc85e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_inventec_d7054q28b +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..9e4c5e06 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,189 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_NODE_MAX_PATH_LEN 64 + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) +{ + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + return onlp_file_read((uint8_t*)buffer, buf_size, &data_len, "%s", filename); +} + +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 11 +#define I2C_PSU_FAN_DIR_LEN 3 +#include +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name); + + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if(isspace(model_name[strlen(model_name)-1])) { + model_name[strlen(model_name)-1] = 0; + } + + if (strncmp(model_name, "YM-2651Y", 8) == 0) { + if (modelname) { + strncpy(modelname, model_name, 8); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + } + + if (strncmp(model_name, "YM-2651V", 8) == 0) { + if (modelname) { + strncpy(modelname, model_name, 8); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_DC_48V_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_DC_48V_B2F; + } + } + + if (strncmp(model_name, "PSU-12V-750", 11) == 0) { + if (modelname) { + strncpy(modelname, model_name, 11); + } + + node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_fan_dir) : PSU2_AC_HWMON_NODE(psu_fan_dir); + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", 3) == 0) { + return PSU_TYPE_DC_12V_F2B; + } + + if (strncmp(fan_dir, "B2F", 3) == 0) { + return PSU_TYPE_DC_12V_B2F; + } + + if (strncmp(fan_dir, "NON", 3) == 0) { + return PSU_TYPE_DC_12V_FANLESS; + } + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + *value = 0; + + if (PSU1_ID == id) { + ret = onlp_file_read_int(value, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + ret = onlp_file_read_int(value, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_int(value, path, NULL) != 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..69b8445d --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,82 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_inventec_d7054q28b_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/11-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/10-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/11-0053/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/10-0050/" + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define FAN_BOARD_PATH "/sys/devices/platform/fan/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom" + +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); + +int psu_pmbus_info_get(int id, char *node, int *value); +int psu_pmbus_info_set(int id, char *node, int value); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F, + PSU_TYPE_DC_48V_F2B, + PSU_TYPE_DC_48V_B2F, + PSU_TYPE_DC_12V_FANLESS, + PSU_TYPE_DC_12V_F2B, + PSU_TYPE_DC_12V_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/psui.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..8d12741e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/psui.c @@ -0,0 +1,272 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(node_path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(node_path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + + ret = onlp_file_read_int(value, node_path); + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +static int +psu_ym2651_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(node_path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + ret = onlp_file_read_int(value, node_path); + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +#include +#define DC12V_750_REG_TO_CURRENT(low, high) (((low << 4 | high >> 4) * 20 * 1000) / 754) +#define DC12V_750_REG_TO_VOLTAGE(low, high) ((low << 4 | high >> 4) * 25) + +static int +psu_dc12v_750_info_get(onlp_psu_info_t* info) +{ + int pid = ONLP_OID_ID_GET(info->hdr.id); + int bus = (PSU1_ID == pid) ? 11 : 10; + int iout_low, iout_high; + int vout_low, vout_high; + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_DC12; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Get current + */ + iout_low = onlp_i2c_readb(bus, 0x6f, 0x0, ONLP_I2C_F_FORCE); + iout_high = onlp_i2c_readb(bus, 0x6f, 0x1, ONLP_I2C_F_FORCE); + + if ((iout_low >= 0) && (iout_high >= 0)) { + info->miout = DC12V_750_REG_TO_CURRENT(iout_low, iout_high); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Get voltage + */ + vout_low = onlp_i2c_readb(bus, 0x6f, 0x2, ONLP_I2C_F_FORCE); + vout_high = onlp_i2c_readb(bus, 0x6f, 0x3, ONLP_I2C_F_FORCE); + + if ((vout_low >= 0) && (vout_high >= 0)) { + info->mvout = DC12V_750_REG_TO_VOLTAGE(vout_low, vout_high); + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get power based on current and voltage + */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_VOUT)) { + info->mpout = (info->miout * info->mvout) / 1000; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + info->caps = ONLP_PSU_CAPS_AC; + ret = psu_ym2651_info_get(info); + break; + case PSU_TYPE_DC_48V_F2B: + case PSU_TYPE_DC_48V_B2F: + info->caps = ONLP_PSU_CAPS_DC48; + ret = psu_ym2651_info_get(info); + break; + case PSU_TYPE_DC_12V_F2B: + case PSU_TYPE_DC_12V_B2F: + case PSU_TYPE_DC_12V_FANLESS: + ret = psu_dc12v_750_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sfpi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..0b568114 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,223 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +#include /* For O_RDWR && open */ +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +#define MUX_START_INDEX 18 +#define NUM_OF_SFP_PORT 32 +static const int sfp_mux_index[NUM_OF_SFP_PORT] = { + 4, 5, 6, 7, 9, 8, 11, 10, + 0, 1, 2, 3, 12, 13, 14, 15, +16, 17, 18, 19, 28, 29, 30, 31, +20, 21, 22, 23, 24, 25, 26, 27 +}; + +#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]+MUX_START_INDEX) + +static int +sfp_node_read_int(char *node_path, int *value, int data_len) +{ + int ret = 0; + *value = 0; + + ret = onlp_file_read_int(value, node_path); + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", + FRONT_PORT_TO_MUX_INDEX(port), + node_name); + + return sfp_node_path; +} + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + char* path = sfp_get_port_path(port, "sfp_is_present"); + + if (sfp_node_read_int(path, &present, 0) != 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[4]; + char* path; + FILE* fp; + + path = sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3 + ); + fclose(fp); + if(count != AIM_ARRAYSIZE(bytes)) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + char* path = sfp_get_port_path(port, "sfp_eeprom"); + int len = 0; + + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + memset(data, 0, 256); + + if (onlp_file_read((uint8_t*)data, 256, &len, path) < 0) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..7d6d8e38 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,295 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "x86_64_inventec_d7054q28b_int.h" +#include "x86_64_inventec_d7054q28b_log.h" + +#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) +{ + return "x86-64-inventec-d7054q28b-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + 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) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 4 Thermal sensors on the chassis */ + for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 4 Fans on the chassis */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +typedef struct fan_ctrl_policy { + int duty_cycle; + int temp_down_adjust; /* The boundary temperature to down adjust fan speed */ + int temp_up_adjust; /* The boundary temperature to up adjust fan speed */ +} fan_ctrl_policy_t; + +fan_ctrl_policy_t fan_ctrl_policy_f2b[] = { +{32, 0, 174000}, +{38, 170000, 182000}, +{50, 178000, 190000}, +{63, 186000, 0} +}; + +fan_ctrl_policy_t fan_ctrl_policy_b2f[] = { +{32, 0, 140000}, +{38, 135000, 150000}, +{50, 145000, 160000}, +{69, 155000, 0} +}; + +#define FAN_DUTY_CYCLE_MAX 100 +#define FAN_SPEED_CTRL_PATH "/sys/bus/i2c/devices/2-0066/fan_duty_cycle_percentage" + +/* + * For AC power Front to Back : + * * If any fan fail, please fan speed register to 15 + * * The max value of Fan speed register is 9 + * [LM75(48) + LM75(49) + LM75(4A)] > 174 => set Fan speed value from 4 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] > 182 => set Fan speed value from 5 to 7 + * [LM75(48) + LM75(49) + LM75(4A)] > 190 => set Fan speed value from 7 to 9 + * + * [LM75(48) + LM75(49) + LM75(4A)] < 170 => set Fan speed value from 5 to 4 + * [LM75(48) + LM75(49) + LM75(4A)] < 178 => set Fan speed value from 7 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] < 186 => set Fan speed value from 9 to 7 + * + * + * For AC power Back to Front : + * * If any fan fail, please fan speed register to 15 + * * The max value of Fan speed register is 10 + * [LM75(48) + LM75(49) + LM75(4A)] > 140 => set Fan speed value from 4 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] > 150 => set Fan speed value from 5 to 7 + * [LM75(48) + LM75(49) + LM75(4A)] > 160 => set Fan speed value from 7 to 10 + * + * [LM75(48) + LM75(49) + LM75(4A)] < 135 => set Fan speed value from 5 to 4 + * [LM75(48) + LM75(49) + LM75(4A)] < 145 => set Fan speed value from 7 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] < 155 => set Fan speed value from 10 to 7 + */ +int +onlp_sysi_platform_manage_fans(void) +{ + int i = 0, arr_size, temp; + fan_ctrl_policy_t *policy; + int cur_duty_cycle, new_duty_cycle; + onlp_thermal_info_t thermal_1, thermal_2, thermal_3; + + int fd, len; + char buf[10] = {0}; + + /* Get each fan status + */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + /* Decision 1: Set fan as full speed if any fan is failed. + */ + if (fan_info.status & ONLP_FAN_STATUS_FAILED) { + AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i); + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + } + + /* Decision 1.1: Set fan as full speed if any fan is not present. + */ + if (!(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { + AIM_LOG_ERROR("Fan(%d) is not present, set the other fans as full speed\r\n", i); + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + if (fan_info.status & ONLP_FAN_STATUS_F2B) { + policy = fan_ctrl_policy_f2b; + arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_f2b); + } + else { + policy = fan_ctrl_policy_b2f; + arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_b2f); + } + } + } + + /* Get current fan speed + */ + fd = open(FAN_SPEED_CTRL_PATH, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + cur_duty_cycle = atoi(buf); + + + /* Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + */ + for (i = 0; i < arr_size; i++) { + if (policy[i].duty_cycle != cur_duty_cycle) + continue; + + break; + } + + if (i == arr_size) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), policy[0].duty_cycle); + } + + /* Get current temperature + */ + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_1) != ONLP_STATUS_OK || + onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_2) != ONLP_STATUS_OK || + onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(4), &thermal_3) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + temp = thermal_1.mcelsius + thermal_2.mcelsius + thermal_3.mcelsius; + + + /* Decision 3: Decide new fan speed depend on fan direction/current fan speed/temperature + */ + new_duty_cycle = cur_duty_cycle; + + if ((temp >= policy[i].temp_up_adjust) && (i != (arr_size-1))) { + new_duty_cycle = policy[i+1].duty_cycle; + } + else if ((temp <= policy[i].temp_down_adjust) && (i != 0)) { + new_duty_cycle = policy[i-1].duty_cycle; + } + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/thermali.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..94f5353c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + "reserved", + NULL, /* CPU_CORE files */ + "/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/3-004b*temp1_input", + "/sys/bus/i2c/devices/11-005b*psu_temp1_input", + "/sys/bus/i2c/devices/10-0058*psu_temp1_input", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int local_id; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if(local_id == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_config.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_config.c new file mode 100644 index 00000000..6385cac8 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(_x) +x86_64_inventec_d7054q28b_config_settings_t x86_64_inventec_d7054q28b_config_settings[] = +{ +#ifdef x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME(x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ x86_64_inventec_d7054q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7054q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_inventec_d7054q28b_config_STRINGIFY_VALUE +#undef __x86_64_inventec_d7054q28b_config_STRINGIFY_NAME + +const char* +x86_64_inventec_d7054q28b_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_inventec_d7054q28b_config_settings[i].name; i++) { + if(strcmp(x86_64_inventec_d7054q28b_config_settings[i].name, setting)) { + return x86_64_inventec_d7054q28b_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_inventec_d7054q28b_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_inventec_d7054q28b_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_inventec_d7054q28b_config_settings[i].name, x86_64_inventec_d7054q28b_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_enums.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_enums.c new file mode 100644 index 00000000..8d0e7338 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_int.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_int.h new file mode 100644 index 00000000..7648b051 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_inventec_d7054q28b Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7054q28b_INT_H__ +#define __x86_64_inventec_d7054q28b_INT_H__ + +#include + + +#endif /* __x86_64_inventec_d7054q28b_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.c new file mode 100644 index 00000000..97381b84 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_inventec_d7054q28b_log.h" +/* + * x86_64_inventec_d7054q28b log struct. + */ +AIM_LOG_STRUCT_DEFINE( + x86_64_inventec_d7054q28b_CONFIG_LOG_OPTIONS_DEFAULT, + x86_64_inventec_d7054q28b_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + x86_64_inventec_d7054q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.h new file mode 100644 index 00000000..b8149079 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7054q28b_LOG_H__ +#define __x86_64_inventec_d7054q28b_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_inventec_d7054q28b +#include + +#endif /* __x86_64_inventec_d7054q28b_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_module.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_module.c new file mode 100644 index 00000000..88aad0ec --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_inventec_d7054q28b_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_inventec_d7054q28b_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_inventec_d7054q28b_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_ucli.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_ucli.c new file mode 100644 index 00000000..79bb6843 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/x86_64_inventec_d7054q28b_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_inventec_d7054q28b_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_inventec_d7054q28b_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d7054q28b) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_inventec_d7054q28b_ucli_module__ = + { + "x86_64_inventec_d7054q28b_ucli", + NULL, + x86_64_inventec_d7054q28b_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_inventec_d7054q28b_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_inventec_d7054q28b_ucli_module__); + n = ucli_node_create("x86_64_inventec_d7054q28b", NULL, &x86_64_inventec_d7054q28b_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d7054q28b")); + return n; +} + +#else +void* +x86_64_inventec_d7054q28b_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/PKG.yml new file mode 100644 index 00000000..4e546de1 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d7054q28b REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml new file mode 100644 index 00000000..37970f49 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for d7054q28b +# +###################################################################### + +x86-64-inventec-d7054q28b-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py new file mode 100644 index 00000000..f21f488b --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py @@ -0,0 +1,15 @@ +from onl.platform.base import * +from onl.platform.inventec import * + +class OnlPlatform_x86_64_inventec_d7054q28b_r0(OnlPlatformInventec, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-inventec-d7054q28b-r0' + MODEL="X86-D7054Q28B" + SYS_OBJECT_ID=".1.32" + + def baseconfig(self): + os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") + self.insmod('inv_platform') + self.insmod('inv_psoc') + self.insmod('inv_cpld') + return True From 95024334d12aa5f621f8d0985d4e65541508237c Mon Sep 17 00:00:00 2001 From: Joe Chan Date: Mon, 19 Feb 2018 14:49:56 -0800 Subject: [PATCH 143/244] Inventec d7054q28b onlp update. --- .../onlp/builds/src/module/src/sysi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c index 7d6d8e38..421aa41c 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/module/src/sysi.c @@ -193,7 +193,7 @@ onlp_sysi_platform_manage_fans(void) { onlp_fan_info_t fan_info; - if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + if (onlp_fan_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); return ONLP_STATUS_E_INTERNAL; } @@ -202,14 +202,14 @@ onlp_sysi_platform_manage_fans(void) */ if (fan_info.status & ONLP_FAN_STATUS_FAILED) { AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i); - return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); } /* Decision 1.1: Set fan as full speed if any fan is not present. */ if (!(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { AIM_LOG_ERROR("Fan(%d) is not present, set the other fans as full speed\r\n", i); - return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); } /* Get fan direction (Only get the first one since all fan direction are the same) @@ -254,14 +254,14 @@ onlp_sysi_platform_manage_fans(void) } if (i == arr_size) { - return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), policy[0].duty_cycle); + return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), policy[0].duty_cycle); } /* Get current temperature */ - if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_1) != ONLP_STATUS_OK || - onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_2) != ONLP_STATUS_OK || - onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(4), &thermal_3) != ONLP_STATUS_OK) { + if (onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_1) != ONLP_STATUS_OK || + onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_2) != ONLP_STATUS_OK || + onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(4), &thermal_3) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read thermal status"); return ONLP_STATUS_E_INTERNAL; } @@ -284,7 +284,7 @@ onlp_sysi_platform_manage_fans(void) return ONLP_STATUS_OK; } - return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle); + return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle); } int From 897f3f3e83adb3b6ee84c6b02cecaa0005ce6b78 Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Wed, 21 Feb 2018 14:45:57 +0800 Subject: [PATCH 144/244] Adding CP2112 latest patch & Enabling USB_ACM in linux config to create TTY interface for CPU to BMC communication. --- .../configs/x86_64-all/x86_64-all.config | 4 +- .../patches/driver-hid-cp2112-mods.patch | 196 ++++++++++++++++++ .../base/any/kernels/3.16-lts/patches/series | 1 + 3 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 packages/base/any/kernels/3.16-lts/patches/driver-hid-cp2112-mods.patch diff --git a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config index 24d29cee..c360583d 100644 --- a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config @@ -2450,7 +2450,7 @@ CONFIG_HID_GENERIC=y # CONFIG_HID_BELKIN is not set # CONFIG_HID_CHERRY is not set # CONFIG_HID_CHICONY is not set -# CONFIG_HID_CP2112 is not set +CONFIG_HID_CP2112=y # CONFIG_HID_CYPRESS is not set # CONFIG_HID_DRAGONRISE is not set # CONFIG_HID_EMS_FF is not set @@ -2561,7 +2561,7 @@ CONFIG_USB_UHCI_HCD=y # # USB Device Class drivers # -# CONFIG_USB_ACM is not set +CONFIG_USB_ACM=y # CONFIG_USB_PRINTER is not set # CONFIG_USB_WDM is not set # CONFIG_USB_TMC is not set diff --git a/packages/base/any/kernels/3.16-lts/patches/driver-hid-cp2112-mods.patch b/packages/base/any/kernels/3.16-lts/patches/driver-hid-cp2112-mods.patch new file mode 100644 index 00000000..e09052db --- /dev/null +++ b/packages/base/any/kernels/3.16-lts/patches/driver-hid-cp2112-mods.patch @@ -0,0 +1,196 @@ +diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c +index bc37acd..fee4c66 100644 +--- a/drivers/hid/hid-cp2112.c ++++ b/drivers/hid/hid-cp2112.c +@@ -156,6 +156,7 @@ struct cp2112_device { + wait_queue_head_t wait; + u8 read_data[61]; + u8 read_length; ++ u8 hwversion; + int xfer_status; + atomic_t read_avail; + atomic_t xfer_avail; +@@ -427,6 +428,156 @@ static int cp2112_write_req(void *buf, u8 slave_address, u8 command, u8 *data, + return data_length + 4; + } + ++static int cp2112_i2c_write_req(void *buf, u8 slave_address, u8 *data, ++ u8 data_length) ++{ ++ struct cp2112_write_req_report *report = buf; ++ ++ if (data_length > sizeof(report->data)) ++ return -EINVAL; ++ ++ report->report = CP2112_DATA_WRITE_REQUEST; ++ report->slave_address = slave_address << 1; ++ report->length = data_length; ++ memcpy(report->data, data, data_length); ++ return data_length + 3; ++} ++ ++static int cp2112_i2c_write_read_req(void *buf, u8 slave_address, ++ u8 *addr, int addr_length, ++ int read_length) ++{ ++ struct cp2112_write_read_req_report *report = buf; ++ ++ if (read_length < 1 || read_length > 512 || ++ addr_length > sizeof(report->target_address)) ++ return -EINVAL; ++ ++ report->report = CP2112_DATA_WRITE_READ_REQUEST; ++ report->slave_address = slave_address << 1; ++ report->length = cpu_to_be16(read_length); ++ report->target_address_length = addr_length; ++ memcpy(report->target_address, addr, addr_length); ++ return addr_length + 5; ++} ++ ++static int cp2112_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, ++ int num) ++{ ++ struct cp2112_device *dev = (struct cp2112_device *)adap->algo_data; ++ struct hid_device *hdev = dev->hdev; ++ u8 buf[64]; ++ ssize_t count; ++ ssize_t read_length = 0; ++ u8 *read_buf = NULL; ++ unsigned int retries; ++ int ret; ++ ++ hid_dbg(hdev, "I2C %d messages\n", num); ++ ++ if (num == 1) { ++ if (msgs->flags & I2C_M_RD) { ++ hid_dbg(hdev, "I2C read %#04x len %d\n", ++ msgs->addr, msgs->len); ++ read_length = msgs->len; ++ read_buf = msgs->buf; ++ count = cp2112_read_req(buf, msgs->addr, msgs->len); ++ } else { ++ hid_dbg(hdev, "I2C write %#04x len %d\n", ++ msgs->addr, msgs->len); ++ count = cp2112_i2c_write_req(buf, msgs->addr, ++ msgs->buf, msgs->len); ++ } ++ if (count < 0) ++ return count; ++ } else if (dev->hwversion > 1 && /* no repeated start in rev 1 */ ++ num == 2 && ++ msgs[0].addr == msgs[1].addr && ++ !(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD)) { ++ hid_dbg(hdev, "I2C write-read %#04x wlen %d rlen %d\n", ++ msgs[0].addr, msgs[0].len, msgs[1].len); ++ read_length = msgs[1].len; ++ read_buf = msgs[1].buf; ++ count = cp2112_i2c_write_read_req(buf, msgs[0].addr, ++ msgs[0].buf, msgs[0].len, msgs[1].len); ++ if (count < 0) ++ return count; ++ } else { ++ hid_err(hdev, ++ "Multi-message I2C transactions not supported\n"); ++ return -EOPNOTSUPP; ++ } ++ ++ ret = hid_hw_power(hdev, PM_HINT_FULLON); ++ if (ret < 0) { ++ hid_err(hdev, "power management error: %d\n", ret); ++ return ret; ++ } ++ ++ ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT); ++ if (ret < 0) { ++ hid_warn(hdev, "Error starting transaction: %d\n", ret); ++ goto power_normal; ++ } ++ ++ for (retries = 0; retries < XFER_STATUS_RETRIES; ++retries) { ++ ret = cp2112_xfer_status(dev); ++ if (-EBUSY == ret) ++ continue; ++ if (ret < 0) ++ goto power_normal; ++ break; ++ } ++ ++ if (XFER_STATUS_RETRIES <= retries) { ++ hid_warn(hdev, "Transfer timed out, cancelling.\n"); ++ buf[0] = CP2112_CANCEL_TRANSFER; ++ buf[1] = 0x01; ++ ++ ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); ++ if (ret < 0) ++ hid_warn(hdev, "Error cancelling transaction: %d\n", ++ ret); ++ ++ ret = -ETIMEDOUT; ++ goto power_normal; ++ } ++ ++ for (count = 0; count < read_length;) { ++ ret = cp2112_read(dev, read_buf + count, read_length - count); ++ if (ret < 0) ++ goto power_normal; ++ if (ret == 0) { ++ hid_err(hdev, "read returned 0\n"); ++ ret = -EIO; ++ goto power_normal; ++ } ++ count += ret; ++ if (count > read_length) { ++ /* ++ * The hardware returned too much data. ++ * This is mostly harmless because cp2112_read() ++ * has a limit check so didn't overrun our ++ * buffer. Nevertheless, we return an error ++ * because something is seriously wrong and ++ * it shouldn't go unnoticed. ++ */ ++ hid_err(hdev, "long read: %d > %zd\n", ++ ret, read_length - count + ret); ++ ret = -EIO; ++ goto power_normal; ++ } ++ } ++ ++ /* return the number of transferred messages */ ++ ret = num; ++ ++power_normal: ++ hid_hw_power(hdev, PM_HINT_NORMAL); ++ hid_dbg(hdev, "I2C transfer finished: %d\n", ret); ++ return ret; ++} ++ + static int cp2112_xfer(struct i2c_adapter *adap, u16 addr, + unsigned short flags, char read_write, u8 command, + int size, union i2c_smbus_data *data) +@@ -593,7 +744,8 @@ power_normal: + + static u32 cp2112_functionality(struct i2c_adapter *adap) + { +- return I2C_FUNC_SMBUS_BYTE | ++ return I2C_FUNC_I2C | ++ I2C_FUNC_SMBUS_BYTE | + I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA | + I2C_FUNC_SMBUS_BLOCK_DATA | +@@ -603,6 +755,7 @@ static u32 cp2112_functionality(struct i2c_adapter *adap) + } + + static const struct i2c_algorithm smbus_algorithm = { ++ .master_xfer = cp2112_i2c_xfer, + .smbus_xfer = cp2112_xfer, + .functionality = cp2112_functionality, + }; +@@ -925,6 +1078,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) + dev->adap.dev.parent = &hdev->dev; + snprintf(dev->adap.name, sizeof(dev->adap.name), + "CP2112 SMBus Bridge on hiddev%d", hdev->minor); ++ dev->hwversion = buf[2]; + init_waitqueue_head(&dev->wait); + + hid_device_io_start(hdev); + diff --git a/packages/base/any/kernels/3.16-lts/patches/series b/packages/base/any/kernels/3.16-lts/patches/series index e6a083f7..37e24f77 100644 --- a/packages/base/any/kernels/3.16-lts/patches/series +++ b/packages/base/any/kernels/3.16-lts/patches/series @@ -26,4 +26,5 @@ platform-powerpc-dni-7448-r0.patch platform-powerpc-quanta-lb9-r0.patch driver-support-intel-igb-bcm50210-phy.patch driver-igb-netberg-aurora.patch +driver-hid-cp2112-mods.patch gcc-no-pie.patch From 81b9b8d5f02a6f3a3298a1e61b13396256863491 Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Wed, 21 Feb 2018 18:01:33 +0800 Subject: [PATCH 145/244] [wedge100_32x] Add support for edge-core wedge100 with 32 network ports --- .../x86-64-accton-wedge100-32x/.gitignore | 3 + .../x86-64-accton-wedge100-32x/Makefile | 1 + .../modules/Makefile | 1 + .../modules/PKG.yml | 1 + .../x86-64-accton-wedge100-32x/onlp/Makefile | 1 + .../x86-64-accton-wedge100-32x/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++++ .../onlp/builds/onlpdump/Makefile | 46 ++++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../auto/x86_64_accton_wedge100_32x.yml | 50 ++++ .../x86_64_accton_wedge100_32x.x | 14 + .../x86_64_accton_wedge100_32x_config.h | 137 ++++++++++ .../x86_64_accton_wedge100_32x_dox.h | 26 ++ .../x86_64_accton_wedge100_32x_porting.h | 107 ++++++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 222 ++++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 220 +++++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 250 ++++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 69 +++++ .../onlp/builds/src/module/src/psui.c | 176 ++++++++++++ .../onlp/builds/src/module/src/sfpi.c | 216 +++++++++++++++ .../onlp/builds/src/module/src/sysi.c | 114 ++++++++ .../onlp/builds/src/module/src/thermali.c | 141 ++++++++++ .../src/x86_64_accton_wedge100_32x_config.c | 80 ++++++ .../src/x86_64_accton_wedge100_32x_enums.c | 10 + .../src/x86_64_accton_wedge100_32x_int.h | 12 + .../src/x86_64_accton_wedge100_32x_log.c | 18 ++ .../src/x86_64_accton_wedge100_32x_log.h | 12 + .../src/x86_64_accton_wedge100_32x_module.c | 24 ++ .../src/x86_64_accton_wedge100_32x_ucli.c | 50 ++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-wedge100-32x-r0.yml | 35 +++ .../x86_64_accton_wedge100_32x_r0/__init__.py | 23 ++ 41 files changed, 2163 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100_32x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/lib/x86-64-accton-wedge100-32x-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/python/x86_64_accton_wedge100_32x_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/.gitignore new file mode 100644 index 00000000..d82fa974 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*wedge100*32x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/PKG.yml new file mode 100644 index 00000000..82b52850 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100-32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/PKG.yml new file mode 100644 index 00000000..2de0fbfe --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-wedge100-32x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/lib/Makefile new file mode 100644 index 00000000..375afdc2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-wedge100-32x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_wedge100_32x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-wedge100-32x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..34d5a52a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_wedge100_32x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.module new file mode 100644 index 00000000..e5d217cd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_wedge100_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile new file mode 100644 index 00000000..8a3d285e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_wedge100_32x +AUTOMODULE := x86_64_accton_wedge100_32x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/README new file mode 100644 index 00000000..8f8f633e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_wedge100_32x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..07a1e011 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_wedge100_32x Autogeneration +# +############################################################################### +x86_64_accton_wedge100_32x_AUTO_DEFS := module/auto/x86_64_accton_wedge100_32x.yml +x86_64_accton_wedge100_32x_AUTO_DIRS := module/inc/x86_64_accton_wedge100_32x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100_32x.yml new file mode 100644 index 00000000..21f43840 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100_32x.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# X86_64_ACCTON_WEDGE100_32X Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_WEDGE100_32X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_wedge100_32x_config + + portingmacro: + X86_64_ACCTON_WEDGE100_32X: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x.x b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x.x new file mode 100644 index 00000000..f9974322 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h new file mode 100644 index 00000000..c0a2c1ba --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100_32x Configuration Header + * + * @addtogroup x86_64_accton_wedge100_32x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100_32X_CONFIG_H__ +#define __X86_64_ACCTON_WEDGE100_32X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_wedge100_32x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_wedge100_32x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_wedge100_32x_config_settings table. */ +extern x86_64_accton_wedge100_32x_config_settings_t x86_64_accton_wedge100_32x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_wedge100_32x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_wedge100_32x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_wedge100_32x_porting.h" + +#endif /* __X86_64_ACCTON_WEDGE100_32X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_dox.h new file mode 100644 index 00000000..475dcf24 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100_32x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100_32X_DOX_H__ +#define __X86_64_ACCTON_WEDGE100_32X_DOX_H__ + +/** + * @defgroup x86_64_accton_wedge100_32x x86_64_accton_wedge100_32x - x86_64_accton_wedge100_32x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_wedge100_32x-x86_64_accton_wedge100_32x Public Interface + * @defgroup x86_64_accton_wedge100_32x-config Compile Time Configuration + * @defgroup x86_64_accton_wedge100_32x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_WEDGE100_32X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h new file mode 100644 index 00000000..7f6d1730 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100_32x Porting Macros. + * + * @addtogroup x86_64_accton_wedge100_32x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100_32X_PORTING_H__ +#define __X86_64_ACCTON_WEDGE100_32X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_wedge100_32x_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_wedge100_32x_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_MALLOC malloc + #else + #error The macro x86_64_accton_wedge100_32x_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_wedge100_32x_FREE GLOBAL_FREE + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_FREE free + #else + #error The macro x86_64_accton_wedge100_32x_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_wedge100_32x_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_MEMSET memset + #else + #error The macro x86_64_accton_wedge100_32x_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_wedge100_32x_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_MEMCPY memcpy + #else + #error The macro x86_64_accton_wedge100_32x_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_wedge100_32x_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_STRNCPY strncpy + #else + #error The macro x86_64_accton_wedge100_32x_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_wedge100_32x_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_wedge100_32x_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_wedge100_32x_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_SNPRINTF snprintf + #else + #error The macro x86_64_accton_wedge100_32x_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100_32x_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_wedge100_32x_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100_32x_STRLEN strlen + #else + #error The macro x86_64_accton_wedge100_32x_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_WEDGE100_32X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..5659a539 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_wedge100_32x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_wedge100_32x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_wedge100_32x_DEPENDMODULE_ENTRIES := init:x86_64_accton_wedge100_32x ucli:x86_64_accton_wedge100_32x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..9bfd57cc --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_wedge100_32x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..3775723f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/fani.c @@ -0,0 +1,222 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define MAX_FAN_SPEED 15400 +#define BIT(i) (1 << (i)) + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, +}; + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/8-0033/" + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5) +}; + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int value = 0, fid; + char path[64] = {0}; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + /* get fan present status + */ + sprintf(path, "%s""fantray_present", FAN_BOARD_PATH); + + if (bmc_file_read_int(&value, path, 16) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value & BIT(fid-1)) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get front fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2 - 1); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + + /* set fan status based on rpm + */ + if (!info->rpm) { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + /* set fan direction + */ + info->status |= ONLP_FAN_STATUS_F2B; + + return ONLP_STATUS_OK; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + char cmd[32] = {0}; + + sprintf(cmd, "set_fan_speed.sh %d", p); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..8dcd1793 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,220 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS1, + LED_SYS2 +}; + +typedef struct led_address_s { + enum onlp_led_id id; + uint8_t bus; + uint8_t devaddr; + uint8_t offset; +} led_address_t; + +typedef struct led_mode_info_s { + onlp_led_mode_t mode; + uint8_t regval; +} led_mode_info_t; + +static led_address_t led_addr[] = +{ + { }, /* Not used */ + {LED_SYS1, 0, 0x32, 0x3e}, + {LED_SYS2, 0, 0x32, 0x3f}, +}; + +static led_mode_info_t led_mode_info[] = +{ + {ONLP_LED_MODE_OFF, 0x0}, + {ONLP_LED_MODE_OFF, 0x8}, + {ONLP_LED_MODE_RED, 0x1}, + {ONLP_LED_MODE_RED_BLINKING, 0x9}, + {ONLP_LED_MODE_GREEN, 0x2}, + {ONLP_LED_MODE_GREEN_BLINKING, 0xa}, + {ONLP_LED_MODE_BLUE, 0x4}, + {ONLP_LED_MODE_BLUE_BLINKING, 0xc}, +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS1), "Chassis LED 1 (SYS LED 1)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_SYS2), "Chassis LED 1 (SYS LED 2)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, +}; + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +reg_value_to_onlp_led_mode(enum onlp_led_id id, int value) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (value != led_mode_info[i].regval) { + continue; + } + + return led_mode_info[i].mode; + } + + return ONLP_LED_MODE_AUTO; +} + +static int +onlp_led_mode_to_reg_value(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (onlp_led_mode != led_mode_info[i].mode) { + continue; + } + + return led_mode_info[i].regval; + } + + return 0; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + value = onlp_i2c_readb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = reg_value_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + value = onlp_led_mode_to_reg_value(lid, mode); + if (onlp_i2c_writeb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, value, ONLP_I2C_F_FORCE) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..55a6119c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_wedge100_32x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..c203592c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,250 @@ +/************************************************************ + * + * + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define TTY_DEVICE "/dev/ttyACM0" +#define TTY_PROMPT "@bmc:" +#define TTY_I2C_TIMEOUT 60000 +#define TTY_BMC_LOGIN_TIMEOUT 1000000 +#define TTY_RETRY 10 +#define MAXIMUM_TTY_BUFFER_LENGTH 1024 +#define MAXIMUM_TTY_STRING_LENGTH (MAXIMUM_TTY_BUFFER_LENGTH - 1) + +static int tty_fd = -1; +static char tty_buf[MAXIMUM_TTY_BUFFER_LENGTH] = {0}; + +static int tty_open(void) +{ + int i = 20; + struct termios attr; + + if (tty_fd > -1) { + return 0; + } + + do { + if ((tty_fd = open(TTY_DEVICE, O_RDWR | O_NOCTTY | O_NDELAY)) > -1) { + tcgetattr(tty_fd, &attr); + attr.c_cflag = B57600 | CS8 | CLOCAL | CREAD; + attr.c_iflag = IGNPAR; + attr.c_oflag = 0; + attr.c_lflag = 0; + attr.c_cc[VMIN] = (unsigned char) + ((MAXIMUM_TTY_STRING_LENGTH > 0xFF) ? 0xFF : MAXIMUM_TTY_STRING_LENGTH); + attr.c_cc[VTIME] = 0; + cfsetospeed(&attr, B57600); + cfsetispeed(&attr, B57600); + tcsetattr(tty_fd, TCSANOW, &attr); + return 0; + } + + i--; + usleep(100000); + } while (i > 0); + + return -1; +} + +static int tty_close(void) +{ + close(tty_fd); + tty_fd = -1; + return 0; +} + +static int tty_exec_buf(unsigned long udelay, const char *str) +{ + if (tty_fd < 0) + return -1; + + write(tty_fd, tty_buf, strlen(tty_buf)+1); + usleep(udelay); + read(tty_fd, tty_buf, MAXIMUM_TTY_BUFFER_LENGTH); + return (strstr(tty_buf, str) != NULL) ? 0 : -1; +} + +static int tty_login(void) +{ + int i = 10; + + for (i = 1; i <= TTY_RETRY; i++) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "\r\r"); + if (!tty_exec_buf(0, TTY_PROMPT)) { + return 0; + } + + if (strstr(tty_buf, "bmc login:") != NULL) + { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "root\r"); + + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, "Password:")) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "0penBmc\r"); + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, TTY_PROMPT)) { + return 0; + } + + } + } + usleep(50000); + } + + return -1; +} + +int bmc_send_command(char *cmd) +{ + int i, ret = 0; + + for (i = 1; i <= TTY_RETRY; i++) { + if (tty_open() != 0) { + printf("ERROR: Cannot open TTY device\n"); + continue; + } + if (tty_login() != 0) { + //printf("ERROR: Cannot login TTY device\n"); + tty_close(); + continue; + } + + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "%s", cmd); + ret = tty_exec_buf(TTY_I2C_TIMEOUT * i, TTY_PROMPT); + tty_close(); + if (ret != 0) { + printf("ERROR: bmc_send_command timed out\n"); + continue; + } + + return 0; + } + + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return -1; +} + +int +bmc_command_read_int(int* value, char *cmd, int base) +{ + int len; + int i; + char *prev_str = NULL; + char *current_str= NULL; + if (bmc_send_command(cmd) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + len = (int)strlen(cmd); + prev_str = strstr(tty_buf, cmd); + if (prev_str == NULL) { + return -1; + } + for (i = 1; i <= TTY_RETRY; i++) { + current_str = strstr(prev_str + len, cmd); + if(current_str == NULL) { + *value = strtoul(prev_str + len, NULL, base); + break; + }else { + prev_str = current_str; + continue; + } + } + return 0; +} + +int +bmc_file_read_int(int* value, char *file, int base) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "cat %s\r\n", file); + return bmc_command_read_int(value, cmd, base); +} + +int +bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "i2cset -f -y %d 0x%x 0x%02x 0x%x\r\n", bus, devaddr, addr, value); + return bmc_send_command(cmd); +} + +int +bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x w\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size) +{ + int data_len, i = 0; + char cmd[64] = {0}; + char *str = NULL; + snprintf(cmd, sizeof(cmd), "i2craw -w 0x%x -r 0 %d 0x%02x\r\n", addr, bus, devaddr); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + str = strstr(tty_buf, "Received:\r\n "); + if (str == NULL) { + return -1; + } + + /* first byte is data length */ + str += strlen("Received:\r\n ");; + data_len = strtoul(str, NULL, 16); + if (data_size < data_len) { + data_len = data_size; + } + + for (i = 0; (i < data_len) && (str != NULL); i++) { + str = strstr(str, " ") + 1; /* Jump to next token */ + data[i] = strtoul(str, NULL, 16); + } + + data[i] = 0; + return 0; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..31593374 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,69 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_wedge100_32x_log.h" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define CHASSIS_FAN_COUNT 5 +#define CHASSIS_THERMAL_COUNT 8 +#define CHASSIS_LED_COUNT 2 +#define CHASSIS_PSU_COUNT 2 + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-39/39-0050/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_6_ON_MAIN_BROAD, + THERMAL_7_ON_MAIN_BROAD, +}; + +int bmc_send_command(char *cmd); +int bmc_file_read_int(int* value, char *file, int base); +int bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value); +int bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size); + +#endif /* __PLATFORM_LIB_H__ */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..71a2b785 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/psui.c @@ -0,0 +1,176 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define PSU1_ID 1 +#define PSU2_ID 2 + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +twos_complement_to_int(uint16_t data, uint8_t valid_bit, int mask) +{ + uint16_t valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static int +pmbus_parse_literal_format(uint16_t value) +{ + int exponent, mantissa, multiplier = 1000; + + exponent = twos_complement_to_int(value >> 11, 5, 0x1f); + mantissa = twos_complement_to_int(value & 0x7ff, 11, 0x7ff); + + return (exponent >= 0) ? (mantissa << exponent) * multiplier : + (mantissa * multiplier) / (1 << -exponent); +} + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int pid, value, addr; + + uint8_t mask = 0; + + VALIDATE(id); + + pid = ONLP_OID_ID_GET(id); + *info = pinfo[pid]; /* Set the onlp_oid_hdr_t */ + + /* Get the present status + */ + mask = 1 << ((pid-1) * 4); + value = onlp_i2c_readb(0, 0x32, 0x10, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value & mask) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + info->caps = ONLP_PSU_CAPS_AC; + + /* Get power good status + */ + mask = 1 << ((pid-1) * 4 + 1); + if (!(value & mask)) { + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* Get input output power status + */ + value = (pid == PSU1_ID) ? 0x2 : 0x1; /* mux channel for psu */ + if (bmc_i2c_writeb(7, 0x70, 0, value) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* Read vin */ + addr = (pid == PSU1_ID) ? 0x59 : 0x5a; + value = bmc_i2c_readw(7, addr, 0x88); + if (value >= 0) { + info->mvin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_VIN; + } + + /* Read iin */ + value = bmc_i2c_readw(7, addr, 0x89); + if (value >= 0) { + info->miin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IIN; + } + + /* Get pin */ + if ((info->caps & ONLP_PSU_CAPS_VIN) && (info->caps & ONLP_PSU_CAPS_IIN)) { + info->mpin = info->mvin * info->miin / 1000; + info->caps |= ONLP_PSU_CAPS_PIN; + } + + /* Read iout */ + value = bmc_i2c_readw(7, addr, 0x8c); + if (value >= 0) { + info->miout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Read pout */ + value = bmc_i2c_readw(7, addr, 0x96); + if (value >= 0) { + info->mpout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_POUT; + } + + /* Get vout */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_POUT) && info->miout != 0) { + info->mvout = info->mpout / info->miout * 1000; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get model name */ + return bmc_i2c_readraw(7, addr, 0x9a, info->model, sizeof(info->model)); +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..220c014e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,216 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100_32x_log.h" + +#define BIT(i) (1 << (i)) +#define NUM_OF_SFP_PORT 32 +static const int sfp_bus_index[] = { + 2, 1, 4, 3, 6, 5, 8, 7, + 10, 9, 12, 11, 14, 13, 16, 15, + 18, 17, 20, 19, 22, 21, 24, 23, + 26, 25, 28, 27, 30, 29, 32, 31 +}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +static uint8_t +onlp_sfpi_reg_val_to_port_sequence(uint8_t value, int revert) +{ + int i; + uint8_t ret = 0; + + for (i = 0; i < 8; i++) { + if (i % 2) { + ret |= (value & BIT(i)) >> 1; + } + else { + ret |= (value & BIT(i)) << 1; + } + } + + return revert ? ~ret : ret; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus = (port < 16) ? 35 : 36; + int addr = (port < 16) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset; + + if (port < 8 || (port >= 16 && port <= 23)) { + offset = 0; + } + else { + offset = 1; + } + + present = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (present < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + present = onlp_sfpi_reg_val_to_port_sequence(present, 0); + return !(present & BIT(port % 8)); +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int i; + uint8_t bytes[4] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(bytes); i++) { + int bus = (i < 2) ? 35 : 36; + int addr = (i < 2) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset = (i % 2); + + bytes[i] = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (bytes[i] < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + bytes[i] = onlp_sfpi_reg_val_to_port_sequence(bytes[i], 1); + } + + /* Convert to 32 bit integer in port order */ + i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_OK; +} + +static int +sfpi_eeprom_read(int port, uint8_t devaddr, uint8_t data[256]) +{ + int i; + + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + memset(data, 0, 256); + + for (i = 0; i < 128; i++) { + int bus = sfp_bus_index[port]; + int val = onlp_i2c_readw(bus, devaddr, i*2, ONLP_I2C_F_FORCE); + + if (val < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + data[i] = val & 0xff; + data[i+1] = (val >> 8) & 0xff; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x50, data); +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x51, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..05eefde5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,114 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100_32x_int.h" +#include "x86_64_accton_wedge100_32x_log.h" + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-wedge100-32x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 8 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 2 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 5 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ +} + +int +onlp_sysi_platform_manage_fans(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..e01abb40 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/drivers/lm75/%s/temp1_input" + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "3-0048", + "3-0049", + "3-004a", + "3-004b", + "3-004c", + "8-0048", + "8-0049", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "TMP75-1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "TMP75-2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "TMP75-3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "TMP75-4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "TMP75-5", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "TMP75-6", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_7_ON_MAIN_BROAD), "TMP75-7", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if (THERMAL_CPU_CORE == tid) { + return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + } + + /* get path */ + sprintf(path, THERMAL_PATH_FORMAT, directory[tid]); + if (bmc_file_read_int(&info->mcelsius, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c new file mode 100644 index 00000000..ad80014f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(_x) +x86_64_accton_wedge100_32x_config_settings_t x86_64_accton_wedge100_32x_config_settings[] = +{ +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE +#undef __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME + +const char* +x86_64_accton_wedge100_32x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_wedge100_32x_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_wedge100_32x_config_settings[i].name, setting)) { + return x86_64_accton_wedge100_32x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_wedge100_32x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_wedge100_32x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_wedge100_32x_config_settings[i].name, x86_64_accton_wedge100_32x_config_settings[i].value); + } + return i; +} + +/* */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_enums.c new file mode 100644 index 00000000..5f093bae --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_int.h new file mode 100644 index 00000000..8af8063a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100_32x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_wedge100_32x_INT_H__ +#define __x86_64_accton_wedge100_32x_INT_H__ + +#include + + +#endif /* __x86_64_accton_wedge100_32x_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.c new file mode 100644 index 00000000..4c195188 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100_32x_log.h" +/* + * x86_64_accton_wedge100_32x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.h new file mode 100644 index 00000000..ee1a688c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_wedge100_32x_LOG_H__ +#define __x86_64_accton_wedge100_32x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_wedge100_32x +#include + +#endif /* __x86_64_accton_wedge100_32x_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_module.c new file mode 100644 index 00000000..65765435 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100_32x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_wedge100_32x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_wedge100_32x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_ucli.c new file mode 100644 index 00000000..f4fe6102 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_wedge100_32x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_wedge100_32x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_wedge100_32x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_wedge100_32x_ucli_module__ = + { + "x86_64_accton_wedge100_32x_ucli", + NULL, + x86_64_accton_wedge100_32x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_wedge100_32x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_wedge100_32x_ucli_module__); + n = ucli_node_create("x86_64_accton_wedge100_32x", NULL, &x86_64_accton_wedge100_32x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_wedge100_32x")); + return n; +} + +#else +void* +x86_64_accton_wedge100_32x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/PKG.yml new file mode 100644 index 00000000..0504f406 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100-32x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/lib/x86-64-accton-wedge100-32x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/lib/x86-64-accton-wedge100-32x-r0.yml new file mode 100644 index 00000000..f6214d02 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/lib/x86-64-accton-wedge100-32x-r0.yml @@ -0,0 +1,35 @@ +--- + +###################################################################### +# +# platform-config for WEDGE +# +###################################################################### + +x86-64-accton-wedge100-32x-r0: + + grub: + + serial: >- + --unit=0 + --speed=57600 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,57600n8 + rd_NO_MD + rd_NO_LUKS + intel_iommu=off + noapic + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/python/x86_64_accton_wedge100_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/python/x86_64_accton_wedge100_32x_r0/__init__.py new file mode 100644 index 00000000..7bf82abd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/platform-config/r0/src/python/x86_64_accton_wedge100_32x_r0/__init__.py @@ -0,0 +1,23 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_wedge100_32x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_32x100): + MODEL="Wedge-100-32X" + PLATFORM="x86-64-accton-wedge100-32x-r0" + SYS_OBJECT_ID=".100.32.1" + + def baseconfig(self): + ########### initialize I2C bus 0 ########### + self.new_i2c_devices([ + # initialize multiplexer (PCA9548) + ('pca9548', 0x70, 0), + ('pca9548', 0x71, 0), + ('pca9548', 0x72, 0), + ('pca9548', 0x73, 0), + ('pca9548', 0x74, 0), + + ('24c64', 0x50, 39), + ]) + + return True From 4539cd8c74554322ba4725568457165597204700 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Thu, 22 Feb 2018 23:56:59 +0000 Subject: [PATCH 146/244] Configuration changes for the 4.9 kernel to support FBOSS and the Wedge 100/100S Tunnel support added for FBOSS USB_ACM for Wedge BCM connection. --- .../4.9-lts/configs/x86_64-all/x86_64-all.config | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index c42f22ad..612c7a07 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -794,7 +794,7 @@ CONFIG_IP_PNP=y CONFIG_IP_PNP_DHCP=y CONFIG_IP_PNP_BOOTP=y CONFIG_IP_PNP_RARP=y -# CONFIG_NET_IPIP is not set +CONFIG_NET_IPIP=y # CONFIG_NET_IPGRE_DEMUX is not set CONFIG_NET_IP_TUNNEL=y CONFIG_IP_MROUTE=y @@ -844,7 +844,7 @@ CONFIG_INET6_ESP=y # CONFIG_IPV6_MIP6 is not set # CONFIG_IPV6_ILA is not set # CONFIG_INET6_XFRM_TUNNEL is not set -# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_TUNNEL=y CONFIG_INET6_XFRM_MODE_TRANSPORT=y CONFIG_INET6_XFRM_MODE_TUNNEL=y CONFIG_INET6_XFRM_MODE_BEET=y @@ -853,10 +853,11 @@ CONFIG_INET6_XFRM_MODE_BEET=y CONFIG_IPV6_SIT=y # CONFIG_IPV6_SIT_6RD is not set CONFIG_IPV6_NDISC_NODETYPE=y -# CONFIG_IPV6_TUNNEL is not set +CONFIG_IPV6_TUNNEL=y # CONFIG_IPV6_FOU is not set # CONFIG_IPV6_FOU_TUNNEL is not set -# CONFIG_IPV6_MULTIPLE_TABLES is not set +CONFIG_IPV6_MULTIPLE_TABLES=y +# CONFIG_IPV6_SUBTREES is not set # CONFIG_IPV6_MROUTE is not set CONFIG_NETLABEL=y CONFIG_NETWORK_SECMARK=y @@ -1471,9 +1472,9 @@ CONFIG_NET_CORE=y CONFIG_NETCONSOLE=y CONFIG_NETPOLL=y CONFIG_NET_POLL_CONTROLLER=y -# CONFIG_TUN is not set +CONFIG_TUN=y # CONFIG_TUN_VNET_CROSS_LE is not set -# CONFIG_VETH is not set +CONFIG_VETH=y CONFIG_VIRTIO_NET=y # CONFIG_NLMON is not set # CONFIG_ARCNET is not set @@ -3073,7 +3074,7 @@ CONFIG_USB_UHCI_HCD=y # # USB Device Class drivers # -# CONFIG_USB_ACM is not set +CONFIG_USB_ACM=y CONFIG_USB_PRINTER=y # CONFIG_USB_WDM is not set # CONFIG_USB_TMC is not set From a1176d5df1c54d66bbe0cebaee4046382f6d5d4b Mon Sep 17 00:00:00 2001 From: Sander Tolsma Date: Fri, 23 Feb 2018 07:42:13 +0100 Subject: [PATCH 147/244] Fix wrong filetest for postinstall.sh The wrong filename was tested for existence. --- builds/any/installer/installer.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/any/installer/installer.sh.in b/builds/any/installer/installer.sh.in index c66ccbe4..470bc882 100644 --- a/builds/any/installer/installer.sh.in +++ b/builds/any/installer/installer.sh.in @@ -578,7 +578,7 @@ if test -f "$postinst"; then fi installer_unzip $installer_zip postinstall.sh || : -if test -f preinstall.sh; then +if test -f postinstall.sh; then chmod +x postinstall.sh ./postinstall.sh $rootdir fi From 65cd247a0acca7c14b7e320415da8f3665d73a69 Mon Sep 17 00:00:00 2001 From: "shaohua.xiong" Date: Fri, 23 Feb 2018 16:25:05 +0800 Subject: [PATCH 148/244] add platform support for ag6248c and ag6248c_poe --- .../loader-initrd-files/src/bin/swiget | 9 + .../loader-initrd-files/src/bin/swimount | 23 +- .../src/bootmodes/installed | 4 +- .../lib/platform-config-defaults-uboot.yml | 7 + .../src/python/onl/install/BaseInstall.py | 228 +- .../src/python/onl/install/InstallUtils.py | 57 + .../src/python/onl/mounts/__init__.py | 40 +- .../src/python/onl/platform/base.py | 4 + .../3.2-lts/configs/arm-iproc-all/Makefile | 2 +- .../arm-iproc-all/arm-iproc-all.config | 4 +- ...latform-delta-ag6248c-device-drivers.patch | 181 ++ .../configs/arm-iproc-all/patches/series | 1 + packages/platforms/delta/armel/Makefile | 1 + .../delta/armel/arm-delta-ag6248c/Makefile | 1 + .../delta/armel/arm-delta-ag6248c/README.md | 25 + .../arm-delta-ag6248c-poe/.gitignore | 1 + .../arm-delta-ag6248c-poe/Makefile | 1 + .../arm-delta-ag6248c-poe/modules/Makefile | 1 + .../arm-delta-ag6248c-poe/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 2 + .../modules/builds/Makefile | 6 + .../builds/arm-delta-ag6248c-poe-cpld-mux-1.c | 242 +++ .../builds/arm-delta-ag6248c-poe-cpld-mux-2.c | 243 +++ .../arm-delta-ag6248c-poe/onlp/Makefile | 1 + .../arm-delta-ag6248c-poe/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 44 + .../lib/libonlp-arm-delta-ag6248c-poe.mk | 10 + .../onlp/builds/onlpdump/Makefile | 45 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/arm-delta-ag6248c-poe-r0.yml | 42 + .../arm_delta_ag6248c_poe_r0/__init__.py | 21 + .../arm-delta-ag6248c/.gitignore | 2 + .../arm-delta-ag6248c/Makefile | 1 + .../arm-delta-ag6248c/modules/Makefile | 1 + .../arm-delta-ag6248c/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 2 + .../arm-delta-ag6248c/modules/builds/Makefile | 6 + .../builds/arm-delta-ag6248c-cpld-mux-1.c | 242 +++ .../builds/arm-delta-ag6248c-cpld-mux-2.c | 243 +++ .../arm-delta-ag6248c/onlp/Makefile | 1 + .../arm-delta-ag6248c/onlp/PKG.yml | 1 + .../arm-delta-ag6248c/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 44 + .../builds/lib/libonlp-arm-delta-ag6248c.mk | 10 + .../onlp/builds/onlpdump/Makefile | 45 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/arm-delta-ag6248c-r0.yml | 43 + .../python/arm_delta_ag6248c_r0/__init__.py | 23 + .../src/arm_delta_ag6248c/.gitignore | 2 + .../src/arm_delta_ag6248c/.module | 1 + .../src/arm_delta_ag6248c/Makefile | 28 + .../arm_delta_ag6248c/arm_delta_ag6248c.doxy | 1869 +++++++++++++++++ .../arm_delta_ag6248c/arm_delta_ag6248c.mk | 13 + .../module/auto/arm_delta_ag6248c.yml | 67 + .../src/arm_delta_ag6248c/module/auto/make.mk | 28 + .../inc/arm_delta_ag6248c/arm_delta_ag6248c.x | 34 + .../arm_delta_ag6248c_config.h | 162 ++ .../arm_delta_ag6248c/arm_delta_ag6248c_dox.h | 51 + .../arm_delta_ag6248c_porting.h | 132 ++ .../src/arm_delta_ag6248c/module/make.mk | 29 + .../src/arm_delta_ag6248c/module/src/Makefile | 30 + .../module/src/arm_delta_ag6248c_config.c | 101 + .../module/src/arm_delta_ag6248c_enums.c | 30 + .../module/src/arm_delta_ag6248c_int.h | 32 + .../module/src/arm_delta_ag6248c_log.c | 38 + .../module/src/arm_delta_ag6248c_log.h | 32 + .../module/src/arm_delta_ag6248c_module.c | 44 + .../module/src/arm_delta_ag6248c_ucli.c | 82 + .../module/src/arm_delta_i2c.c | 141 ++ .../module/src/arm_delta_i2c.h | 54 + .../src/arm_delta_ag6248c/module/src/fani.c | 470 +++++ .../src/arm_delta_ag6248c/module/src/ledi.c | 375 ++++ .../src/arm_delta_ag6248c/module/src/make.mk | 29 + .../module/src/platform_lib.c | 85 + .../module/src/platform_lib.h | 136 ++ .../src/arm_delta_ag6248c/module/src/psui.c | 381 ++++ .../src/arm_delta_ag6248c/module/src/sfpi.c | 364 ++++ .../src/arm_delta_ag6248c/module/src/sysi.c | 290 +++ .../arm_delta_ag6248c/module/src/thermali.c | 208 ++ .../platforms/delta/armel/modules/Makefile | 1 + .../platforms/delta/armel/modules/PKG.yml | 1 + 86 files changed, 7248 insertions(+), 15 deletions(-) create mode 100644 packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch create mode 100644 packages/platforms/delta/armel/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/README.md create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/.gitignore create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/PKG.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/.gitignore create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/PKG.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/libonlp-arm-delta-ag6248c-poe.mk create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/onlpdump/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/PKG.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/lib/arm-delta-ag6248c-poe-r0.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/python/arm_delta_ag6248c_poe_r0/__init__.py create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c create mode 100644 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/make.mk create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c create mode 100755 packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c create mode 100644 packages/platforms/delta/armel/modules/Makefile create mode 100644 packages/platforms/delta/armel/modules/PKG.yml diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget index 841ea130..3bee3891 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget @@ -19,6 +19,7 @@ import zipfile import onl.install.InstallUtils MountContext = onl.install.InstallUtils.MountContext BlkidParser = onl.install.InstallUtils.BlkidParser +UbinfoParser = onl.install.InstallUtils.UbinfoParser ProcMountsParser = onl.install.InstallUtils.ProcMountsParser import onl.mounts @@ -247,6 +248,14 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): part = blkid[label] except IndexError: part = None + if part is None: + ubinfo = UbinfoParser(log=self.log) + part = {} + part = ubinfo[label] + device = "/dev/" + part['device'] + "_" + part['Volume ID'] + + return self.blockdevCopy(device, r, dir=mpt) + if part is not None: return self.blockdevCopy(part.device, r, dir=mpt) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swimount b/packages/base/all/initrds/loader-initrd-files/src/bin/swimount index b7ea1879..2741b5bd 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swimount +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swimount @@ -11,6 +11,7 @@ import logging import onl.install.InstallUtils BlkidParser = onl.install.InstallUtils.BlkidParser +UbinfoParser = onl.install.InstallUtils.UbinfoParser import onl.mounts MountContext = onl.install.InstallUtils.MountContext @@ -26,6 +27,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): self.log = log self.blkid = BlkidParser(log=self.log) + self.ubinfo = UbinfoParser(log=self.log) def mount(self, SWI): @@ -125,6 +127,13 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): part = self.blkid[label] except IndexError: part = None + if part is None: + part = {} + part = self.ubinfo[label] + + device = "/dev/" + part['device'] + "_" + part['Volume ID'] + + return self.blockdevMount(device, path, dir=mpt) if part is not None: return self.blockdevMount(part.device, path, dir=mpt) @@ -141,7 +150,12 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): if not os.path.exists(dst): self.log.error("missing SWI: %s", dst) return None - self.check_call(('mount', '-o', 'rw,remount', dst,)) + p = dev.find('ubi') + if p < 0: + self.check_call(('mount', '-o', 'rw,remount', dst,)) + else: + self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', dst,)) + return dst with MountContext(device=dev, log=self.log) as ctx: @@ -154,7 +168,12 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): # move to its proper location as per mtab # XXX perms may not be right here if dir is not None: - self.check_call(('mount', '-o', 'rw,remount', ctx.dir,)) + p = dev.find('ubi') + if p < 0: + self.check_call(('mount', '-o', 'rw,remount', ctx.dir,)) + else: + self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', ctx.dir,)) + self.check_call(('mount', '--move', ctx.dir, dir,)) ctx.mounted = False dst = dir diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed index 00aa3a41..dc0e887b 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed +++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed @@ -15,8 +15,8 @@ if [ ! -d /mnt/onl/data ]; then fi # make sure it's mounted as per mtab.yml -d1=$(stat -f -c '%d' /mnt/onl) -d2=$(stat -f -c '%d' /mnt/onl/data) +d1=$(stat -f -c '%b' /mnt/onl) +d2=$(stat -f -c '%b' /mnt/onl/data) if [ "$d1" -eq "$d2" ]; then msg_error "Unmounted /mnt/onl/data, disk boot cannot continue" exit 200 diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml index 4ad068fb..6b66f8c6 100644 --- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml +++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml @@ -129,6 +129,13 @@ default: - ext2load mmc 0:1 $onl_loadaddr $onl_itb - "bootm $onl_loadaddr#$onl_platform" + #ubifs to boot onl + flash_bootcmds: &flash_bootcmds + - ubi part open + - ubifsmount ONL-BOOT + - ubifsload $loadaddr $onl_itb + - "bootm $onl_loadaddr#$onl_platform" + nos_bootcmds: *ide_bootcmds # Configure the fw_env.config file, diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py index 10878bce..3290ec34 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py @@ -17,7 +17,7 @@ import imp import fnmatch, glob from InstallUtils import SubprocessMixin -from InstallUtils import MountContext, BlkidParser, PartedParser +from InstallUtils import MountContext, BlkidParser, PartedParser, UbinfoParser from InstallUtils import ProcMountsParser from InstallUtils import GdiskParser from InstallUtils import OnieSubprocess @@ -83,6 +83,7 @@ class Base: # keep track of next partition/next block self.blkidParts = [] + self.ubiParts = [] # current scan of partitions and labels self.partedDevice = None @@ -853,7 +854,203 @@ class GrubInstaller(SubprocessMixin, Base): def shutdown(self): Base.shutdown(self) -class UbootInstaller(SubprocessMixin, Base): +class UBIfsCreater(SubprocessMixin, Base): + + def __init__(self, *args, **kwargs): + Base.__init__(self, *args, **kwargs) + self.log = logging.getLogger("ubinfo -a") + self.device = self.im.getDevice() + self.ubiParts = None + """Set up an UBI file system.""" + + def ubifsinit(self): + UNITS = { + 'GiB' : 1024 * 1024 * 1024, + 'G' : 1000 * 1000 * 1000, + 'MiB' : 1024 * 1024, + 'M' : 1000 * 1000, + 'KiB' : 1024, + 'K' : 1000, + } + try: + code = 0 + if not code: + mtd_num = self.device[-1] + cmd = ('ubiformat', '/dev/mtd' + mtd_num) + self.check_call(cmd, vmode=self.V2) + cmd = ('ubiattach', '-m', mtd_num, '-d', '0', '/dev/ubi_ctrl',) + self.check_call(cmd, vmode=self.V2) + for part in self.im.platformConf['installer']: + label, partData = list(part.items())[0] + if type(partData) == dict: + sz, fmt = partData['='], partData.get('format', 'ubifs') + else: + sz, fmt = partData, 'ubifs' + cnt = None + for ul, ub in UNITS.items(): + if sz.endswith(ul): + cnt = int(sz[:-len(ul)], 10) * ub + break + if cnt is None: + self.log.error("invalid size (no units) for %s: %s",part, sz) + return 1 + label = label.strip() + cmd = ('ubimkvol', '/dev/ubi0', '-N', label, '-s', bytes(cnt),) + self.check_call(cmd, vmode=self.V2) + except Exception: + self.log.exception("cannot create UBI file systemfrom %s",self.device) + + return 0 + + def ubi_mount(self, dir, devpart): + + if devpart is None: + self.log.error("Mount failed.no given mount device part") + return 1 + if dir is None: + self.log.error("Mount failed.no given mount directory") + return 1 + if self.ubiParts is None: + try: + self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a")) + except Exception: + self.log.exception("Mount failed.No UBIfs") + return 1 + try: + dev = self.ubiParts[devpart] + except IndexError as ex: + self.log.error("Mount failed.cannot find %s partition", str(devpart)) + return 1 + self.makedirs(dir) + device = "/dev/" + dev['device'] + "_" + dev['Volume ID'] + if dev['fsType']: + cmd = ('mount', '-t', dev['fsType'], device, dir,) + else: + cmd = ('mount', device, dir,) + code = self.check_call(cmd, vmode=self.V2) + if code: + self.log.error("Mount failed.mount command exect failed") + return 1 + return 0 + + def ubi_unmount(self,dir=None): + + if dir is None: + self.log.error("Unmount failed.no given unmount directory") + return 1 + cmd = ('umount', dir) + code = self.check_call(cmd, vmode=self.V2) + if code: + self.log.error("Unmount failed.umount command exect failed") + return 1 + return 0 + + def ubi_getinfo(self): + try: + self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a")) + except Exception: + self.log.exception("UBI info get failed.No UBIfs") + return 1 + return 0 + + def ubi_installSwi(self): + + files = os.listdir(self.im.installerConf.installer_dir) + self.zf.namelist() + + swis = [x for x in files if x.endswith('.swi')] + + if not swis: + self.log.warn("No ONL Software Image available for ubi installation.") + self.log.warn("Post-install ZTN installation will be required.") + + if len(swis) > 1: + self.log.error("Multiple SWIs found in ubi installer: %s", " ".join(swis)) + return 1 + + base = swis[0] + + self.log.info("Installing ONL Software Image (%s)...", base) + dev = "ONL-IMAGES" + dstDir = "/tmp/ubifs" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + dst = os.path.join(dstDir, base) + self.installerCopy(base, dst) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + def ubi_installLoader(self): + + loaderBasename = None + for c in sysconfig.installer.fit: + if self.installerExists(c): + loaderBasename = c + break + if not loaderBasename: + self.log.error("The platform loader file is missing.") + return 1 + + self.log.info("Installing the ONL loader from %s...", loaderBasename) + dev = "ONL-BOOT" + dstDir = "/tmp/ubiloader" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + dst = os.path.join(dstDir, "%s.itb" % self.im.installerConf.installer_platform) + self.installerCopy(loaderBasename, dst) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + def ubi_installBootConfig(self): + + basename = 'boot-config' + + self.log.info("Installing boot-config to ONL-BOOT partion") + dev = "ONL-BOOT" + dstDir = "/tmp/ubibootcon" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + dst = os.path.join(dstDir, basename) + self.installerCopy(basename, dst, True) + with open(dst) as fd: + buf = fd.read() + ecf = buf.encode('base64', 'strict').strip() + if self.im.grub and self.im.grubEnv is not None: + setattr(self.im.grubEnv, 'boot_config_default', ecf) + if self.im.uboot and self.im.ubootEnv is not None: + setattr(self.im.ubootEnv, 'boot-config-default', ecf) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + def ubi_installOnlConfig(self): + + self.log.info("Installing onl-config to ONL-CONFIG partion") + dev = "ONL-CONFIG" + dstDir = "/tmp/ubionlconfig" + code = self.ubi_mount(dstDir,dev) + if code : + return 1 + for f in self.zf.namelist(): + d = 'config/' + if f.startswith(d) and f != d: + dst = os.path.join(dstDir, os.path.basename(f)) + if not os.path.exists(dst): + self.installerCopy(f, dst) + self.log.info("syncing block devices(%s)...",dev) + self.check_call(('sync',)) + self.ubi_unmount(dstDir) + return 0 + + +class UbootInstaller(SubprocessMixin, UBIfsCreater): class installmeta(Base.installmeta): @@ -874,13 +1071,16 @@ class UbootInstaller(SubprocessMixin, Base): cmds.append("setenv onl_itb %s" % itb) for item in self.platformConf['loader']['setenv']: k, v = list(item.items())[0] - cmds.append("setenv %s %s" % (k, v,)) + device = self.getDevice() + if "mtdblock" in device: + cmds.append("setenv %s %s ${platformargs} ubi.mtd=%s root=/dev/ram ethaddr=$ethaddr" % (k, v, device[-1],)) + else: + cmds.append("setenv %s %s" % (k, v,)) cmds.extend(self.platformConf['loader']['nos_bootcmds']) return "; ".join(cmds) def __init__(self, *args, **kwargs): - Base.__init__(self, *args, **kwargs) - + UBIfsCreater.__init__(self, *args, **kwargs) self.device = self.im.getDevice() self.rawLoaderDevice = None @@ -1014,6 +1214,24 @@ class UbootInstaller(SubprocessMixin, Base): code = self.assertUnmounted() if code: return code + + if "mtdblock" in self.device: + code = self.ubifsinit() + if code: return code + code = self.ubi_getinfo() + if code: return code + code = self.ubi_installSwi() + if code: return code + code = self.ubi_installLoader() + if code: return code + code = self.ubi_installBootConfig() + if code: return code + code = self.ubi_installOnlConfig() + if code: return code + code = self.runPlugins(Plugin.PLUGIN_POSTINSTALL) + if code: return code + code = self.installUbootEnv() + return code code = self.maybeCreateLabel() if code: return code diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index ccb4615e..85fe2c01 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -388,6 +388,63 @@ class BlkidParser(SubprocessMixin): def __len__(self): return len(self.parts) +class UbinfoParser(SubprocessMixin): + + def __init__(self, log=None): + self.log = log or logging.getLogger("ubinfo -a") + self.parse() + + def parse(self): + self.parts = [] + lines = '' + try: + cmd = ('ubinfo', '-a',) + lines = self.check_output(cmd).splitlines() + except Exception as ex: + return self + + dev = None + volId = None + name = None + attrs = {} + for line in lines: + line = line.strip() + + p = line.find(':') + if p < 0: continue + name, value = line[:p], line[p+1:].strip() + if 'Volume ID' in name: + p = value.find('(') + if p < 0: continue + volumeId = value[:p].strip() + attrs['Volume ID'] = volumeId + p = value.find('on') + if p < 0: continue + dev = value[p+2:-1].strip() + attrs['device'] = dev + + if 'Name' in name: + dev = "/dev/" + dev + "_" + volumeId + p = line.find(':') + if p < 0: continue + attrs['Name'] = line[p+1:].strip() + attrs['fsType'] = 'ubifs' + self.parts.append(attrs) + dev = None + volId = None + name = None + attrs = {} + + def __getitem__(self, idxOrName): + if type(idxOrName) == int: + return self.parts[idxOrName] + for part in self.parts: + if part['Name'] == idxOrName: return part + raise IndexError("cannot find partition %s" % repr(idxOrName)) + + def __len__(self): + return len(self.parts) + class ProcMtdEntry: def __init__(self, diff --git a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py index bf591df6..e6d24391 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py @@ -63,7 +63,12 @@ class MountManager(object): self.logger.debug("%s not mounted @ %s. It will be mounted %s" % (device, directory, mode)) try: - cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory) + p = device.find('ubi') + if p < 0: + cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory) + else: + cmd = "mount -o %s -t %s %s %s" % (','.join(mountargs), 'ubifs', device, directory) + self.logger.debug("+ %s" % cmd) subprocess.check_call(cmd, shell=True) except subprocess.CalledProcessError, e: @@ -148,12 +153,39 @@ class OnlMountManager(object): def _discover(k): v = md[k] lbl = v.get('label', k) - + useUbiDev = False try: v['device'] = subprocess.check_output(('blkid', '-L', lbl,)).strip() except subprocess.CalledProcessError: - return False - + useUbiDev = True + if useUbiDev == True: + if k == 'EFI-BOOT': + return False + output = subprocess.check_output("ubinfo -d 0 -N %s" % k, shell=True).splitlines() + volumeId = None + device = None + for line in output: + line = line.strip() + p = line.find(':') + if p < 0: + self.logger.debug("Invaild ubinfo output %s" % line) + + name, value = line[:p], line[p+1:].strip() + if 'Volume ID' in name: + p = value.find('(') + if p < 0: + self.logger.debug("Invalid Volume ID %s" % value) + + volumeId = value[:p].strip() + p = value.find('on') + if p < 0: + self.logger.debug("Invalid ubi devicde %s" % value) + + device = value[p+2:-1].strip() + if 'Name' in name: + v['device'] = "/dev/" + device + "_" + volumeId + + if not os.path.isdir(v['dir']): self.logger.debug("Make directory '%s'...", v['dir']) os.makedirs(v['dir']) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index b0849cf8..a2d00feb 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -477,6 +477,10 @@ class OnlPlatformPortConfig_48x1_4x10(object): PORT_COUNT=52 PORT_CONFIG="48x1 + 4x10" +class OnlPlatformPortConfig_48x1_2x10(object): + PORT_COUNT=50 + PORT_CONFIG="48x1 + 2x10" + class OnlPlatformPortConfig_48x10_4x40(object): PORT_COUNT=52 PORT_CONFIG="48x10 + 4x40" diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile index b16fc9d4..49f02b06 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/Makefile @@ -38,6 +38,6 @@ K_COPY_DST := kernel-3.2-lts-arm-iproc-all.bin.gz endif export ARCH=arm -DTS_LIST := accton_as4610_54 +DTS_LIST := accton_as4610_54 delta_ag6248c include $(ONL)/make/kbuild.mk diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config index 4df4b2f3..e70dd3b3 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/arm-iproc-all.config @@ -289,6 +289,7 @@ CONFIG_BCM_RAM_START_RESERVED_SIZE=0x200000 # CONFIG_MACH_GH is not set # CONFIG_MACH_DNI_3448P is not set CONFIG_MACH_ACCTON_AS4610_54=y +CONFIG_MACH_DELTA_AG6248C=y # CONFIG_MACH_IPROC_EMULATION is not set # @@ -1938,7 +1939,8 @@ CONFIG_IPROC_QSPI_SINGLE_MODE=y # CONFIG_IPROC_QSPI_DUAL_MODE is not set # CONFIG_IPROC_QSPI_QUAD_MODE is not set CONFIG_IPROC_QSPI_MAX_HZ=62500000 -# CONFIG_IPROC_MTD_NAND is not set +CONFIG_IPROC_MTD_NAND=y +# CONFIG_IPROC_MTD_NAND_USE_JFFS2 is not set # CONFIG_IPROC_PWM is not set CONFIG_IPROC_USB2H=y CONFIG_USB_EHCI_BCM=y diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch new file mode 100644 index 00000000..6dd2774b --- /dev/null +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/platform-delta-ag6248c-device-drivers.patch @@ -0,0 +1,181 @@ +diff --git a/arch/arm/boot/dts/delta_ag6248c.dts b/arch/arm/boot/dts/delta_ag6248c.dts +new file mode 100755 +index 0000000..f86c35b +--- /dev/null ++++ b/arch/arm/boot/dts/delta_ag6248c.dts +@@ -0,0 +1,78 @@ ++/* ++ * Delta Networks, Inc. AG6248C Device Tree Source ++ * ++ * Copyright 2015, Cumulus Networks, Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; either version 2 of the License, or (at your ++ * option) any later version. ++ * ++ */ ++/dts-v1/; ++/include/ "helix4.dtsi" ++ ++/ { ++ model = "delta,ag6248c"; ++ compatible = "delta,ag6248c"; ++ ++ aliases { ++ serial0 = &uart0; ++ i2c-controller0 = &i2c0; ++ i2c-controller1 = &i2c1; ++ }; ++ ++ memory { ++ reg = <0x61000000 0x7f000000>; ++ }; ++ ++ cpus { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ cpu@0 { ++ device_type = "cpu"; ++ compatible = "arm,cortex-a9"; ++ next-level-cache = <&L2>; ++ reg = <0x00>; ++ }; ++ cpu@1 { ++ device_type = "cpu"; ++ compatible = "arm,cortex-a9"; ++ next-level-cache = <&L2>; ++ reg = <0x01>; ++ }; ++ }; ++ ++ localbus@1e000000{ ++ address-cells = <0x2>; ++ #size-cells = <0x1>; ++ compatible = "simple-bus"; ++ ranges = <0x0 0x0 0x1e000000 0x02000000>; ++ ++ }; ++ ++ i2c0: i2c@18038000 { ++ compatible = "iproc-smb"; ++ reg = <0x18038000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ interrupts = < 127 >; ++ clock-frequency = <400000>; ++ rtc@68 { ++ compatible = "m41st85"; ++ reg = <0x68>; ++ }; ++ }; ++ ++ ++ i2c1: i2c@1803b000 { ++ compatible = "iproc-smb"; ++ reg = <0x1803b000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ interrupts = < 128 >; ++ clock-frequency = <100000>; ++ ++ }; ++}; +diff --git a/arch/arm/mach-iproc/Kconfig b/arch/arm/mach-iproc/Kconfig +index c77208d..c6a87fc 100644 +--- a/arch/arm/mach-iproc/Kconfig ++++ b/arch/arm/mach-iproc/Kconfig +@@ -49,6 +49,12 @@ config MACH_ACCTON_AS4610_54 + help + Support for Accton AS4610-54 POE and non -POE board. + ++config MACH_DELTA_AG6248C ++ select ARM_L1_CACHE_SHIFT_6 ++ bool "Support Delta AG6248C board" ++ help ++ Support for Delta AG6248C board. ++ + config MACH_IPROC_P7 + bool "Support iProc Profile 7 architecture" + depends on MACH_GH +diff --git a/arch/arm/mach-iproc/board_bu.c b/arch/arm/mach-iproc/board_bu.c +index 7e07ed1..5479020 100644 +--- a/arch/arm/mach-iproc/board_bu.c ++++ b/arch/arm/mach-iproc/board_bu.c +@@ -1083,6 +1083,7 @@ MACHINE_END + static const char * helix4_dt_board_compat[] = { + "dni,dni_3448p", + "accton,as4610_54", ++ "delta,ag6248c", + NULL + }; + +diff --git a/arch/arm/mach-iproc/common.c b/arch/arm/mach-iproc/common.c +index b116ffc..e911a2b 100644 +--- a/arch/arm/mach-iproc/common.c ++++ b/arch/arm/mach-iproc/common.c +@@ -187,7 +187,8 @@ static struct platform_device wdt_device = + enum { + HX4_NONE = 0, + HX4_DNI_3448P, +- HX4_ACCTON_AS4610_54 ++ HX4_ACCTON_AS4610_54, ++ HX4_DELTA_AG6248C, + }; + + /* +@@ -212,6 +213,8 @@ int brcm_get_hx4_model(void) + return HX4_DNI_3448P; + else if (!strcmp(model, "accton,as4610_54")) + return HX4_ACCTON_AS4610_54; ++ else if (!strcmp(model, "delta,ag6248c")) ++ return HX4_DELTA_AG6248C; + + printk( KERN_ERR "Unknown Model %s\n", model ); + return HX4_NONE; +diff --git a/arch/arm/mach-iproc/include/mach/iproc_regs.h b/arch/arm/mach-iproc/include/mach/iproc_regs.h +index 460c436..50ea557 100644 +--- a/arch/arm/mach-iproc/include/mach/iproc_regs.h ++++ b/arch/arm/mach-iproc/include/mach/iproc_regs.h +@@ -364,7 +364,11 @@ + #define IPROC_GMAC3_INT 182 + #elif (defined(CONFIG_MACH_HX4) || defined(CONFIG_MACH_KT2) || defined(CONFIG_MACH_DNI_3448P) || \ + defined(CONFIG_MACH_ACCTON_AS4610_54)) ++#if defined(CONFIG_MACH_DELTA_AG6248C) ++#define IPROC_NUM_GMACS 1 ++#else + #define IPROC_NUM_GMACS 2 ++#endif + #define IPROC_GMAC0_REG_BASE (GMAC0_DEVCONTROL) //(0x18022000) + #define IPROC_GMAC1_REG_BASE (GMAC1_DEVCONTROL) //(0x18023000) + #define IPROC_GMAC2_REG_BASE (0) // n/a +diff --git a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c +index d5b400d..a823697 100644 +--- a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c ++++ b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c +@@ -143,7 +143,8 @@ __setup("envaddr=", envaddr_setup); + enum { + HX4_NONE = 0, + HX4_DNI_3448P, +- HX4_ACCTON_AS4610_54 ++ HX4_ACCTON_AS4610_54, ++ HX4_DELTA_AG6248C + }; + + static void +@@ -158,7 +159,10 @@ setup_uboot_vars(void) { + } else if (modelnum == HX4_ACCTON_AS4610_54) { + env_offset = 0x000f0000; + uboot_vars_start = CONFIG_SPI_BASE + env_offset; +- } ++ }else if (modelnum == HX4_DELTA_AG6248C) { ++ env_offset = 0x00300000; ++ uboot_vars_start = CONFIG_NAND_BASE + env_offset; ++ } + } + + /* +-- +2.1.4 + diff --git a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series index e2adb686..3028ed13 100644 --- a/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series +++ b/packages/base/any/kernels/3.2-lts/configs/arm-iproc-all/patches/series @@ -506,3 +506,4 @@ scripts_package_Makefile.patch tools_include_tools_be_byteshift.h.patch tools_include_tools_le_byteshift.h.patch platform-accton-as4610-device-drivers.patch +platform-delta-ag6248c-device-drivers.patch diff --git a/packages/platforms/delta/armel/Makefile b/packages/platforms/delta/armel/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/README.md b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md new file mode 100644 index 00000000..b49d2126 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md @@ -0,0 +1,25 @@ +#How to run ONL in DELTA AG6248C board + +For the first step, it only support install the ONL to the USB and boot up. +It will be support to install the ONL to NandFlash next step. + +Build the ONL +-------------------------------------------------------------------------- +Please refer the $ONL/docs/Building.md + +Install the ONL through ONIE +-------------------------------------------------------------------------- +``` +ONIE:/ # onie-discovery-stop +discover: installer mode detected. +Stopping: discover... done. +ONIE:/ # +ONIE:/ # ifconfig eth0 192.168.1.1 #configure the DUT IP address +ONIE:/ # tftp -r ONL-2.*_ARMEL_INSTALLED_INSTALLER -g 192.168.1.99 -b 10240 +ONIE:/ # onie-nos-install ONL-2.*_ARMEL_INSTALLED_INSTALLER +``` +Boot the ONL +-------------------------------------------------------------------------- +Device will reboot automatically after install the ONL installer successfull. + +Now it will start the ONL boot progress. diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/.gitignore new file mode 100755 index 00000000..9f7b1342 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/.gitignore @@ -0,0 +1 @@ +onlpdump.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/PKG.yml new file mode 100755 index 00000000..4375c960 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c-poe KERNELS="onl-kernel-3.2-lts-arm-iproc-all:armel" diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/.gitignore new file mode 100755 index 00000000..a813c369 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/.gitignore @@ -0,0 +1,2 @@ +onlpdump.mk +lib diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/Makefile new file mode 100755 index 00000000..98c58425 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.2-lts-arm-iproc-all:armel +KMODULES := $(wildcard *.c) +VENDOR := delta +BASENAME := arm-delta-ag6248c-poe +ARCH := arm +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c new file mode 100755 index 00000000..29686679 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c @@ -0,0 +1,242 @@ +/* + * An I2C multiplexer dirver for delta as5812 CPLD + * + * Copyright (C) 2015 Delta Technology Corporation. + * Brandon Chuang + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Delta ag7648c CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x0 +#define CTRL_CPLD_I2C_ADDR 0x28 +#define PARENT_CHAN 0x0 +#define NUM_OF_CPLD_CHANS 0x2 + +#define CPLD_CHANNEL_SELECT_REG 0x19 +#define CPLD_CHANNEL_SELECT_MASK 0x3 +#define CPLD_CHANNEL_SELECT_OFFSET 0x0 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x2 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try; + s32 res = -EIO; + u8 reg_val = 0; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // read first + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + + // modify the field we wanted + data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte |= reg_val; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Dave Hu "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c new file mode 100755 index 00000000..c3354b89 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c @@ -0,0 +1,243 @@ +/* + * An I2C multiplexer dirver for delta as5812 CPLD + * + * Copyright (C) 2015 Delta Technology Corporation. + * Brandon Chuang + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Delta ag7648c CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x0 +#define CTRL_CPLD_I2C_ADDR 0x28 +#define PARENT_CHAN 0x1 +#define NUM_OF_CPLD_CHANS 0x2 + +#define CPLD_CHANNEL_SELECT_REG 0x19 +#define CPLD_CHANNEL_SELECT_MASK 0x3 +#define CPLD_CHANNEL_SELECT_OFFSET 0x5 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x2 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try; + s32 res = -EIO; + u8 reg_val = 0; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // read first + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + + // modify the field we wanted + data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte |= reg_val; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Dave Hu "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/PKG.yml new file mode 100755 index 00000000..0f9fdb5b --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=arm-delta-ag6248c-poe ARCH=armel TOOLCHAIN=arm-linux-gnueabi diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/Makefile new file mode 100755 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/Makefile new file mode 100755 index 00000000..8e449476 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/Makefile @@ -0,0 +1,44 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.armel.mk + +MODULE := libonlp-arm-delta-ag6248c-poe +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF arm_delta_ag6248c onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-arm-delta-ag6248c-poe.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/libonlp-arm-delta-ag6248c-poe.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/libonlp-arm-delta-ag6248c-poe.mk new file mode 100755 index 00000000..9edfe87c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/lib/libonlp-arm-delta-ag6248c-poe.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-arm-delta-ag6248c-poe module. +# +# Autogenerated 2016-07-20 18:27:47.344268 +# +############################################################################### +libonlp-arm-delta-ag6248c-poe_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..3fe979f3 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.armel.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp arm_delta_ag6248c onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/PKG.yml new file mode 100755 index 00000000..d8c6ed4a --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c-poe REVISION=r0 diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/lib/arm-delta-ag6248c-poe-r0.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/lib/arm-delta-ag6248c-poe-r0.yml new file mode 100755 index 00000000..ac3ed810 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/lib/arm-delta-ag6248c-poe-r0.yml @@ -0,0 +1,42 @@ +--- + +###################################################################### +# +# platform-config for AG6248C-POE +# +###################################################################### + +arm-delta-ag6248c-poe-r0: + flat_image_tree: + kernel: + <<: *arm-iproc-kernel + dtb: + =: delta_ag6248c.dtb + <<: *arm-iproc-kernel-package + itb: + <<: *arm-itb + + loader: + device: /dev/mtdblock4 + loadaddr: 0x70000000 + nos_bootcmds: *flash_bootcmds + + environment: + - device: /dev/mtd2 + env_offset: 0x00000000 + env_size: 0x00002000 + sector_size: 0x00010000 + + installer: + - ONL-BOOT: + =: 128MiB + format: ubifs + - ONL-CONFIG: + =: 128MiB + format: ubifs + - ONL-IMAGES: + =: 1024MiB + format: ubifs + - ONL-DATA: + =: 2048MiB + format: ubifs diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/python/arm_delta_ag6248c_poe_r0/__init__.py b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/python/arm_delta_ag6248c_poe_r0/__init__.py new file mode 100755 index 00000000..43045aec --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/platform-config/r0/src/python/arm_delta_ag6248c_poe_r0/__init__.py @@ -0,0 +1,21 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_arm_delta_ag6248c_poe_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x1_2x10): + PLATFORM='arm-delta-ag6248c-poe-r0' + MODEL="AG6248C-POE" + SYS_OBJECT_ID=".6248.1" + + def baseconfig(self): + self.insmod('arm-delta-ag6248c-poe-cpld-mux-1.ko') + self.insmod('arm-delta-ag6248c-poe-cpld-mux-2.ko') + + self.new_i2c_devices( + [ + # initiate lm75 + ('tmp75', 0x49, 0), + ('tmp75', 0x4a, 0), + + ] + ) + return True diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore new file mode 100644 index 00000000..4d978b36 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/.gitignore @@ -0,0 +1,2 @@ +*x86*64*cel*redstone*xp*.mk +onlpdump.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml new file mode 100755 index 00000000..cb9893f5 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c KERNELS="onl-kernel-3.2-lts-arm-iproc-all:armel" diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore new file mode 100755 index 00000000..a813c369 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/.gitignore @@ -0,0 +1,2 @@ +onlpdump.mk +lib diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile new file mode 100755 index 00000000..465902c8 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.2-lts-arm-iproc-all:armel +KMODULES := $(wildcard *.c) +VENDOR := delta +BASENAME := arm-delta-ag6248c +ARCH := arm +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c new file mode 100755 index 00000000..56d68b13 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c @@ -0,0 +1,242 @@ +/* + * An I2C multiplexer dirver for delta as5812 CPLD + * + * Copyright (C) 2017 Delta Networks, Inc. + * Brandon Chuang + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Delta ag7648c CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x0 +#define CTRL_CPLD_I2C_ADDR 0x28 +#define PARENT_CHAN 0x0 +#define NUM_OF_CPLD_CHANS 0x2 + +#define CPLD_CHANNEL_SELECT_REG 0x19 +#define CPLD_CHANNEL_SELECT_MASK 0x3 +#define CPLD_CHANNEL_SELECT_OFFSET 0x0 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x2 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try; + s32 res = -EIO; + u8 reg_val = 0; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // read first + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + + // modify the field we wanted + data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte |= reg_val; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Dave Hu "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c new file mode 100755 index 00000000..12b5fb38 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c @@ -0,0 +1,243 @@ +/* + * An I2C multiplexer dirver for delta as5812 CPLD + * + * Copyright (C) 2017 Delta Networks, Inc. + * Brandon Chuang + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Delta ag7648c CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x0 +#define CTRL_CPLD_I2C_ADDR 0x28 +#define PARENT_CHAN 0x1 +#define NUM_OF_CPLD_CHANS 0x2 + +#define CPLD_CHANNEL_SELECT_REG 0x19 +#define CPLD_CHANNEL_SELECT_MASK 0x3 +#define CPLD_CHANNEL_SELECT_OFFSET 0x5 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x2 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try; + s32 res = -EIO; + u8 reg_val = 0; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // read first + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res && res != -EAGAIN) + break; + + // modify the field we wanted + data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte |= reg_val; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Dave Hu "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml new file mode 100644 index 00000000..63b56dc7 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=arm-delta-ag6248c ARCH=armel TOOLCHAIN=arm-linux-gnueabi diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile new file mode 100644 index 00000000..46fdfee8 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/Makefile @@ -0,0 +1,44 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.armel.mk + +MODULE := libonlp-arm-delta-ag6248c +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF arm_delta_ag6248c onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-arm-delta-ag6248c.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk new file mode 100644 index 00000000..9cf2a027 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/lib/libonlp-arm-delta-ag6248c.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-arm-delta-ag6248c module. +# +# Autogenerated 2016-07-20 18:27:47.344268 +# +############################################################################### +libonlp-arm-delta-ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..3fe979f3 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.armel.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp arm_delta_ag6248c onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml new file mode 100644 index 00000000..16ff5c28 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c REVISION=r0 diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml new file mode 100644 index 00000000..ba1cbec5 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/lib/arm-delta-ag6248c-r0.yml @@ -0,0 +1,43 @@ +--- + +###################################################################### +# +# platform-config for AG6248C +# +###################################################################### + +arm-delta-ag6248c-r0: + flat_image_tree: + kernel: + <<: *arm-iproc-kernel + dtb: + =: delta_ag6248c.dtb + <<: *arm-iproc-kernel-package + itb: + <<: *arm-itb + + loader: + device: /dev/mtdblock4 + loadaddr: 0x70000000 + nos_bootcmds: *flash_bootcmds + + environment: + - device: /dev/mtd2 + env_offset: 0x00000000 + env_size: 0x00002000 + sector_size: 0x00010000 + + installer: + - ONL-BOOT: + =: 128MiB + format: ubifs + - ONL-CONFIG: + =: 128MiB + format: ubifs + - ONL-IMAGES: + =: 1024MiB + format: ubifs + - ONL-DATA: + =: 2048MiB + format: ubifs + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py new file mode 100755 index 00000000..7d7b97a1 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/platform-config/r0/src/python/arm_delta_ag6248c_r0/__init__.py @@ -0,0 +1,23 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_arm_delta_ag6248c_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x1_2x10): + PLATFORM='arm-delta-ag6248c-r0' + MODEL="AG6248C" + SYS_OBJECT_ID=".6248.2" + + def baseconfig(self): + self.insmod('arm-delta-ag6248c-cpld-mux-1.ko') + self.insmod('arm-delta-ag6248c-cpld-mux-2.ko') + + self.new_i2c_devices( + [ + # initiate lm75 + ('tmp75', 0x49, 0), + ('tmp75', 0x4a, 0), + + + + ] + ) + return True diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore new file mode 100644 index 00000000..82fb1eaf --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.gitignore @@ -0,0 +1,2 @@ +/arm_delta_ag6248c_poe.mk +/doc diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module new file mode 100644 index 00000000..1e18e32c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/.module @@ -0,0 +1 @@ +name: arm_delta_ag6248c diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile new file mode 100644 index 00000000..bfc40983 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/Makefile @@ -0,0 +1,28 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.mk +MODULE := arm_delta_ag6248c +AUTOMODULE := arm_delta_ag6248c +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy new file mode 100644 index 00000000..b13fcf5d --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.doxy @@ -0,0 +1,1869 @@ +# Doxyfile 1.8.3.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "arm_delta_ag6248c" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Open Network Platform Linux Example Implementation." + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented classes, +# or namespaces to their corresponding documentation. Such a link can be +# prevented in individual cases by by putting a percent sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if section-label ... \endif +# and \cond section-label ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. Do not use +# file names with spaces, bibtex cannot handle them. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = module/inc + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page (index.html). +# This can be useful if you have a project on for instance GitHub and want reuse +# the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# SVG. The default value is HTML-CSS, which is slower, but has the best +# compatibility. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a web server instead of a web client using Javascript. +# There are two flavours of web server based search depending on the +# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for +# searching and an index file used by the script. When EXTERNAL_SEARCH is +# enabled the indexing and searching needs to be provided by external tools. +# See the manual for details. + +SERVER_BASED_SEARCH = NO + +# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP +# script for searching. Instead the search results are written to an XML file +# which needs to be processed by an external indexer. Doxygen will invoke an +# external search engine pointed to by the SEARCHENGINE_URL option to obtain +# the search results. Doxygen ships with an example indexer (doxyindexer) and +# search engine (doxysearch.cgi) which are based on the open source search engine +# library Xapian. See the manual for configuration details. + +EXTERNAL_SEARCH = NO + +# The SEARCHENGINE_URL should point to a search engine hosted by a web server +# which will returned the search results when EXTERNAL_SEARCH is enabled. +# Doxygen ships with an example search engine (doxysearch) which is based on +# the open source search engine library Xapian. See the manual for configuration +# details. + +SEARCHENGINE_URL = + +# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed +# search data is written to a file for indexing by an external tool. With the +# SEARCHDATA_FILE tag the name of this file can be specified. + +SEARCHDATA_FILE = searchdata.xml + +# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the +# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is +# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple +# projects and redirect the results back to the right project. + +EXTERNAL_SEARCH_ID = + +# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen +# projects other than the one defined by this configuration file, but that are +# all added to the same external search index. Each project needs to have a +# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id +# of to a relative location where the documentation can be found. +# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... + +EXTRA_SEARCH_MAPPINGS = + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50 percent before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk new file mode 100644 index 00000000..42ac4368 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/arm_delta_ag6248c.mk @@ -0,0 +1,13 @@ + +############################################################################### +# +# Inclusive Makefile for the arm_delta_ag6248c module. +# +# Autogenerated 2017-02-16 14:19:33.628446 +# +############################################################################### +arm_delta_ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(arm_delta_ag6248c_BASEDIR)module/make.mk +include $(arm_delta_ag6248c_BASEDIR)module/auto/make.mk +include $(arm_delta_ag6248c_BASEDIR)module/src/make.mk + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml new file mode 100644 index 00000000..80f1a97d --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml @@ -0,0 +1,67 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ + +cdefs: &cdefs +- ONLPSIM_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- ONLPSIM_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- ONLPSIM_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: ONLPSIM_CONFIG_PORTING_STDLIB +- ONLPSIM_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- ONLPSIM_CONFIG_SFP_COUNT: + doc: "SFP Count." + default: 0 + +definitions: + cdefs: + ONLPSIM_CONFIG_HEADER: + defs: *cdefs + basename: arm_delta_ag6248c_config + + portingmacro: + ONLPSIM: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk new file mode 100644 index 00000000..57889792 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/make.mk @@ -0,0 +1,28 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ + +arm_delta_ag6248c_AUTO_DEFS := module/auto/arm_delta_ag6248c.yml +arm_delta_ag6248c_AUTO_DIRS := module/inc/arm_delta_ag6248c module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x new file mode 100644 index 00000000..f15500cc --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x @@ -0,0 +1,34 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h new file mode 100644 index 00000000..68664185 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h @@ -0,0 +1,162 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +/**************************************************************************//** + * + * @file + * @brief arm_delta_ag6248c Configuration Header + * + * @addtogroup arm_delta_ag6248c-config + * @{ + * + *****************************************************************************/ +#ifndef __ONLPSIM_CONFIG_H__ +#define __ONLPSIM_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef ONLPSIM_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * ONLPSIM_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef ONLPSIM_CONFIG_INCLUDE_LOGGING +#define ONLPSIM_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT +#define ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * ONLPSIM_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef ONLPSIM_CONFIG_LOG_BITS_DEFAULT +#define ONLPSIM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * ONLPSIM_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef ONLPSIM_CONFIG_PORTING_STDLIB +#define ONLPSIM_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLPSIM_CONFIG_PORTING_STDLIB +#endif + +/** + * ONLPSIM_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef ONLPSIM_CONFIG_INCLUDE_UCLI +#define ONLPSIM_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * ONLPSIM_CONFIG_SFP_COUNT + * + * SFP Count. */ + + +#ifndef ONLPSIM_CONFIG_SFP_COUNT +#define ONLPSIM_CONFIG_SFP_COUNT 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct arm_delta_ag6248c_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} arm_delta_ag6248c_config_settings_t; + +/** Configuration settings table. */ +/** arm_delta_ag6248c_config_settings table. */ +extern arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* arm_delta_ag6248c_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "arm_delta_ag6248c_porting.h" + +#endif /* __ONLPSIM_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h new file mode 100644 index 00000000..20f312ed --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h @@ -0,0 +1,51 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +/********************************************************//** + * + * arm_delta_ag6248c Doxygen Header + * + ***********************************************************/ +#ifndef __ONLPSIM_DOX_H__ +#define __ONLPSIM_DOX_H__ + +/** + * @defgroup arm_delta_ag6248c arm_delta_ag6248c - onlpsim Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup arm_delta_ag6248c-arm_delta_ag6248c Public Interface + * @defgroup arm_delta_ag6248c-config Compile Time Configuration + * @defgroup arm_delta_ag6248c-porting Porting Macros + * + * @} + * + */ + +#endif /* __ONLPSIM_DOX_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h new file mode 100644 index 00000000..19853401 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h @@ -0,0 +1,132 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +/********************************************************//** + * + * @file + * @brief arm_delta_ag6248c Porting Macros. + * + * @addtogroup arm_delta_ag6248c-porting + * @{ + * + ***********************************************************/ +#ifndef __ONLPSIM_PORTING_H__ +#define __ONLPSIM_PORTING_H__ + + +/* */ +#if ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef ONLPSIM_MALLOC + #if defined(GLOBAL_MALLOC) + #define ONLPSIM_MALLOC GLOBAL_MALLOC + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_MALLOC malloc + #else + #error The macro ONLPSIM_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_FREE + #if defined(GLOBAL_FREE) + #define ONLPSIM_FREE GLOBAL_FREE + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_FREE free + #else + #error The macro ONLPSIM_FREE is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_MEMSET + #if defined(GLOBAL_MEMSET) + #define ONLPSIM_MEMSET GLOBAL_MEMSET + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_MEMSET memset + #else + #error The macro ONLPSIM_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define ONLPSIM_MEMCPY GLOBAL_MEMCPY + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_MEMCPY memcpy + #else + #error The macro ONLPSIM_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define ONLPSIM_STRNCPY GLOBAL_STRNCPY + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_STRNCPY strncpy + #else + #error The macro ONLPSIM_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define ONLPSIM_VSNPRINTF GLOBAL_VSNPRINTF + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_VSNPRINTF vsnprintf + #else + #error The macro ONLPSIM_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define ONLPSIM_SNPRINTF GLOBAL_SNPRINTF + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_SNPRINTF snprintf + #else + #error The macro ONLPSIM_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef ONLPSIM_STRLEN + #if defined(GLOBAL_STRLEN) + #define ONLPSIM_STRLEN GLOBAL_STRLEN + #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 + #define ONLPSIM_STRLEN strlen + #else + #error The macro ONLPSIM_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __ONLPSIM_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk new file mode 100644 index 00000000..29f7a9f3 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/make.mk @@ -0,0 +1,29 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +arm_delta_ag6248c_INCLUDES := -I $(THIS_DIR)inc +arm_delta_ag6248c_INTERNAL_INCLUDES := -I $(THIS_DIR)src +arm_delta_ag6248c_DEPENDMODULE_ENTRIES := init:arm_delta_ag6248c ucli:arm_delta_ag6248c + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile new file mode 100644 index 00000000..94aa2ec9 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/Makefile @@ -0,0 +1,30 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# Local source generation targets. +# +############################################################ + +include ../../../../init.mk + +ucli: + $(SUBMODULE_BIGCODE)/tools/uclihandlers.py arm_delta_ag6248c_ucli.c + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c new file mode 100644 index 00000000..6447135c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c @@ -0,0 +1,101 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +/* */ +#define __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) #_x +#define __arm_delta_ag6248c_config_STRINGIFY_VALUE(_x) __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) +arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[] = +{ +#ifdef ONLPSIM_CONFIG_INCLUDE_LOGGING + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_LOGGING), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_LOGGING) }, +#else +{ ONLPSIM_CONFIG_INCLUDE_LOGGING(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_LOG_BITS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ ONLPSIM_CONFIG_LOG_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_PORTING_STDLIB + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_STDLIB), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_STDLIB) }, +#else +{ ONLPSIM_CONFIG_PORTING_STDLIB(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_INCLUDE_UCLI + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_UCLI), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_UCLI) }, +#else +{ ONLPSIM_CONFIG_INCLUDE_UCLI(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef ONLPSIM_CONFIG_SFP_COUNT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_SFP_COUNT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_SFP_COUNT) }, +#else +{ ONLPSIM_CONFIG_SFP_COUNT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __arm_delta_ag6248c_config_STRINGIFY_VALUE +#undef __arm_delta_ag6248c_config_STRINGIFY_NAME + +const char* +arm_delta_ag6248c_config_lookup(const char* setting) +{ + int i; + for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) { + if(strcmp(arm_delta_ag6248c_config_settings[i].name, setting)) { + return arm_delta_ag6248c_config_settings[i].value; + } + } + return NULL; +} + +int +arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", arm_delta_ag6248c_config_settings[i].name, arm_delta_ag6248c_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c new file mode 100644 index 00000000..2a14c2cc --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c @@ -0,0 +1,30 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h new file mode 100644 index 00000000..8dfd2c7c --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h @@ -0,0 +1,32 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#ifndef __ONLPSIM_INT_H__ +#define __ONLPSIM_INT_H__ + +#include + + +#endif /* __ONLPSIM_INT_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c new file mode 100644 index 00000000..1941f294 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c @@ -0,0 +1,38 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +#include "arm_delta_ag6248c_log.h" +/* + * arm_delta_ag6248c log struct. + */ +AIM_LOG_STRUCT_DEFINE( + ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT, + ONLPSIM_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h new file mode 100644 index 00000000..13d00bc5 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h @@ -0,0 +1,32 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#ifndef __ONLPSIM_LOG_H__ +#define __ONLPSIM_LOG_H__ + +#define AIM_LOG_MODULE_NAME arm_delta_ag6248c +#include + +#endif /* __ONLPSIM_LOG_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c new file mode 100644 index 00000000..fdb080f0 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c @@ -0,0 +1,44 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +#include "arm_delta_ag6248c_log.h" + +static int +datatypes_init__(void) +{ +#define ONLPSIM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __arm_delta_ag6248c_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c new file mode 100644 index 00000000..4dbeeed0 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c @@ -0,0 +1,82 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#include + +#if ONLPSIM_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +arm_delta_ag6248c_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(arm_delta_ag6248c) +} + +/* */ +/****************************************************************************** + * + * These handler table(s) were autogenerated from the symbols in this + * source file. + * + *****************************************************************************/ +static ucli_command_handler_f arm_delta_ag6248c_ucli_ucli_handlers__[] = +{ + arm_delta_ag6248c_ucli_ucli__config__, + NULL +}; +/******************************************************************************/ +/* */ + +static ucli_module_t +arm_delta_ag6248c_ucli_module__ = + { + "arm_delta_ag6248c_ucli", + NULL, + arm_delta_ag6248c_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +arm_delta_ag6248c_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&arm_delta_ag6248c_ucli_module__); + n = ucli_node_create("arm_delta_ag6248c", NULL, &arm_delta_ag6248c_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("arm_delta_ag6248c")); + return n; +} + +#else +void* +arm_delta_ag6248c_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c new file mode 100755 index 00000000..a7a83e0e --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "arm_delta_ag6248c_log.h" +#include "arm_delta_i2c.h" +#include + +struct i2c_device_info i2c_device_list[]={ + {"RTC",0X0,0X68}, + {"TMP1_CLOSE_TO_MAC",0X0,0X49}, + {"TMP2_CLOSE_TO_PHY",0X0,0X4a}, + {"CPLD",0X0,0X28}, + {"FAN_ON_BOARD",0X1,0X2C}, + {"CURT_MONTOR",0X1,0X40}, + {"SFP1",0X2,0X50}, + {"SFP2",0X3,0X50}, +// ------------------------- + {"PSU1_PMBUS",0X4,0X58}, + {"PSU2_PMBUS",0X5,0X59}, + {"PSU1_EEPROM",0X4,0X50}, + {"PSU2_EEPROM",0X5,0X51}, +// ------------------------- + {"PSU1_PMBUS_POE",0X4,0X58}, + {"PSU2_PMBUS_POE",0X5,0X58}, + {"PSU1_EEPROM_POE",0X4,0X52}, + {"PSU2_EEPROM_POE",0X5,0X52}, + {NULL, -1,-1}, +}; + + +uint32_t i2c_flag=ONLP_I2C_F_FORCE; + + +i2c_device_info_t *i2c_dev_find_by_name (char *name) +{ + i2c_device_info_t *i2c_dev = i2c_device_list; + + if (name == NULL) return NULL; + + while (i2c_dev->name) { + if (strcmp (name, i2c_dev->name) == 0) break; + ++ i2c_dev; + } + if (i2c_dev->name == NULL) return NULL; + + return i2c_dev; +} + +int i2c_devname_read_byte (char *name, int reg) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_readb (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); + + return ret; +} + +int i2c_devname_write_byte (char *name, int reg, int value) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_writeb (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); + + + return ret; +} + +int i2c_devname_read_word (char *name, int reg) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_readw (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); + + return ret; +} + +int i2c_devname_write_word (char *name, int reg, int value) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_writew (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); + + return ret; +} + +int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size) +{ + int ret = -1; + + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret = onlp_i2c_block_read (i2c_dev->i2cbus, i2c_dev->addr, reg, buff_size, buff, i2c_flag); + + return ret; + +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h new file mode 100755 index 00000000..76c35cbb --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h @@ -0,0 +1,54 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************/ +/* the i2c struct header*/ + +#ifndef __ARM_DELTA_I2C_H__ +#define __ARM_DELTA_I2C_H__ + +#include "arm_delta_ag6248c_log.h" + +struct i2c_device_info { + /*i2c device name*/ + char *name; + char i2cbus; + char addr; +}; + + +typedef struct i2c_device_info i2c_device_info_t; + +extern struct i2c_device_info i2c_device_list[]; + + +extern int i2c_devname_read_byte(char *name, int reg); + +extern int i2c_devname_write_byte(char *name, int reg, int value); + + +extern int i2c_devname_read_word(char *name, int reg); + +extern int i2c_devname_write_word(char *name, int reg, int value); + + +extern int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size); + +#endif diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c new file mode 100755 index 00000000..b0c16526 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c @@ -0,0 +1,470 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_i2c.h" +#include + +#define MAX_FAN_SPEED 12000 +#define MAX_PSU_FAN_SPEED 23000 + +#define FILE_NAME_LEN 80 + +/* The MAX6639 registers, valid channel numbers: 0, 1 */ +#define MAX6639_REG_STATUS 0x02 +#define MAX6639_REG_FAN_CONFIG1(ch) (0x10 + 4*(ch-1)) +#define MAX6639_REG_FAN_CNT(ch) (0x20 + (ch-1)) +#define MAX6639_REG_TARGET_CNT(ch) (0x22 + (ch-1)) + +/*define the reg bit mask*/ +#define MAX6639_REG_FAN_STATUS_BIT(ch) (0X02>>(ch-1)) +#define MAX6639_FAN_CONFIG1_RPM_RANGE 0x03 +#define MAX6639_FAN_PRESENT_REG (0x0c) +#define MAX6639_FAN_PRESENT_BIT (0x2) +#define MAX6639_FAN_GOOD_BIT (0x1) +#define FAN_FROM_REG(val) ((480000.0) / (val)) + +static int fan_initd=0; + +enum onlp_fan_id +{ + FAN_RESERVED = 0, + FAN_1_ON_MAIN_BOARD, + FAN_2_ON_MAIN_BOARD, + FAN_1_ON_PSU1, + FAN_1_ON_PSU2 +}; + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM| ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ + (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int + _onlp_psu_fan_val_to_rpm (int v) +{ + int lf = (v & 0xffff); + int y, n; + + y = lf & 0x7ff; + n = ((lf >> 11) & 0x1f); + + return (y * (1 << n)); +} + +static int +_onlp_fan_board_init(void) +{ + i2c_devname_write_byte("FAN_ON_BOARD", 0x03,0xfc); + i2c_devname_write_byte("FAN_ON_BOARD", 0x04,0x30); + + i2c_devname_write_byte("FAN_ON_BOARD", 0x10,0x23); + i2c_devname_write_byte("FAN_ON_BOARD", 0x11,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x12,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x13,0x21); + i2c_devname_write_byte("FAN_ON_BOARD", 0x24,0xe8); + + i2c_devname_write_byte("FAN_ON_BOARD", 0x14,0x23); + i2c_devname_write_byte("FAN_ON_BOARD", 0x15,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x16,0x00); + i2c_devname_write_byte("FAN_ON_BOARD", 0x17,0x21); + i2c_devname_write_byte("FAN_ON_BOARD", 0x25,0xe8); + + fan_initd=1; + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) +{ + int r_data,fan_good,fan_present,fan_fault; + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + /* get fan fault status (turn on when any one fails)*/ + r_data= i2c_devname_read_byte("CPLD",MAX6639_FAN_PRESENT_REG); + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_present = r_data & MAX6639_FAN_PRESENT_BIT; + + if(!fan_present){ + + info->status |= ONLP_FAN_STATUS_PRESENT; + + fan_good=r_data&MAX6639_FAN_GOOD_BIT; + + if(fan_good) + info->status&=~ONLP_FAN_STATUS_FAILED; + else{ + r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_STATUS); + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_fault=r_data & MAX6639_REG_FAN_STATUS_BIT(local_id); + + if(!fan_fault) + info->status &=~ ONLP_FAN_STATUS_FAILED; + else{ + info->status |=ONLP_FAN_STATUS_FAILED; + info->rpm=0; + info->percentage=0; + goto mode; + } + } + } + else{ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + + /* get fan speed */ + r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_FAN_CNT(local_id)); + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + info->rpm = FAN_FROM_REG(r_data); + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_FAN_SPEED; + +mode: + if(info->percentage>100) + strcpy(info->model,"ONLP_FAN_MODE_LAST"); + else if(info->percentage==100) + strcpy(info->model,"ONLP_FAN_MODE_MAX"); + else if(info->percentage>=75&&info->percentage<100) + strcpy(info->model,"ONLP_FAN_MODE_FAST"); + else if(info->percentage>=35&&info->percentage<75) + strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); + else if(info->percentage>0&&info->percentage<35) + strcpy(info->model,"ONLP_FAN_MODE_SLOW"); + else if(info->percentage<=0) + strcpy(info->model,"ONLP_FAN_MODE_OFF"); + else{ } + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) +{ + int psu_id; + int r_data,fan_rpm; + int psu_present; + int psu_good; + psu_type_t psu_type; + + enum ag6248c_product_id pid = get_product_id(); + /* get fan fault status + */ + psu_id = (local_id - FAN_1_ON_PSU1) + 1; + DEBUG_PRINT("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id); + + psu_type = get_psu_type(psu_id); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */ + DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type); + psu_present=psu_status_info_get(psu_id, "present"); + psu_good=psu_status_info_get(psu_id, "good"); + if((psu_present<=0)||(psu_good<=0)){ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B); + break; + case PSU_TYPE_AC_B2F: + info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* get fan speed*/ + if(pid == PID_AG6248C_48){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x90); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x90); + } + else{ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x90); + else + r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x90); + } + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_rpm=_onlp_psu_fan_val_to_rpm(r_data); + + info->rpm = fan_rpm; + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_PSU_FAN_SPEED; + + if(info->percentage>100) + strcpy(info->model,"ONLP_FAN_MODE_LAST"); + else if(info->percentage==100) + strcpy(info->model,"ONLP_FAN_MODE_MAX"); + else if(info->percentage>=75&&info->percentage<100) + strcpy(info->model,"ONLP_FAN_MODE_FAST"); + else if(info->percentage>=35&&info->percentage<75) + strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); + else if(info->percentage>0&&info->percentage<35) + strcpy(info->model,"ONLP_FAN_MODE_SLOW"); + else if(info->percentage<=0) + strcpy(info->model,"ONLP_FAN_MODE_OFF"); + else{} + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + int rc; + rc=_onlp_fan_board_init(); + return rc; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if (chassis_fan_count() == 0) { + local_id += 1; + } + + *info = linfo[local_id]; + + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + rc = _onlp_fani_info_get_fan_on_psu(local_id, info); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ /* + the rpm is the actual rpm/1000. so 16 represents the 16000(max spd) + */ + int fan_set_rpm_cont,rc; + int local_id; + int actual_rpm=rpm; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) + return ONLP_STATUS_E_UNSUPPORTED; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_INVALID; + } + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + /* reject rpm=0 (rpm=0, stop fan) */ + if (actual_rpm == 0) + return ONLP_STATUS_E_INVALID; + + /*get ret value for the speed set*/ + fan_set_rpm_cont=FAN_FROM_REG(actual_rpm); + + /*set the rpm speed */ + rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont); + + if(rc<0) + return ONLP_STATUS_E_INVALID; + + return ONLP_STATUS_OK; +} +/*set the percentage for the psu fan*/ + + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + /* + p is between 0 and 100 ,p=100 represents 16000(max spd) + */ + int rpm_val,fan_set_rpm_cont,rc; + int local_id; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) + return ONLP_STATUS_E_UNSUPPORTED; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_INVALID; + } + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + rpm_val=p*(MAX_FAN_SPEED/100); + + /*get ret value for the speed set*/ + fan_set_rpm_cont=FAN_FROM_REG(rpm_val); + + /*set the rpm speed */ + rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont); + + if(rc<0) + return ONLP_STATUS_E_INVALID; + + return ONLP_STATUS_OK; + + +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c new file mode 100755 index 00000000..66443e10 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/ledi.c @@ -0,0 +1,375 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include + +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_i2c.h" +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +#define CPLD_LED_MODE_REG (0X0A) +#define CPLD_LED_MODE_TEMP_REG (0X0B) +#define CPLD_LED_MODE_REG_BIT(ch) (0x3<<2*((ch)-1)) +#define CPLD_LED_MODE_TEMP_REG_BIT (0x0C) +#define CPLD_LED_MODE_MASTER_REG_BIT (0x02) +#define CPLD_LED_MODE_REG_OFFSET(ch) (2*((ch)-1)) +#define CPLD_LED_MODE_TEMP_REG_OFFSET (2) +#define CPLD_LED_MODE_MASTER_REG_OFFSET (1) + + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS), "sys", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN_BLINKING |ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_RED , + }, + + { + { ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 }, + ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + + { + { ONLP_LED_ID_CREATE(LED_PSU2), "psu2", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_GREEN , + }, + + { + { ONLP_LED_ID_CREATE(LED_PSU1), "psu1", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_GREEN , + }, + + { + { ONLP_LED_ID_CREATE(LED_TEMP), "temp", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_RED , + }, + + { + { ONLP_LED_ID_CREATE(LED_MASTER), "master", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN , + }, +}; + +static int conver_led_light_mode_to_onl(uint32_t id, int led_ligth_mode) +{ + switch (id) { + case LED_SYS: + switch (led_ligth_mode) { + case SYS_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; + case SYS_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case SYS_LED_MODE_RED: return ONLP_LED_MODE_RED; + case SYS_LED_MODE_RED_BLINKING: return ONLP_LED_MODE_RED_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_PSU1: + case LED_PSU2: + switch (led_ligth_mode) { + case PSU_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case PSU_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case PSU_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_FAN: + switch (led_ligth_mode) { + case FAN_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case FAN_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case FAN_LED_MODE_RED: return ONLP_LED_MODE_RED; + default: return ONLP_LED_MODE_OFF; + } + case LED_TEMP: + switch (led_ligth_mode) { + case TEMP_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case TEMP_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case TEMP_LED_MODE_RED: return ONLP_LED_MODE_RED; + default: return ONLP_LED_MODE_OFF; + } + case LED_MASTER: + switch (led_ligth_mode) { + case MASTER_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case MASTER_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + default: return ONLP_LED_MODE_OFF; + } + } + + return ONLP_LED_MODE_OFF; +} + +static int conver_onlp_led_light_mode_to_driver(uint32_t id, int led_ligth_mode) +{ + switch (id) { + case LED_SYS: + switch (led_ligth_mode) { + case ONLP_LED_MODE_GREEN_BLINKING: return SYS_LED_MODE_GREEN_BLINKING; + case ONLP_LED_MODE_GREEN: return SYS_LED_MODE_GREEN; + case ONLP_LED_MODE_RED: return SYS_LED_MODE_RED ; + case ONLP_LED_MODE_RED_BLINKING: return SYS_LED_MODE_RED_BLINKING; + default: return SYS_LED_MODE_UNKNOWN; + } + case LED_PSU1: + case LED_PSU2: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return PSU_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return PSU_LED_MODE_GREEN; + case ONLP_LED_MODE_GREEN_BLINKING: return PSU_LED_MODE_GREEN_BLINKING; + default: return PSU_LED_MODE_UNKNOWN; + } + case LED_FAN: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return FAN_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return FAN_LED_MODE_GREEN ; + case ONLP_LED_MODE_RED: return FAN_LED_MODE_RED; + default: return FAN_LED_MODE_UNKNOWN; + } + case LED_TEMP: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return TEMP_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return TEMP_LED_MODE_GREEN; + case ONLP_LED_MODE_RED: return TEMP_LED_MODE_RED; + default: return TEMP_LED_MODE_UNKNOWN; + } + case LED_MASTER: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return MASTER_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return MASTER_LED_MODE_GREEN; + default: return TEMP_LED_MODE_UNKNOWN; + } + + } + + return ONLP_LED_MODE_OFF; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +onlp_ledi_oid_to_internal_id(onlp_oid_t id) +{ + int lid = ONLP_OID_ID_GET(id); + + switch (lid) { + case 1: return LED_SYS; + case 2: return LED_FAN; + case 3: return LED_PSU2; + case 4: return LED_PSU1; + case 5: return LED_TEMP; + case 6: return LED_MASTER; + default : + return LED_UNKNOW; + } + + return LED_UNKNOW; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int r_data,m_data; + + VALIDATE(id); + + enum ag6248c_product_id pid = get_product_id(); + + int lid = onlp_ledi_oid_to_internal_id(id); + + if (pid == PID_AG6248C_48) { + if((lid >= LED_UNKNOW) || (lid < LED_SYS)) + return ONLP_STATUS_E_UNSUPPORTED; + } + else if (pid == PID_AG6248C_48P) { + if((lid >= LED_MASTER) || (lid < LED_SYS)) + return ONLP_STATUS_E_UNSUPPORTED; + } + else + return ONLP_STATUS_E_UNSUPPORTED; + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[lid]; + + if((lid==LED_TEMP)||(lid==LED_MASTER)) + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG); + else + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG); + + if(r_data<0) + return ONLP_STATUS_E_INTERNAL; + + if(lid==LED_TEMP) + m_data=(r_data & CPLD_LED_MODE_TEMP_REG_BIT); + else if(lid==LED_MASTER) + m_data=(r_data & CPLD_LED_MODE_MASTER_REG_BIT); + else + m_data=(r_data & CPLD_LED_MODE_REG_BIT(lid)); + + if(lid==LED_TEMP) + m_data=(m_data>> CPLD_LED_MODE_TEMP_REG_OFFSET); + else if(lid==LED_MASTER) + m_data=(m_data>> CPLD_LED_MODE_MASTER_REG_OFFSET); + else + m_data=(m_data>>CPLD_LED_MODE_REG_OFFSET(lid)); + + info->mode = conver_led_light_mode_to_onl(lid, m_data); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + + } + + return ONLP_STATUS_OK; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int r_data,driver_mode, rc; + + VALIDATE(id); + + enum ag6248c_product_id pid = get_product_id(); + + int lid = onlp_ledi_oid_to_internal_id(id); + + if (pid == PID_AG6248C_48) { + if((lid >= LED_UNKNOW) || (lid < LED_SYS)) + return ONLP_STATUS_E_UNSUPPORTED; + } + else if (pid == PID_AG6248C_48P) { + if((lid >= LED_MASTER) || (lid < LED_SYS)) + return ONLP_STATUS_E_UNSUPPORTED; + } + else + return ONLP_STATUS_E_UNSUPPORTED; + + driver_mode = conver_onlp_led_light_mode_to_driver(lid, mode); + + if((driver_mode==SYS_LED_MODE_UNKNOWN)||(driver_mode==PSU_LED_MODE_UNKNOWN)||\ + (driver_mode==FAN_LED_MODE_UNKNOWN)||(driver_mode==TEMP_LED_MODE_UNKNOWN)||\ + (driver_mode==MASTER_LED_MODE_UNKNOWN)) + return ONLP_STATUS_E_UNSUPPORTED; + + if((lid==LED_TEMP)||(lid==LED_MASTER)) + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG); + else + r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG); + + if(r_data<0) + return ONLP_STATUS_E_INTERNAL; + + if(lid==LED_TEMP) + r_data=r_data&(~CPLD_LED_MODE_TEMP_REG_BIT); + else if(lid==LED_MASTER) + r_data=r_data&(~CPLD_LED_MODE_MASTER_REG_BIT); + else + r_data=r_data&(~CPLD_LED_MODE_REG_BIT(lid)); + + if(lid==LED_TEMP) + driver_mode=(driver_mode< +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ + +LIBRARY := arm_delta_ag6248c +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +#$(LIBRARY)_LAST := 1 +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c new file mode 100755 index 00000000..118cc437 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c @@ -0,0 +1,85 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_i2c.h" + + +psu_type_t get_psu_type(int id) +{ + if ((id == PSU1_ID)||(id == PSU2_ID)) + return PSU_TYPE_AC_B2F; + return PSU_TYPE_UNKNOWN; +} + +enum ag6248c_product_id get_product_id(void) +{ + int ret; + int pid = PID_UNKNOWN; + + ret = i2c_devname_read_byte("CPLD", 0X01); + + if(ret<0) + return PID_UNKNOWN; + + pid = ((ret&0xf0)>>4); + + + if (pid >= PID_UNKNOWN || pid < PID_AG6248C_48) { + return PID_UNKNOWN; + } + + return pid; +} + +int chassis_fan_count(void) +{ + enum ag6248c_product_id pid = get_product_id(); + + if ((pid == PID_AG6248C_48P)||(pid == PID_AG6248C_48)) { + return 4; + } + + return 0 ; +} + +int chassis_led_count(void) +{ + enum ag6248c_product_id pid = get_product_id(); + + if (pid == PID_AG6248C_48P) + return 5; + else if(pid == PID_AG6248C_48) + return 6; + else + return 0; +} diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h new file mode 100755 index 00000000..7cd66a5f --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.h @@ -0,0 +1,136 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "arm_delta_ag6248c_log.h" + +#define CHASSIS_THERMAL_COUNT 4 +#define CHASSIS_PSU_COUNT 2 + +#define PSU1_ID 1 +#define PSU2_ID 2 + + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +enum onlp_fan_duty_cycle_percentage +{ + FAN_IDLE_RPM = 5500, + FAN_LEVEL1_RPM = 7000, + FAN_LEVEL2_RPM = 9000, + FAN_LEVEL3_RPM = 12000, +}; + +enum ag6248c_product_id { + PID_AG6248C_48= 2, + PID_AG6248C_48P=4, + PID_UNKNOWN +}; +/* LED related data */ +enum sys_led_light_mode { + SYS_LED_MODE_GREEN_BLINKING = 0, + SYS_LED_MODE_GREEN, + SYS_LED_MODE_RED, + SYS_LED_MODE_RED_BLINKING, + SYS_LED_MODE_AUTO, + SYS_LED_MODE_UNKNOWN +}; + +enum fan_led_light_mode { + FAN_LED_MODE_OFF=0, + FAN_LED_MODE_GREEN, + FAN_LED_MODE_RED, + FAN_LED_MODE_RESERVERD, + FAN_LED_MODE_AUTO, + FAN_LED_MODE_UNKNOWN +}; + +enum psu_led_light_mode { + PSU_LED_MODE_OFF =0, + PSU_LED_MODE_GREEN, + PSU_LED_MODE_GREEN_BLINKING, + PSU_LED_MODE_RESERVERD, + PSU_LED_MODE_UNKNOWN +}; + +enum temp_led_light_mode { + TEMP_LED_MODE_OFF =0, + TEMP_LED_MODE_GREEN, + TEMP_LED_MODE_RED, + TEMP_LED_MODE_RESERVERD, + TEMP_LED_MODE_UNKNOWN +}; + +enum master_led_light_mode { + MASTER_LED_MODE_OFF =0, + MASTER_LED_MODE_GREEN, + MASTER_LED_MODE_OFF1, + MASTER_LED_MODE_RESERVERD, + MASTER_LED_MODE_UNKNOWN +}; + +typedef enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS, + LED_FAN, + LED_PSU2, + LED_PSU1, + LED_TEMP, + LED_MASTER, + LED_UNKNOW +} onlp_led_id_t; + +enum ag6248c_product_id get_product_id(void); +int chassis_fan_count(void); +int chassis_led_count(void); + +typedef enum platform_id_e { + PLATFORM_ID_UNKNOWN, + PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0, + PLATFORM_ID_POWERPC_DELTA_AG6248C_R0, +} platform_id_t; + +extern platform_id_t platform_id; + +extern int psu_status_info_get(int id, char *node); +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c new file mode 100755 index 00000000..3a0d8344 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/psui.c @@ -0,0 +1,381 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_i2c.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 +#define PSU_STATUS_REG (0X08) +#define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1)) +#define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1)) +#define PSU_STATUS_PRESENT_OFFSET(ch) (4*ch-1) +#define PSU_STATUS_GOOD_OFFSET(ch) (0x2+4*(ch-1)) +#define PSU_PNBUS_VIN_REG (0x88) +#define PSU_PNBUS_IIN_REG (0x89) +#define PSU_PNBUS_PIN_REG (0x97) +#define PSU_PNBUS_VOUT_REG (0x8b) +#define PSU_PNBUS_IOUT_REG (0x8c) +#define PSU_PNBUS_POUT_REG (0x96) +#define PSU_PNBUS_SERIAL_REG (0x39) +#define PSU_PNBUS_MODEL_REG (0xc) + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static long psu_data_convert(unsigned int d, int mult) +{ + long X, Y, N, n; + + Y = d & 0x07FF; + N = (d >> 11) & 0x0f; + n = d & 0x8000 ? 1 : 0; + + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = (Y * mult) * (N=(1<<(N&0xf))); + + return X; +} + +static long psu_data_convert_16(unsigned int d, int mult) +{ + long X; + X = (d * mult) / (1 << 9); + return X; + +} + + +int +psu_status_info_get(int id, char *node) +{ + int ret; + int r_data; + ret=i2c_devname_read_byte("CPLD",PSU_STATUS_REG); + + if(ret<0) + return -1; + + if (PSU1_ID == id) { + if(!strcmp("present",node)) + r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); + else if(!strcmp("good",node)) + r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); + else + r_data=-1; + + } + else if (PSU2_ID == id) { + + if(!strcmp("present",node)) + r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); + else if(!strcmp("good",node)) + r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); + else + r_data=-1; + } + else{ + r_data=-1; + } + + return r_data; +} + +static int +psu_value_info_get(int id, char *type) +{ + int ret; + char *dev_name; + int reg_offset; + + enum ag6248c_product_id pid = get_product_id(); + + if(pid == PID_AG6248C_48){ + if(PSU1_ID == id) + dev_name="PSU1_PMBUS"; + else + dev_name="PSU2_PMBUS"; + } + else{ + if(PSU1_ID == id) + dev_name="PSU1_PMBUS_POE"; + else + dev_name="PSU2_PMBUS_POE"; + } + + if(!strcmp(type,"vin")) + reg_offset=PSU_PNBUS_VIN_REG; + else if(!strcmp(type,"iin")) + reg_offset=PSU_PNBUS_IIN_REG; + else if(!strcmp(type,"pin")) + reg_offset=PSU_PNBUS_PIN_REG; + else if(!strcmp(type,"vout")) + reg_offset=PSU_PNBUS_VOUT_REG; + else if(!strcmp(type,"iout")) + reg_offset=PSU_PNBUS_IOUT_REG; + else + reg_offset=PSU_PNBUS_POUT_REG; + + ret=i2c_devname_read_word(dev_name,reg_offset); + + if(ret<0) + return -1; + + return ret; +} + + +static int +psu_serial_model_info_get(int id,char *type,char*data,int data_len) +{ + int i,r_data,re_cnt; + char *dev_name; + int reg_offset; + + enum ag6248c_product_id pid = get_product_id(); + + if(pid == PID_AG6248C_48){ + if(PSU1_ID == id) + dev_name="PSU1_EEPROM"; + else + dev_name="PSU2_EEPROM"; + } + else{ + if(PSU1_ID == id) + dev_name="PSU1_EEPROM_POE"; + else + dev_name="PSU2_EEPROM_POE"; + } + + if(!strcmp(type,"serial")) + reg_offset=PSU_PNBUS_SERIAL_REG; + else + reg_offset=PSU_PNBUS_MODEL_REG; + + for(i=0;istatus &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + /* Get power good status */ + val=psu_status_info_get(index,"good"); + + if (val<0) { + AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + /* Get PSU type + */ + psu_type = get_psu_type(index); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + info->caps = ONLP_PSU_CAPS_AC; + ret = ONLP_STATUS_OK; + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + /* Get PSU vin,vout*/ + + r_data=psu_value_info_get(index,"vin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Vin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mvin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"vout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Vout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mvout=psu_data_convert_16(r_data,1000); + /* Get PSU iin, iout + */ + r_data=psu_value_info_get(index,"iin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Iin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->miin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"iout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Iout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->miout=psu_data_convert(r_data,1000); + + /* Get PSU pin, pout + */ + r_data=psu_value_info_get(index,"pin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Pin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mpin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"pout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Pout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mpout=psu_data_convert(r_data,1000); + /* Get PSU serial + */ + + ret=psu_serial_model_info_get(index,"serial",sn_data,14); + if (ret!=ONLP_STATUS_OK) { + AIM_LOG_INFO("Unable to read PSU %d SN value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + strcpy(info->serial,sn_data); + + /* Get PSU model + */ + ret=psu_serial_model_info_get(index,"model",model_data,16); + if (ret!=ONLP_STATUS_OK) { + AIM_LOG_INFO("Unable to read PSU %d model value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + strcpy(info->model,model_data); + + return ONLP_STATUS_OK; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c new file mode 100755 index 00000000..4764bbe9 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sfpi.c @@ -0,0 +1,364 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#include +#include "arm_delta_ag6248c_log.h" +#include "arm_delta_i2c.h" + +#define SFP_PRESENT_REG (0X14) +#define SFP_RX_LOS_REG (0X11) +#define SFP_TX_DISABLE_REG (0X17) +#define SFP_PRESENT_PORT47_BIT (0X40) +#define SFP_PRESENT_PORT48_BIT (0X80) +#define SFP_PRESENT_PORT47_OFFSET (0X06) +#define SFP_PRESENT_PORT48_OFFSET (0X07) + + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + int start_port, end_port; + + if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| + (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)) + { + start_port = 47; + end_port = 48; + } + else /*reserved*/ + { + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + for(p = start_port; p <=end_port; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present,r_data; + + if((port==47)||(port==48)) + r_data=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG); + else{ + AIM_LOG_ERROR("The port %d is invalid \r\n", port); + return ONLP_STATUS_E_UNSUPPORTED; + } + + if(r_data<0){ + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if(port==47){ + r_data&=SFP_PRESENT_PORT47_BIT; + present=!(r_data>>SFP_PRESENT_PORT47_OFFSET); + } + else{ + r_data&=SFP_PRESENT_PORT48_BIT; + present=!(r_data>>SFP_PRESENT_PORT48_OFFSET); + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int status; + int port, i = 0; + uint64_t presence_all=0; + + AIM_BITMAP_CLR_ALL(dst); + + if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \ + (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){ + + port=47; + + } + else{ + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + status=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG); + + if(status<0){ + AIM_LOG_ERROR("Unable to read the sfp_is_present_all value. \r\n"); + return ONLP_STATUS_E_INTERNAL; + } + status=~status; + + status>>=6; + + /* Convert to 64 bit integer in port order */ + + presence_all = status & 0x3; + + presence_all <<= port; + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int status; + int port,i = 0; + uint64_t rx_los_all = 0; + + AIM_BITMAP_CLR_ALL(dst); + + if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \ + (platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){ + + port=47; + + } + else{ + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + status=i2c_devname_read_byte("CPLD", SFP_RX_LOS_REG); + + if(status<0){ + AIM_LOG_ERROR("Unable to read the rx loss reg value. \r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + status>>=6; + + /* Convert to 64 bit integer in port order */ + rx_los_all = status & 0x3; + + rx_los_all <<= port; + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + + int i, r_data, re_cnt; + char* sfp_name; + + memset(data, 0, 256); + + if(port==47) + sfp_name="SFP1"; + else + sfp_name="SFP2"; + + + for(i=0;i<256;i++){ + re_cnt=3; + while(re_cnt){ + r_data=i2c_devname_read_byte(sfp_name,i); + if(r_data<0){ + re_cnt--; + continue; + } + data[i]=r_data; + break; + } + if(re_cnt==0){ + AIM_LOG_ERROR("Unable to read the %d reg \r\n",i); + return ONLP_STATUS_E_INTERNAL; + } + + } + + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + + return onlp_sfpi_eeprom_read( port, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + /*value is 1 if the tx disable + value is 0 if the tx enable + */ + + int rc,r_data,dis_value,present; + + present=onlp_sfpi_is_present(port); + + if(present==0){ + AIM_LOG_INFO("The port %d is not present and can not set tx disable\r\n",port); + return ONLP_STATUS_E_UNSUPPORTED; + } + + r_data=i2c_devname_read_byte("CPLD", SFP_TX_DISABLE_REG); + + if(r_data<0){ + AIM_LOG_INFO("Unable to read sfp tx disable reg value\r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + if(port==47){ + r_data&=~(0x1<>SFP_PRESENT_PORT47_OFFSET); + } + else{ + r_data&=(0x1<>SFP_PRESENT_PORT48_OFFSET); + } + + return ONLP_STATUS_OK; +} + + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c new file mode 100755 index 00000000..b8b0adec --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c @@ -0,0 +1,290 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "arm_delta_ag6248c_int.h" +#include "arm_delta_ag6248c_log.h" + +#include "platform_lib.h" +#include "arm_delta_i2c.h" +platform_id_t platform_id = PLATFORM_ID_UNKNOWN; + +#define ONIE_PLATFORM_NAME "arm-delta-ag6248c-r0" + +const char* +onlp_sysi_platform_get(void) +{ + enum ag6248c_product_id pid = get_product_id(); + + if (pid == PID_AG6248C_48) + return "arm-delta-ag6248c"; + else if(pid == PID_AG6248C_48P) + return "arm-delta-ag6248c-poe"; + else + return "unknow"; +} + +int +onlp_sysi_platform_set(const char* platform) +{ + if(strstr(platform,"arm-delta-ag6248c-r0")) { + platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_R0; + return ONLP_STATUS_OK; + } + if(strstr(platform,"arm-delta-ag6248c-poe-r0")) { + platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0; + return ONLP_STATUS_OK; + } + AIM_LOG_ERROR("No support for platform '%s'", platform); + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int v; + + v = i2c_devname_read_byte("CPLD", 0X07); + + pi->cpld_versions = aim_fstrdup("%d", v); + + return 0; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + int fd,rc_size; + char fullpath[20] = {0}; + + sprintf(fullpath, "/dev/mtd7"); + + fd=open(fullpath,O_RDWR); + + if(fd<0){ + aim_free(rdata); + return ONLP_STATUS_E_INTERNAL ; + } + + rc_size=read(fd,rdata,256); + + if(rc_size<0||rc_size!=256){ + aim_free(rdata); + return ONLP_STATUS_E_INTERNAL ; + } + + *data = rdata; + + return ONLP_STATUS_OK; + + +} + +void +onlp_sysi_onie_data_free(uint8_t* data) +{ + aim_free(data); +} + + + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 1 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* LEDs on the chassis */ + for (i = 1; i <= chassis_led_count(); i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 1 Fans on the chassis */ + for (i = 1; i <= chassis_fan_count(); i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_manage_fans(void) +{ + + int rc; + onlp_thermal_info_t ti1; + onlp_thermal_info_t ti2; + int mtemp=0; + int new_rpm=0; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* Get temperature */ + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + mtemp=(ti1.mcelsius+ti2.mcelsius)/2; + /* Bring fan speed according the temp + */ + if(mtemp<50000) + new_rpm=FAN_IDLE_RPM; + else if((mtemp>=55000)&&(mtemp<60000)) + new_rpm=FAN_LEVEL1_RPM; + else if((mtemp>=65000)&&(mtemp<70000)) + new_rpm=FAN_LEVEL2_RPM; + else if(mtemp>=75000) + new_rpm=FAN_LEVEL3_RPM; + else{ + return ONLP_STATUS_OK; + } + + onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); + onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); + + + return ONLP_STATUS_OK; +} + + +int +onlp_sysi_platform_manage_leds(void) +{ + int rc,rc1; + + onlp_fan_info_t info1,info2; + onlp_led_mode_t fan_new_mode; + onlp_thermal_info_t ti; + onlp_led_mode_t temp_new_mode; + onlp_psu_info_t psu1; + onlp_led_mode_t psu1_new_mode; + onlp_psu_info_t psu2; + onlp_led_mode_t psu2_new_mode; + onlp_led_mode_t sys_new_mode; + /*fan led */ + rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &info1); + + rc1=onlp_fani_info_get(ONLP_FAN_ID_CREATE(2), &info2); + + if ((rc != ONLP_STATUS_OK)||(rc1 != ONLP_STATUS_OK)){ + fan_new_mode=ONLP_LED_MODE_RED; + goto temp_led; + } + if(((info1.status&0x3)==1)&&((info2.status&0x3)==1)) + fan_new_mode=ONLP_LED_MODE_GREEN; + else + fan_new_mode=ONLP_LED_MODE_RED; + +temp_led: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode); + + /*temperature led */ + + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti); + if (rc != ONLP_STATUS_OK) { + temp_new_mode=ONLP_LED_MODE_OFF; + goto psu1_led; + } + if(ti.mcelsius >= 75000) + temp_new_mode=ONLP_LED_MODE_RED; + else + temp_new_mode=ONLP_LED_MODE_GREEN; + +psu1_led: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_TEMP),temp_new_mode); + + /*psu1 and psu2 led */ + rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(1),&psu1); + + if (rc != ONLP_STATUS_OK) { + psu1_new_mode=ONLP_LED_MODE_OFF; + goto psu2_led; + } + + if((psu1.status&0x1)&&!(psu1.status&0x2)) + psu1_new_mode=ONLP_LED_MODE_GREEN; + else + psu1_new_mode=ONLP_LED_MODE_OFF; +psu2_led: + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1),psu1_new_mode); + //psu2 led ---------------- + rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(2),&psu2); + + if (rc != ONLP_STATUS_OK) { + psu2_new_mode=ONLP_LED_MODE_OFF; + goto sys_led; + } + + if((psu2.status&0x1)&&!(psu2.status&0x2)) + psu2_new_mode=ONLP_LED_MODE_GREEN; + else + psu2_new_mode=ONLP_LED_MODE_OFF; +sys_led : + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2),psu2_new_mode); + //sys led ---------------- + + if((fan_new_mode!=ONLP_LED_MODE_GREEN)||((psu2_new_mode!=ONLP_LED_MODE_GREEN)&& \ + (psu1_new_mode!=ONLP_LED_MODE_GREEN))) + sys_new_mode=ONLP_LED_MODE_RED_BLINKING; + else + sys_new_mode=ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode); + + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c new file mode 100755 index 00000000..807855c9 --- /dev/null +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/thermali.c @@ -0,0 +1,208 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "arm_delta_ag6248c_log.h" +#include +#include "arm_delta_i2c.h" +#define prefix_path "/sys/bus/i2c/devices/" +#define LOCAL_DEBUG 0 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_1_CLOSE_TO_MAC, + THERMAL_2_CLOSE_TO_PHY, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* last_path[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "0-0049/temp1_input", + "0-004a/temp1_input", +}; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_MAC), "Thermal Sensor 1- close to mac", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_CLOSE_TO_PHY), "Thermal Sensor 2- close to phy", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; +static int +_onlp_psu_thermali_val_to_temperature (int v,int mult) +{ + long X, Y, N, n; + Y = v & 0x07FF; + N = (v >> 11) & 0x0f; + n = v & 0x8000 ? 1 : 0; + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = Y * mult * (N=(1<<(N&0xf))); + return X; +} +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +static int +_onlp_thermali_info_get(int id, onlp_thermal_info_t* info) +{ + int len, nbytes = 10, temp_base=1, local_id; + uint8_t r_data[10] = {0}; + char fullpath[50] = {0}; + + local_id = 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]); + + onlp_file_read(r_data,nbytes,&len, fullpath); + + info->mcelsius =ONLPLIB_ATOI((char*)r_data) / temp_base; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; +} + +static int +_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info) +{ + int psu_present,psu_good; + int psu_id,local_id; + int r_data,temperature_v; + enum ag6248c_product_id pid; + + local_id=id; + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + + psu_id=(local_id-THERMAL_1_ON_PSU1)+1; + pid=get_product_id(); + //if the psu is not, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + psu_good=psu_status_info_get(psu_id, "good"); + if((psu_present<=0)||(psu_good<=0)){ + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + //read the pus temperture register value + if(pid == PID_AG6248C_48){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); + } + else{ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x8d); + } + if(r_data<0) + return ONLP_STATUS_E_INVALID; + //get the real temperture value + temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000); + + info->mcelsius=temperature_v; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; + +} + +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rc; + int local_id; + + VALIDATE(id); + + local_id=ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if((local_id==THERMAL_1_CLOSE_TO_MAC) || (local_id==THERMAL_2_CLOSE_TO_PHY)) + rc= _onlp_thermali_info_get(local_id,info); + else if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2)) + rc=_onlp_thermali_psu_info_get(local_id,info); + else{ + rc=ONLP_STATUS_E_INVALID; + } + return rc; +} + + + diff --git a/packages/platforms/delta/armel/modules/Makefile b/packages/platforms/delta/armel/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/armel/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/armel/modules/PKG.yml b/packages/platforms/delta/armel/modules/PKG.yml new file mode 100644 index 00000000..e73b86da --- /dev/null +++ b/packages/platforms/delta/armel/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=armel VENDOR=delta From 7561bc6304dd48d1578b746d9b279acb283f0cf5 Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Sat, 24 Feb 2018 16:17:11 +0800 Subject: [PATCH 149/244] [wedge100BF_32x] Add support for wedge100 barefoot with 32 QSFP ports --- .../x86-64-accton-wedge100bf-32x/.gitignore | 3 + .../x86-64-accton-wedge100bf-32x/Makefile | 1 + .../modules/Makefile | 1 + .../modules/PKG.yml | 1 + .../onlp/Makefile | 1 + .../x86-64-accton-wedge100bf-32x/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++++ .../onlp/builds/onlpdump/Makefile | 46 ++++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../auto/x86_64_accton_wedge100bf_32x.yml | 50 ++++ .../x86_64_accton_wedge100bf_32x.x | 14 + .../x86_64_accton_wedge100bf_32x_config.h | 137 ++++++++++ .../x86_64_accton_wedge100bf_32x_dox.h | 26 ++ .../x86_64_accton_wedge100bf_32x_porting.h | 107 ++++++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 222 ++++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 220 +++++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 251 ++++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 69 +++++ .../onlp/builds/src/module/src/psui.c | 176 ++++++++++++ .../onlp/builds/src/module/src/sfpi.c | 216 +++++++++++++++ .../onlp/builds/src/module/src/sysi.c | 114 ++++++++ .../onlp/builds/src/module/src/thermali.c | 134 ++++++++++ .../src/x86_64_accton_wedge100bf_32x_config.c | 80 ++++++ .../src/x86_64_accton_wedge100bf_32x_enums.c | 10 + .../src/x86_64_accton_wedge100bf_32x_int.h | 12 + .../src/x86_64_accton_wedge100bf_32x_log.c | 18 ++ .../src/x86_64_accton_wedge100bf_32x_log.h | 12 + .../src/x86_64_accton_wedge100bf_32x_module.c | 24 ++ .../src/x86_64_accton_wedge100bf_32x_ucli.c | 50 ++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../lib/x86-64-accton-wedge100bf-32x-r0.yml | 35 +++ .../__init__.py | 23 ++ 41 files changed, 2157 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_32x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-32x-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/python/x86_64_accton_wedge100bf_32x_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/.gitignore new file mode 100644 index 00000000..a8d34d32 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*wedge100bf*32x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/PKG.yml new file mode 100644 index 00000000..f988a59d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100bf-32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/PKG.yml new file mode 100644 index 00000000..6faeb0e9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-wedge100bf-32x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/lib/Makefile new file mode 100644 index 00000000..6733959b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-wedge100bf-32x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_wedge100bf_32x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-wedge100bf-32x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..f828c871 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_wedge100bf_32x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/.module new file mode 100644 index 00000000..4b274b0e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_wedge100bf_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/Makefile new file mode 100644 index 00000000..3c409f10 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_wedge100bf_32x +AUTOMODULE := x86_64_accton_wedge100bf_32x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/README new file mode 100644 index 00000000..7907a7ae --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_wedge100bf_32x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..dd4268b7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_wedge100bf_32x Autogeneration +# +############################################################################### +x86_64_accton_wedge100bf_32x_AUTO_DEFS := module/auto/x86_64_accton_wedge100bf_32x.yml +x86_64_accton_wedge100bf_32x_AUTO_DIRS := module/inc/x86_64_accton_wedge100bf_32x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_32x.yml new file mode 100644 index 00000000..bc8b1570 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_32x.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# X86_64_ACCTON_WEDGE100BF_32X Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_WEDGE100BF_32X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_wedge100bf_32x_config + + portingmacro: + X86_64_ACCTON_WEDGE100BF_32X: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x.x b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x.x new file mode 100644 index 00000000..0f37b19c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_config.h new file mode 100644 index 00000000..0ec546a7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100bf_32x Configuration Header + * + * @addtogroup x86_64_accton_wedge100bf_32x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100BF_32X_CONFIG_H__ +#define __X86_64_ACCTON_WEDGE100BF_32X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_wedge100bf_32x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_wedge100bf_32x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_wedge100bf_32x_config_settings table. */ +extern x86_64_accton_wedge100bf_32x_config_settings_t x86_64_accton_wedge100bf_32x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_wedge100bf_32x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_wedge100bf_32x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_wedge100bf_32x_porting.h" + +#endif /* __X86_64_ACCTON_WEDGE100BF_32X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_dox.h new file mode 100644 index 00000000..557a549e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100bf_32x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100BF_32X_DOX_H__ +#define __X86_64_ACCTON_WEDGE100BF_32X_DOX_H__ + +/** + * @defgroup x86_64_accton_wedge100bf_32x x86_64_accton_wedge100bf_32x - x86_64_accton_wedge100bf_32x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_wedge100bf_32x-x86_64_accton_wedge100bf_32x Public Interface + * @defgroup x86_64_accton_wedge100bf_32x-config Compile Time Configuration + * @defgroup x86_64_accton_wedge100bf_32x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_WEDGE100BF_32X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_porting.h new file mode 100644 index 00000000..d322dd38 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_32x/x86_64_accton_wedge100bf_32x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100bf_32x Porting Macros. + * + * @addtogroup x86_64_accton_wedge100bf_32x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100BF_32X_PORTING_H__ +#define __X86_64_ACCTON_WEDGE100BF_32X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_wedge100bf_32x_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_wedge100bf_32x_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_MALLOC malloc + #else + #error The macro x86_64_accton_wedge100bf_32x_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_wedge100bf_32x_FREE GLOBAL_FREE + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_FREE free + #else + #error The macro x86_64_accton_wedge100bf_32x_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_wedge100bf_32x_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_MEMSET memset + #else + #error The macro x86_64_accton_wedge100bf_32x_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_wedge100bf_32x_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_MEMCPY memcpy + #else + #error The macro x86_64_accton_wedge100bf_32x_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_wedge100bf_32x_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_STRNCPY strncpy + #else + #error The macro x86_64_accton_wedge100bf_32x_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_wedge100bf_32x_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_wedge100bf_32x_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_wedge100bf_32x_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_SNPRINTF snprintf + #else + #error The macro x86_64_accton_wedge100bf_32x_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_32x_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_wedge100bf_32x_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_32x_STRLEN strlen + #else + #error The macro x86_64_accton_wedge100bf_32x_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_WEDGE100BF_32X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..1dd41682 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_wedge100bf_32x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_wedge100bf_32x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_wedge100bf_32x_DEPENDMODULE_ENTRIES := init:x86_64_accton_wedge100bf_32x ucli:x86_64_accton_wedge100bf_32x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..83d4081a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_wedge100bf_32x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..3775723f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/fani.c @@ -0,0 +1,222 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define MAX_FAN_SPEED 15400 +#define BIT(i) (1 << (i)) + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, +}; + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/8-0033/" + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5) +}; + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int value = 0, fid; + char path[64] = {0}; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + /* get fan present status + */ + sprintf(path, "%s""fantray_present", FAN_BOARD_PATH); + + if (bmc_file_read_int(&value, path, 16) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value & BIT(fid-1)) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get front fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2 - 1); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + + /* set fan status based on rpm + */ + if (!info->rpm) { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + /* set fan direction + */ + info->status |= ONLP_FAN_STATUS_F2B; + + return ONLP_STATUS_OK; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + char cmd[32] = {0}; + + sprintf(cmd, "set_fan_speed.sh %d", p); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..c04342a2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,220 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS1, + LED_SYS2 +}; + +typedef struct led_address_s { + enum onlp_led_id id; + uint8_t bus; + uint8_t devaddr; + uint8_t offset; +} led_address_t; + +typedef struct led_mode_info_s { + onlp_led_mode_t mode; + uint8_t regval; +} led_mode_info_t; + +static led_address_t led_addr[] = +{ + { }, /* Not used */ + {LED_SYS1, 1, 0x32, 0x3e}, + {LED_SYS2, 1, 0x32, 0x3f}, +}; + +static led_mode_info_t led_mode_info[] = +{ + {ONLP_LED_MODE_OFF, 0x0}, + {ONLP_LED_MODE_OFF, 0x8}, + {ONLP_LED_MODE_RED, 0x1}, + {ONLP_LED_MODE_RED_BLINKING, 0x9}, + {ONLP_LED_MODE_GREEN, 0x2}, + {ONLP_LED_MODE_GREEN_BLINKING, 0xa}, + {ONLP_LED_MODE_BLUE, 0x4}, + {ONLP_LED_MODE_BLUE_BLINKING, 0xc}, +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS1), "Chassis LED 1 (SYS LED 1)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_SYS2), "Chassis LED 1 (SYS LED 2)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, +}; + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +reg_value_to_onlp_led_mode(enum onlp_led_id id, int value) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (value != led_mode_info[i].regval) { + continue; + } + + return led_mode_info[i].mode; + } + + return ONLP_LED_MODE_AUTO; +} + +static int +onlp_led_mode_to_reg_value(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (onlp_led_mode != led_mode_info[i].mode) { + continue; + } + + return led_mode_info[i].regval; + } + + return 0; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + value = onlp_i2c_readb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = reg_value_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + value = onlp_led_mode_to_reg_value(lid, mode); + if (onlp_i2c_writeb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, value, ONLP_I2C_F_FORCE) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..2029f0b0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_wedge100bf_32x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..1d374e75 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,251 @@ +/************************************************************ + * + * + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define TTY_DEVICE "/dev/ttyACM0" +#define TTY_PROMPT "@bmc:" +#define TTY_I2C_TIMEOUT 800000 +#define TTY_BMC_LOGIN_TIMEOUT 1000000 +#define TTY_RETRY 10 +#define MAXIMUM_TTY_BUFFER_LENGTH 1024 +#define MAXIMUM_TTY_STRING_LENGTH (MAXIMUM_TTY_BUFFER_LENGTH - 1) + +static int tty_fd = -1; +static char tty_buf[MAXIMUM_TTY_BUFFER_LENGTH] = {0}; + +static int tty_open(void) +{ + int i = 20; + struct termios attr; + + if (tty_fd > -1) { + return 0; + } + + do { + if ((tty_fd = open(TTY_DEVICE, O_RDWR | O_NOCTTY | O_NDELAY)) > -1) { + tcgetattr(tty_fd, &attr); + attr.c_cflag = B57600 | CS8 | CLOCAL | CREAD; + attr.c_iflag = IGNPAR; + attr.c_oflag = 0; + attr.c_lflag = 0; + attr.c_cc[VMIN] = (unsigned char) + ((MAXIMUM_TTY_STRING_LENGTH > 0xFF) ? 0xFF : MAXIMUM_TTY_STRING_LENGTH); + attr.c_cc[VTIME] = 0; + cfsetospeed(&attr, B57600); + cfsetispeed(&attr, B57600); + tcsetattr(tty_fd, TCSANOW, &attr); + return 0; + } + + i--; + usleep(100000); + } while (i > 0); + + return -1; +} + +static int tty_close(void) +{ + close(tty_fd); + tty_fd = -1; + return 0; +} + +static int tty_exec_buf(unsigned long udelay, const char *str) +{ + if (tty_fd < 0) + return -1; + + write(tty_fd, tty_buf, strlen(tty_buf)+1); + usleep(udelay); + read(tty_fd, tty_buf, MAXIMUM_TTY_BUFFER_LENGTH); + return (strstr(tty_buf, str) != NULL) ? 0 : -1; +} + +static int tty_login(void) +{ + int i = 10; + + for (i = 1; i <= TTY_RETRY; i++) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "\r\r"); + if (!tty_exec_buf(0, TTY_PROMPT)) { + return 0; + } + + if (strstr(tty_buf, "bmc login:") != NULL) + { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "root\r"); + + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, "Password:")) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "0penBmc\r"); + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, TTY_PROMPT)) { + return 0; + } + + } + } + usleep(50000); + } + + return -1; +} + +int bmc_send_command(char *cmd) +{ + int i, ret = 0; + + for (i = 1; i <= TTY_RETRY; i++) { + if (tty_open() != 0) { + printf("ERROR: Cannot open TTY device\n"); + continue; + } + if (tty_login() != 0) { + //printf("ERROR: Cannot login TTY device\n"); + tty_close(); + continue; + } + + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "%s", cmd); + ret = tty_exec_buf(TTY_I2C_TIMEOUT * i, TTY_PROMPT); + tty_close(); + if (ret != 0) { + printf("ERROR: bmc_send_command timed out\n"); + continue; + } + + return 0; + } + + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return -1; +} + +int +bmc_command_read_int(int* value, char *cmd, int base) +{ + int len; + int i; + char *prev_str = NULL; + char *current_str= NULL; + if (bmc_send_command(cmd) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + len = (int)strlen(cmd); + prev_str = strstr(tty_buf, cmd); + if (prev_str == NULL) { + return -1; + } + for (i = 1; i <= TTY_RETRY; i++) { + current_str = strstr(prev_str + len, cmd); + if(current_str == NULL) { + *value = strtoul(prev_str + len, NULL, base); + break; + }else { + prev_str = current_str; + continue; + } + } + return 0; +} + + +int +bmc_file_read_int(int* value, char *file, int base) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "cat %s\r\n", file); + return bmc_command_read_int(value, cmd, base); +} + +int +bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "i2cset -f -y %d 0x%x 0x%02x 0x%x\r\n", bus, devaddr, addr, value); + return bmc_send_command(cmd); +} + +int +bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x w\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size) +{ + int data_len, i = 0; + char cmd[64] = {0}; + char *str = NULL; + snprintf(cmd, sizeof(cmd), "i2craw -w 0x%x -r 0 %d 0x%02x\r\n", addr, bus, devaddr); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + str = strstr(tty_buf, "Received:\r\n "); + if (str == NULL) { + return -1; + } + + /* first byte is data length */ + str += strlen("Received:\r\n ");; + data_len = strtoul(str, NULL, 16); + if (data_size < data_len) { + data_len = data_size; + } + + for (i = 0; (i < data_len) && (str != NULL); i++) { + str = strstr(str, " ") + 1; /* Jump to next token */ + data[i] = strtoul(str, NULL, 16); + } + + data[i] = 0; + return 0; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..ee600282 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,69 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_wedge100bf_32x_log.h" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define CHASSIS_FAN_COUNT 5 +#define CHASSIS_THERMAL_COUNT 8 +#define CHASSIS_LED_COUNT 2 +#define CHASSIS_PSU_COUNT 2 + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-40/40-0050/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_6_ON_MAIN_BROAD, + THERMAL_7_ON_MAIN_BROAD, +}; + +int bmc_send_command(char *cmd); +int bmc_file_read_int(int* value, char *file, int base); +int bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value); +int bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size); + +#endif /* __PLATFORM_LIB_H__ */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..4d321457 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/psui.c @@ -0,0 +1,176 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define PSU1_ID 1 +#define PSU2_ID 2 + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +twos_complement_to_int(uint16_t data, uint8_t valid_bit, int mask) +{ + uint16_t valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static int +pmbus_parse_literal_format(uint16_t value) +{ + int exponent, mantissa, multiplier = 1000; + + exponent = twos_complement_to_int(value >> 11, 5, 0x1f); + mantissa = twos_complement_to_int(value & 0x7ff, 11, 0x7ff); + + return (exponent >= 0) ? (mantissa << exponent) * multiplier : + (mantissa * multiplier) / (1 << -exponent); +} + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int pid, value, addr; + + uint8_t mask = 0; + + VALIDATE(id); + + pid = ONLP_OID_ID_GET(id); + *info = pinfo[pid]; /* Set the onlp_oid_hdr_t */ + + /* Get the present status + */ + mask = 1 << ((pid-1) * 4); + value = onlp_i2c_readb(1, 0x32, 0x10, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value & mask) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + info->caps = ONLP_PSU_CAPS_AC; + + /* Get power good status + */ + mask = 1 << ((pid-1) * 4 + 1); + if (!(value & mask)) { + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* Get input output power status + */ + value = (pid == PSU1_ID) ? 0x2 : 0x1; /* mux channel for psu */ + if (bmc_i2c_writeb(7, 0x70, 0, value) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* Read vin */ + addr = (pid == PSU1_ID) ? 0x59 : 0x5a; + value = bmc_i2c_readw(7, addr, 0x88); + if (value >= 0) { + info->mvin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_VIN; + } + + /* Read iin */ + value = bmc_i2c_readw(7, addr, 0x89); + if (value >= 0) { + info->miin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IIN; + } + + /* Get pin */ + if ((info->caps & ONLP_PSU_CAPS_VIN) && (info->caps & ONLP_PSU_CAPS_IIN)) { + info->mpin = info->mvin * info->miin / 1000; + info->caps |= ONLP_PSU_CAPS_PIN; + } + + /* Read iout */ + value = bmc_i2c_readw(7, addr, 0x8c); + if (value >= 0) { + info->miout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Read pout */ + value = bmc_i2c_readw(7, addr, 0x96); + if (value >= 0) { + info->mpout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_POUT; + } + + /* Get vout */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_POUT) && info->miout != 0) { + info->mvout = info->mpout / info->miout * 1000; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get model name */ + return bmc_i2c_readraw(7, addr, 0x9a, info->model, sizeof(info->model)); +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..20fa4873 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,216 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100bf_32x_log.h" + +#define BIT(i) (1 << (i)) +#define NUM_OF_SFP_PORT 32 +static const int sfp_bus_index[] = { + 3, 2, 5, 4, 7, 6, 9, 8, + 11, 10, 13, 12, 15, 14, 17, 16, + 19, 18, 21, 20, 23, 22, 25, 24, + 27, 26, 29, 28, 31, 30, 33, 32 +}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +static uint8_t +onlp_sfpi_reg_val_to_port_sequence(uint8_t value, int revert) +{ + int i; + uint8_t ret = 0; + + for (i = 0; i < 8; i++) { + if (i % 2) { + ret |= (value & BIT(i)) >> 1; + } + else { + ret |= (value & BIT(i)) << 1; + } + } + + return revert ? ~ret : ret; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus = (port < 16) ? 36 : 37; + int addr = (port < 16) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset; + + if (port < 8 || (port >= 16 && port <= 23)) { + offset = 0; + } + else { + offset = 1; + } + + present = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (present < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + present = onlp_sfpi_reg_val_to_port_sequence(present, 0); + return !(present & BIT(port % 8)); +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int i; + uint8_t bytes[4] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(bytes); i++) { + int bus = (i < 2) ? 36 : 37; + int addr = (i < 2) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset = (i % 2); + + bytes[i] = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (bytes[i] < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + bytes[i] = onlp_sfpi_reg_val_to_port_sequence(bytes[i], 1); + } + + /* Convert to 32 bit integer in port order */ + i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_OK; +} + +static int +sfpi_eeprom_read(int port, uint8_t devaddr, uint8_t data[256]) +{ + int i; + + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + memset(data, 0, 256); + + for (i = 0; i < 128; i++) { + int bus = sfp_bus_index[port]; + int val = onlp_i2c_readw(bus, devaddr, i*2, ONLP_I2C_F_FORCE); + + if (val < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + data[i] = val & 0xff; + data[i+1] = (val >> 8) & 0xff; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x50, data); +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x51, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..8d19ba0f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,114 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100bf_32x_int.h" +#include "x86_64_accton_wedge100bf_32x_log.h" + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-wedge100bf-32x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 8 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 2 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 5 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ +} + +int +onlp_sysi_platform_manage_fans(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..f6f67cbe --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,134 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/drivers/lm75/%s/temp1_input" +#define THERMAL_CPU_CORE_PATH_FORMAT "/sys/bus/i2c/drivers/com_e_driver/%s/temp2_input" + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + "4-0033", /* CPU_CORE files */ + "3-0048", + "3-0049", + "3-004a", + "3-004b", + "3-004c", + "8-0048", + "8-0049", +}; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "TMP75-1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "TMP75-2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "TMP75-3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "TMP75-4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "TMP75-5", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "TMP75-6", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_7_ON_MAIN_BROAD), "TMP75-7", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + /* get path */ + if (THERMAL_CPU_CORE == tid) { + sprintf(path, THERMAL_CPU_CORE_PATH_FORMAT, directory[tid]); + }else { + sprintf(path, THERMAL_PATH_FORMAT, directory[tid]); + } + + if (bmc_file_read_int(&info->mcelsius, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_config.c new file mode 100644 index 00000000..41d7965b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(_x) +x86_64_accton_wedge100bf_32x_config_settings_t x86_64_accton_wedge100bf_32x_config_settings[] = +{ +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_WEDGE100BF_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_wedge100bf_32x_config_STRINGIFY_VALUE +#undef __x86_64_accton_wedge100bf_32x_config_STRINGIFY_NAME + +const char* +x86_64_accton_wedge100bf_32x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_wedge100bf_32x_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_wedge100bf_32x_config_settings[i].name, setting)) { + return x86_64_accton_wedge100bf_32x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_wedge100bf_32x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_wedge100bf_32x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_wedge100bf_32x_config_settings[i].name, x86_64_accton_wedge100bf_32x_config_settings[i].value); + } + return i; +} + +/* */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_enums.c new file mode 100644 index 00000000..b5dfc66d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_int.h new file mode 100644 index 00000000..7ac6cd83 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100bf_32x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_wedge100bf_32x_INT_H__ +#define __x86_64_accton_wedge100bf_32x_INT_H__ + +#include + + +#endif /* __x86_64_accton_wedge100bf_32x_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.c new file mode 100644 index 00000000..2f710325 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100bf_32x_log.h" +/* + * x86_64_accton_wedge100bf_32x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_WEDGE100BF_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.h new file mode 100644 index 00000000..8b2dc637 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_wedge100bf_32x_LOG_H__ +#define __x86_64_accton_wedge100bf_32x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_wedge100bf_32x +#include + +#endif /* __x86_64_accton_wedge100bf_32x_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_module.c new file mode 100644 index 00000000..da3fffac --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100bf_32x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_wedge100bf_32x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_wedge100bf_32x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_ucli.c new file mode 100644 index 00000000..ea6eb7de --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_32x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_wedge100bf_32x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_wedge100bf_32x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_wedge100bf_32x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_wedge100bf_32x_ucli_module__ = + { + "x86_64_accton_wedge100bf_32x_ucli", + NULL, + x86_64_accton_wedge100bf_32x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_wedge100bf_32x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_wedge100bf_32x_ucli_module__); + n = ucli_node_create("x86_64_accton_wedge100bf_32x", NULL, &x86_64_accton_wedge100bf_32x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_wedge100bf_32x")); + return n; +} + +#else +void* +x86_64_accton_wedge100bf_32x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/PKG.yml new file mode 100644 index 00000000..76ee333a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100bf-32x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-32x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-32x-r0.yml new file mode 100644 index 00000000..bf57f795 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-32x-r0.yml @@ -0,0 +1,35 @@ +--- + +###################################################################### +# +# platform-config for WEDGE +# +###################################################################### + +x86-64-accton-wedge100bf-32x-r0: + + grub: + + serial: >- + --unit=0 + --speed=57600 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,57600n8 + rd_NO_MD + rd_NO_LUKS + intel_iommu=off + noapic + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/python/x86_64_accton_wedge100bf_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/python/x86_64_accton_wedge100bf_32x_r0/__init__.py new file mode 100644 index 00000000..374dcd50 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-32x/platform-config/r0/src/python/x86_64_accton_wedge100bf_32x_r0/__init__.py @@ -0,0 +1,23 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_wedge100bf_32x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_32x100): + MODEL="Wedge-100bf-32X" + PLATFORM="x86-64-accton-wedge100bf-32x-r0" + SYS_OBJECT_ID=".100.32.2" + + def baseconfig(self): + ########### initialize I2C bus 1 ########### + self.new_i2c_devices([ + # initialize multiplexer (PCA9548) + ('pca9548', 0x70, 1), + ('pca9548', 0x71, 1), + ('pca9548', 0x72, 1), + ('pca9548', 0x73, 1), + ('pca9548', 0x74, 1), + + ('24c64', 0x50, 40), + ]) + + return True From 7ff32c9eb6582d2b150117573318a5c5ce802a81 Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Sat, 24 Feb 2018 16:38:15 +0800 Subject: [PATCH 150/244] [wedge100BF_65x] Add support for wedge100 barefoot with 65 network ports --- .../x86-64-accton-wedge100bf-65x/.gitignore | 3 + .../x86-64-accton-wedge100bf-65x/Makefile | 1 + .../modules/Makefile | 1 + .../modules/PKG.yml | 1 + .../onlp/Makefile | 1 + .../x86-64-accton-wedge100bf-65x/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++++ .../onlp/builds/onlpdump/Makefile | 46 ++++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../auto/x86_64_accton_wedge100bf_65x.yml | 50 ++++ .../x86_64_accton_wedge100bf_65x.x | 14 + .../x86_64_accton_wedge100bf_65x_config.h | 137 ++++++++++ .../x86_64_accton_wedge100bf_65x_dox.h | 26 ++ .../x86_64_accton_wedge100bf_65x_porting.h | 107 ++++++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 222 +++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 220 +++++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 251 +++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 69 +++++ .../onlp/builds/src/module/src/psui.c | 176 ++++++++++++ .../onlp/builds/src/module/src/sfpi.c | 253 ++++++++++++++++++ .../onlp/builds/src/module/src/sysi.c | 114 ++++++++ .../onlp/builds/src/module/src/thermali.c | 134 ++++++++++ .../src/x86_64_accton_wedge100bf_65x_config.c | 80 ++++++ .../src/x86_64_accton_wedge100bf_65x_enums.c | 10 + .../src/x86_64_accton_wedge100bf_65x_int.h | 12 + .../src/x86_64_accton_wedge100bf_65x_log.c | 18 ++ .../src/x86_64_accton_wedge100bf_65x_log.h | 12 + .../src/x86_64_accton_wedge100bf_65x_module.c | 24 ++ .../src/x86_64_accton_wedge100bf_65x_ucli.c | 50 ++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../lib/x86-64-accton-wedge100bf-65x-r0.yml | 35 +++ .../__init__.py | 31 +++ 41 files changed, 2202 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_65x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-65x-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/python/x86_64_accton_wedge100bf_65x_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/.gitignore new file mode 100644 index 00000000..0853a426 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*wedge100bf*65x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/PKG.yml new file mode 100644 index 00000000..1f614ff6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100bf-65x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/PKG.yml new file mode 100644 index 00000000..d67268ea --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-wedge100bf-65x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/lib/Makefile new file mode 100644 index 00000000..486d83c1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-wedge100bf-65x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_wedge100bf_65x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-wedge100bf-65x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..4cc10ffb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_wedge100bf_65x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/.module new file mode 100644 index 00000000..5713722f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_wedge100bf_65x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/Makefile new file mode 100644 index 00000000..74fd9b35 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_wedge100bf_65x +AUTOMODULE := x86_64_accton_wedge100bf_65x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/README new file mode 100644 index 00000000..a5e38abf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_wedge100bf_65x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..ede2b0ed --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_wedge100bf_65x Autogeneration +# +############################################################################### +x86_64_accton_wedge100bf_65x_AUTO_DEFS := module/auto/x86_64_accton_wedge100bf_65x.yml +x86_64_accton_wedge100bf_65x_AUTO_DIRS := module/inc/x86_64_accton_wedge100bf_65x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_65x.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_65x.yml new file mode 100644 index 00000000..e62f68c5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/auto/x86_64_accton_wedge100bf_65x.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# X86_64_ACCTON_WEDGE100BF_65X Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_WEDGE100BF_65X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_wedge100bf_65x_config + + portingmacro: + X86_64_ACCTON_WEDGE100BF_65X: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x.x b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x.x new file mode 100644 index 00000000..c17d7eec --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_config.h new file mode 100644 index 00000000..1725b533 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100bf_65x Configuration Header + * + * @addtogroup x86_64_accton_wedge100bf_65x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100BF_65X_CONFIG_H__ +#define __X86_64_ACCTON_WEDGE100BF_65X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_wedge100bf_65x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_wedge100bf_65x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_wedge100bf_65x_config_settings table. */ +extern x86_64_accton_wedge100bf_65x_config_settings_t x86_64_accton_wedge100bf_65x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_wedge100bf_65x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_wedge100bf_65x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_wedge100bf_65x_porting.h" + +#endif /* __X86_64_ACCTON_WEDGE100BF_65X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_dox.h new file mode 100644 index 00000000..02c2343e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100bf_65x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100BF_65X_DOX_H__ +#define __X86_64_ACCTON_WEDGE100BF_65X_DOX_H__ + +/** + * @defgroup x86_64_accton_wedge100bf_65x x86_64_accton_wedge100bf_65x - x86_64_accton_wedge100bf_65x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_wedge100bf_65x-x86_64_accton_wedge100bf_65x Public Interface + * @defgroup x86_64_accton_wedge100bf_65x-config Compile Time Configuration + * @defgroup x86_64_accton_wedge100bf_65x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_WEDGE100BF_65X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_porting.h new file mode 100644 index 00000000..2a58754a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/inc/x86_64_accton_wedge100bf_65x/x86_64_accton_wedge100bf_65x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100bf_65x Porting Macros. + * + * @addtogroup x86_64_accton_wedge100bf_65x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100BF_65X_PORTING_H__ +#define __X86_64_ACCTON_WEDGE100BF_65X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_wedge100bf_65x_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_wedge100bf_65x_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_MALLOC malloc + #else + #error The macro x86_64_accton_wedge100bf_65x_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_wedge100bf_65x_FREE GLOBAL_FREE + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_FREE free + #else + #error The macro x86_64_accton_wedge100bf_65x_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_wedge100bf_65x_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_MEMSET memset + #else + #error The macro x86_64_accton_wedge100bf_65x_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_wedge100bf_65x_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_MEMCPY memcpy + #else + #error The macro x86_64_accton_wedge100bf_65x_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_wedge100bf_65x_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_STRNCPY strncpy + #else + #error The macro x86_64_accton_wedge100bf_65x_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_wedge100bf_65x_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_wedge100bf_65x_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_wedge100bf_65x_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_SNPRINTF snprintf + #else + #error The macro x86_64_accton_wedge100bf_65x_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_wedge100bf_65x_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_wedge100bf_65x_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_wedge100bf_65x_STRLEN strlen + #else + #error The macro x86_64_accton_wedge100bf_65x_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_WEDGE100BF_65X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..b95bfa95 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_wedge100bf_65x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_wedge100bf_65x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_wedge100bf_65x_DEPENDMODULE_ENTRIES := init:x86_64_accton_wedge100bf_65x ucli:x86_64_accton_wedge100bf_65x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..1e8f6986 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_wedge100bf_65x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..3775723f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/fani.c @@ -0,0 +1,222 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define MAX_FAN_SPEED 15400 +#define BIT(i) (1 << (i)) + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, +}; + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/8-0033/" + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5) +}; + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int value = 0, fid; + char path[64] = {0}; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + /* get fan present status + */ + sprintf(path, "%s""fantray_present", FAN_BOARD_PATH); + + if (bmc_file_read_int(&value, path, 16) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value & BIT(fid-1)) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get front fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2 - 1); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + + /* set fan status based on rpm + */ + if (!info->rpm) { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + /* set fan direction + */ + info->status |= ONLP_FAN_STATUS_F2B; + + return ONLP_STATUS_OK; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + char cmd[32] = {0}; + + sprintf(cmd, "set_fan_speed.sh %d", p); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..c04342a2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,220 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS1, + LED_SYS2 +}; + +typedef struct led_address_s { + enum onlp_led_id id; + uint8_t bus; + uint8_t devaddr; + uint8_t offset; +} led_address_t; + +typedef struct led_mode_info_s { + onlp_led_mode_t mode; + uint8_t regval; +} led_mode_info_t; + +static led_address_t led_addr[] = +{ + { }, /* Not used */ + {LED_SYS1, 1, 0x32, 0x3e}, + {LED_SYS2, 1, 0x32, 0x3f}, +}; + +static led_mode_info_t led_mode_info[] = +{ + {ONLP_LED_MODE_OFF, 0x0}, + {ONLP_LED_MODE_OFF, 0x8}, + {ONLP_LED_MODE_RED, 0x1}, + {ONLP_LED_MODE_RED_BLINKING, 0x9}, + {ONLP_LED_MODE_GREEN, 0x2}, + {ONLP_LED_MODE_GREEN_BLINKING, 0xa}, + {ONLP_LED_MODE_BLUE, 0x4}, + {ONLP_LED_MODE_BLUE_BLINKING, 0xc}, +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS1), "Chassis LED 1 (SYS LED 1)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_SYS2), "Chassis LED 1 (SYS LED 2)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, +}; + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +reg_value_to_onlp_led_mode(enum onlp_led_id id, int value) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (value != led_mode_info[i].regval) { + continue; + } + + return led_mode_info[i].mode; + } + + return ONLP_LED_MODE_AUTO; +} + +static int +onlp_led_mode_to_reg_value(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (onlp_led_mode != led_mode_info[i].mode) { + continue; + } + + return led_mode_info[i].regval; + } + + return 0; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + value = onlp_i2c_readb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = reg_value_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + value = onlp_led_mode_to_reg_value(lid, mode); + if (onlp_i2c_writeb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, value, ONLP_I2C_F_FORCE) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..b63ffb14 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_wedge100bf_65x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..1d374e75 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,251 @@ +/************************************************************ + * + * + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define TTY_DEVICE "/dev/ttyACM0" +#define TTY_PROMPT "@bmc:" +#define TTY_I2C_TIMEOUT 800000 +#define TTY_BMC_LOGIN_TIMEOUT 1000000 +#define TTY_RETRY 10 +#define MAXIMUM_TTY_BUFFER_LENGTH 1024 +#define MAXIMUM_TTY_STRING_LENGTH (MAXIMUM_TTY_BUFFER_LENGTH - 1) + +static int tty_fd = -1; +static char tty_buf[MAXIMUM_TTY_BUFFER_LENGTH] = {0}; + +static int tty_open(void) +{ + int i = 20; + struct termios attr; + + if (tty_fd > -1) { + return 0; + } + + do { + if ((tty_fd = open(TTY_DEVICE, O_RDWR | O_NOCTTY | O_NDELAY)) > -1) { + tcgetattr(tty_fd, &attr); + attr.c_cflag = B57600 | CS8 | CLOCAL | CREAD; + attr.c_iflag = IGNPAR; + attr.c_oflag = 0; + attr.c_lflag = 0; + attr.c_cc[VMIN] = (unsigned char) + ((MAXIMUM_TTY_STRING_LENGTH > 0xFF) ? 0xFF : MAXIMUM_TTY_STRING_LENGTH); + attr.c_cc[VTIME] = 0; + cfsetospeed(&attr, B57600); + cfsetispeed(&attr, B57600); + tcsetattr(tty_fd, TCSANOW, &attr); + return 0; + } + + i--; + usleep(100000); + } while (i > 0); + + return -1; +} + +static int tty_close(void) +{ + close(tty_fd); + tty_fd = -1; + return 0; +} + +static int tty_exec_buf(unsigned long udelay, const char *str) +{ + if (tty_fd < 0) + return -1; + + write(tty_fd, tty_buf, strlen(tty_buf)+1); + usleep(udelay); + read(tty_fd, tty_buf, MAXIMUM_TTY_BUFFER_LENGTH); + return (strstr(tty_buf, str) != NULL) ? 0 : -1; +} + +static int tty_login(void) +{ + int i = 10; + + for (i = 1; i <= TTY_RETRY; i++) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "\r\r"); + if (!tty_exec_buf(0, TTY_PROMPT)) { + return 0; + } + + if (strstr(tty_buf, "bmc login:") != NULL) + { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "root\r"); + + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, "Password:")) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "0penBmc\r"); + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, TTY_PROMPT)) { + return 0; + } + + } + } + usleep(50000); + } + + return -1; +} + +int bmc_send_command(char *cmd) +{ + int i, ret = 0; + + for (i = 1; i <= TTY_RETRY; i++) { + if (tty_open() != 0) { + printf("ERROR: Cannot open TTY device\n"); + continue; + } + if (tty_login() != 0) { + //printf("ERROR: Cannot login TTY device\n"); + tty_close(); + continue; + } + + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "%s", cmd); + ret = tty_exec_buf(TTY_I2C_TIMEOUT * i, TTY_PROMPT); + tty_close(); + if (ret != 0) { + printf("ERROR: bmc_send_command timed out\n"); + continue; + } + + return 0; + } + + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return -1; +} + +int +bmc_command_read_int(int* value, char *cmd, int base) +{ + int len; + int i; + char *prev_str = NULL; + char *current_str= NULL; + if (bmc_send_command(cmd) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + len = (int)strlen(cmd); + prev_str = strstr(tty_buf, cmd); + if (prev_str == NULL) { + return -1; + } + for (i = 1; i <= TTY_RETRY; i++) { + current_str = strstr(prev_str + len, cmd); + if(current_str == NULL) { + *value = strtoul(prev_str + len, NULL, base); + break; + }else { + prev_str = current_str; + continue; + } + } + return 0; +} + + +int +bmc_file_read_int(int* value, char *file, int base) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "cat %s\r\n", file); + return bmc_command_read_int(value, cmd, base); +} + +int +bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "i2cset -f -y %d 0x%x 0x%02x 0x%x\r\n", bus, devaddr, addr, value); + return bmc_send_command(cmd); +} + +int +bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x w\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size) +{ + int data_len, i = 0; + char cmd[64] = {0}; + char *str = NULL; + snprintf(cmd, sizeof(cmd), "i2craw -w 0x%x -r 0 %d 0x%02x\r\n", addr, bus, devaddr); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + str = strstr(tty_buf, "Received:\r\n "); + if (str == NULL) { + return -1; + } + + /* first byte is data length */ + str += strlen("Received:\r\n ");; + data_len = strtoul(str, NULL, 16); + if (data_size < data_len) { + data_len = data_size; + } + + for (i = 0; (i < data_len) && (str != NULL); i++) { + str = strstr(str, " ") + 1; /* Jump to next token */ + data[i] = strtoul(str, NULL, 16); + } + + data[i] = 0; + return 0; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..790978a2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,69 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_wedge100bf_65x_log.h" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define CHASSIS_FAN_COUNT 5 +#define CHASSIS_THERMAL_COUNT 8 +#define CHASSIS_LED_COUNT 2 +#define CHASSIS_PSU_COUNT 2 + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-41/41-0050/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_6_ON_MAIN_BROAD, + THERMAL_7_ON_MAIN_BROAD, +}; + +int bmc_send_command(char *cmd); +int bmc_file_read_int(int* value, char *file, int base); +int bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value); +int bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size); + +#endif /* __PLATFORM_LIB_H__ */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..4d321457 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/psui.c @@ -0,0 +1,176 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define PSU1_ID 1 +#define PSU2_ID 2 + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +twos_complement_to_int(uint16_t data, uint8_t valid_bit, int mask) +{ + uint16_t valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static int +pmbus_parse_literal_format(uint16_t value) +{ + int exponent, mantissa, multiplier = 1000; + + exponent = twos_complement_to_int(value >> 11, 5, 0x1f); + mantissa = twos_complement_to_int(value & 0x7ff, 11, 0x7ff); + + return (exponent >= 0) ? (mantissa << exponent) * multiplier : + (mantissa * multiplier) / (1 << -exponent); +} + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int pid, value, addr; + + uint8_t mask = 0; + + VALIDATE(id); + + pid = ONLP_OID_ID_GET(id); + *info = pinfo[pid]; /* Set the onlp_oid_hdr_t */ + + /* Get the present status + */ + mask = 1 << ((pid-1) * 4); + value = onlp_i2c_readb(1, 0x32, 0x10, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value & mask) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + info->caps = ONLP_PSU_CAPS_AC; + + /* Get power good status + */ + mask = 1 << ((pid-1) * 4 + 1); + if (!(value & mask)) { + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* Get input output power status + */ + value = (pid == PSU1_ID) ? 0x2 : 0x1; /* mux channel for psu */ + if (bmc_i2c_writeb(7, 0x70, 0, value) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* Read vin */ + addr = (pid == PSU1_ID) ? 0x59 : 0x5a; + value = bmc_i2c_readw(7, addr, 0x88); + if (value >= 0) { + info->mvin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_VIN; + } + + /* Read iin */ + value = bmc_i2c_readw(7, addr, 0x89); + if (value >= 0) { + info->miin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IIN; + } + + /* Get pin */ + if ((info->caps & ONLP_PSU_CAPS_VIN) && (info->caps & ONLP_PSU_CAPS_IIN)) { + info->mpin = info->mvin * info->miin / 1000; + info->caps |= ONLP_PSU_CAPS_PIN; + } + + /* Read iout */ + value = bmc_i2c_readw(7, addr, 0x8c); + if (value >= 0) { + info->miout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Read pout */ + value = bmc_i2c_readw(7, addr, 0x96); + if (value >= 0) { + info->mpout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_POUT; + } + + /* Get vout */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_POUT) && info->miout != 0) { + info->mvout = info->mpout / info->miout * 1000; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get model name */ + return bmc_i2c_readraw(7, addr, 0x9a, info->model, sizeof(info->model)); +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..0af7c6f3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,253 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100bf_65x_log.h" + +#define BIT(i) (1 << (i)) +#define NUM_OF_SFP_PORT 64 +static const int sfp_bus_index[] = { + 4, 3, 6, 5, 8, 7, 10, 9, + 12, 11, 14, 13, 16, 15, 18, 17, + 20, 19, 22, 21, 24, 23, 26, 25, + 28, 27, 30, 29, 32, 31, 34, 33, + 44, 43, 46, 45, 48, 47, 50, 49, + 52, 51, 54, 53, 56, 55, 58, 57, + 60, 59, 62, 61, 64, 63, 66, 65, + 68, 67, 70, 69, 72, 71, 74, 73, +}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +static uint8_t +onlp_sfpi_reg_val_to_port_sequence(uint8_t value, int revert) +{ + int i; + uint8_t ret = 0; + + for (i = 0; i < 8; i++) { + if (i % 2) { + ret |= (value & BIT(i)) >> 1; + } + else { + ret |= (value & BIT(i)) << 1; + } + } + + return revert ? ~ret : ret; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus; + int addr = ((port < 16) || (port >= 32 && port <= 47)) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset; + + if(port < 16) { + bus = 37; + }else if(port >=16 && port < 32){ + bus = 38; + }else if(port >=32 && port < 48){ + bus = 77; + }else if(port >=48 && port <= 63){ + bus = 78; + } + + if ((port < 8) || (port >= 16 && port <= 23) || (port >= 32 && port <= 39) \ + || (port >=48 && port <=55)) { + offset = 0; + } + else { + offset = 1; + } + + present = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (present < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + present = onlp_sfpi_reg_val_to_port_sequence(present, 0); + return !(present & BIT(port % 8)); +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int i; + uint8_t bytes[8] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(bytes); i++) { + int bus; + int addr = ((i < 2)|| (i > 3 && i < 6)) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset = (i % 2); + /* Adding bus number for upper board QSFP ports */ + switch(i) + { + case 0: + case 1: + bus = 37; + break; + case 2: + case 3: + bus = 38; + break; + case 4: + case 5: + bus = 77; + break; + case 6: + case 7: + bus = 78; + break; + default: + break; + } + + bytes[i] = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (bytes[i] < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + bytes[i] = onlp_sfpi_reg_val_to_port_sequence(bytes[i], 1); + } + + /* Convert to 64 bit integer in port order */ + i = 0; + uint64_t presence_all = 0; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_OK; +} + +static int +sfpi_eeprom_read(int port, uint8_t devaddr, uint8_t data[256]) +{ + int i; + + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + memset(data, 0, 256); + + for (i = 0; i < 128; i++) { + int bus = sfp_bus_index[port]; + int val = onlp_i2c_readw(bus, devaddr, i*2, ONLP_I2C_F_FORCE); + + if (val < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + data[i] = val & 0xff; + data[i+1] = (val >> 8) & 0xff; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x50, data); +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x51, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..653d45cc --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,114 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100bf_65x_int.h" +#include "x86_64_accton_wedge100bf_65x_log.h" + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-wedge100bf-65x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 8 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 2 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 5 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ +} + +int +onlp_sysi_platform_manage_fans(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..f6f67cbe --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,134 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/drivers/lm75/%s/temp1_input" +#define THERMAL_CPU_CORE_PATH_FORMAT "/sys/bus/i2c/drivers/com_e_driver/%s/temp2_input" + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + "4-0033", /* CPU_CORE files */ + "3-0048", + "3-0049", + "3-004a", + "3-004b", + "3-004c", + "8-0048", + "8-0049", +}; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "TMP75-1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "TMP75-2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "TMP75-3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "TMP75-4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "TMP75-5", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "TMP75-6", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_7_ON_MAIN_BROAD), "TMP75-7", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + /* get path */ + if (THERMAL_CPU_CORE == tid) { + sprintf(path, THERMAL_CPU_CORE_PATH_FORMAT, directory[tid]); + }else { + sprintf(path, THERMAL_PATH_FORMAT, directory[tid]); + } + + if (bmc_file_read_int(&info->mcelsius, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_config.c new file mode 100644 index 00000000..65405d9b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(_x) __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(_x) +x86_64_accton_wedge100bf_65x_config_settings_t x86_64_accton_wedge100bf_65x_config_settings[] = +{ +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_STDLIB(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_UCLI(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_WEDGE100BF_65X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_wedge100bf_65x_config_STRINGIFY_VALUE +#undef __x86_64_accton_wedge100bf_65x_config_STRINGIFY_NAME + +const char* +x86_64_accton_wedge100bf_65x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_wedge100bf_65x_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_wedge100bf_65x_config_settings[i].name, setting)) { + return x86_64_accton_wedge100bf_65x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_wedge100bf_65x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_wedge100bf_65x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_wedge100bf_65x_config_settings[i].name, x86_64_accton_wedge100bf_65x_config_settings[i].value); + } + return i; +} + +/* */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_enums.c new file mode 100644 index 00000000..dbf85626 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_int.h new file mode 100644 index 00000000..41272810 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100bf_65x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_wedge100bf_65x_INT_H__ +#define __x86_64_accton_wedge100bf_65x_INT_H__ + +#include + + +#endif /* __x86_64_accton_wedge100bf_65x_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.c new file mode 100644 index 00000000..865b3d12 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100bf_65x_log.h" +/* + * x86_64_accton_wedge100bf_65x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_WEDGE100BF_65X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.h new file mode 100644 index 00000000..75be4f55 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_wedge100bf_65x_LOG_H__ +#define __x86_64_accton_wedge100bf_65x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_wedge100bf_65x +#include + +#endif /* __x86_64_accton_wedge100bf_65x_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_module.c new file mode 100644 index 00000000..9572a4c9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100bf_65x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_wedge100bf_65x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_wedge100bf_65x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_ucli.c new file mode 100644 index 00000000..43b9d1b6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/x86_64_accton_wedge100bf_65x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_wedge100bf_65x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_wedge100bf_65x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_wedge100bf_65x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_wedge100bf_65x_ucli_module__ = + { + "x86_64_accton_wedge100bf_65x_ucli", + NULL, + x86_64_accton_wedge100bf_65x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_wedge100bf_65x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_wedge100bf_65x_ucli_module__); + n = ucli_node_create("x86_64_accton_wedge100bf_65x", NULL, &x86_64_accton_wedge100bf_65x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_wedge100bf_65x")); + return n; +} + +#else +void* +x86_64_accton_wedge100bf_65x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/PKG.yml new file mode 100644 index 00000000..a989249c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-wedge100bf-65x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-65x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-65x-r0.yml new file mode 100644 index 00000000..aa616b23 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/lib/x86-64-accton-wedge100bf-65x-r0.yml @@ -0,0 +1,35 @@ +--- + +###################################################################### +# +# platform-config for WEDGE +# +###################################################################### + +x86-64-accton-wedge100bf-65x-r0: + + grub: + + serial: >- + --unit=0 + --speed=57600 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,57600n8 + rd_NO_MD + rd_NO_LUKS + intel_iommu=off + noapic + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/python/x86_64_accton_wedge100bf_65x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/python/x86_64_accton_wedge100bf_65x_r0/__init__.py new file mode 100644 index 00000000..a8ceb80b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/platform-config/r0/src/python/x86_64_accton_wedge100bf_65x_r0/__init__.py @@ -0,0 +1,31 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_wedge100bf_65x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_64x100): + MODEL="Wedge-100bf-65x" + PLATFORM="x86-64-accton-wedge100bf-65x-r0" + SYS_OBJECT_ID=".100.65.1" + + def baseconfig(self): + ########### initialize I2C bus 1 & bus 2 ########### + self.new_i2c_devices([ + # initialize multiplexer (PCA9548) + ('pca9548', 0x70, 1), + ('pca9548', 0x71, 1), + ('pca9548', 0x72, 1), + ('pca9548', 0x73, 1), + ('pca9548', 0x74, 1), + + + # initialize multiplexer (PCA9548) + ('pca9548', 0x70, 2), + ('pca9548', 0x71, 2), + ('pca9548', 0x72, 2), + ('pca9548', 0x73, 2), + ('pca9548', 0x74, 2), + + ('24c64', 0x50, 41), + ]) + + return True From b1eeddcc3186b27c5066977cfd3687c061bca952 Mon Sep 17 00:00:00 2001 From: "shaohua.xiong" Date: Mon, 26 Feb 2018 15:37:53 +0800 Subject: [PATCH 151/244] amended the comment fot the platform ag6248c and ag6248c_poe --- .../delta/armel/arm-delta-ag6248c/README.md | 5 +---- .../builds/arm-delta-ag6248c-poe-cpld-mux-1.c | 10 ++++------ .../builds/arm-delta-ag6248c-poe-cpld-mux-2.c | 12 +++++------- .../modules/builds/arm-delta-ag6248c-cpld-mux-1.c | 10 ++++------ .../modules/builds/arm-delta-ag6248c-cpld-mux-2.c | 12 +++++------- 5 files changed, 19 insertions(+), 30 deletions(-) diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/README.md b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md index b49d2126..20a424e5 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/README.md +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/README.md @@ -1,7 +1,4 @@ -#How to run ONL in DELTA AG6248C board - -For the first step, it only support install the ONL to the USB and boot up. -It will be support to install the ONL to NandFlash next step. +#How to run ONL in DELTA AG6248C and AG6248C_POE board Build the ONL -------------------------------------------------------------------------- diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c index 29686679..08d3b805 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-1.c @@ -1,13 +1,11 @@ /* - * An I2C multiplexer dirver for delta as5812 CPLD + * An I2C multiplexer dirver for delta ag6248c_poe CPLD * - * Copyright (C) 2015 Delta Technology Corporation. - * Brandon Chuang + * Copyright (C) 2018 Delta Networks, Inc. + * Shaohua Xiong * * This module supports the delta cpld that hold the channel select * mechanism for other i2c slave devices, such as SFP. - * This includes the: - * Delta ag7648c CPLD1/CPLD2/CPLD3 * * Based on: * pca954x.c from Kumar Gala @@ -233,7 +231,7 @@ static void __exit delta_i2c_cpld_mux_exit(void) __delta_i2c_cpld_mux_remove (); } -MODULE_AUTHOR("Dave Hu "); +MODULE_AUTHOR("Shaohua Xiong "); MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); MODULE_LICENSE("GPL"); diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c index c3354b89..8ed6f32e 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c-poe/modules/builds/arm-delta-ag6248c-poe-cpld-mux-2.c @@ -1,13 +1,11 @@ /* - * An I2C multiplexer dirver for delta as5812 CPLD + * An I2C multiplexer dirver for delta ag6248c_poe CPLD * - * Copyright (C) 2015 Delta Technology Corporation. - * Brandon Chuang + * Copyright (C) 2018 Delta Networks, Inc. + * Shaohua.xiong * * This module supports the delta cpld that hold the channel select - * mechanism for other i2c slave devices, such as SFP. - * This includes the: - * Delta ag7648c CPLD1/CPLD2/CPLD3 + * mechanism for other i2c slave devices, such as PSU. * * Based on: * pca954x.c from Kumar Gala @@ -234,7 +232,7 @@ static void __exit delta_i2c_cpld_mux_exit(void) __delta_i2c_cpld_mux_remove (); } -MODULE_AUTHOR("Dave Hu "); +MODULE_AUTHOR("Shaohua.xiong "); MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); MODULE_LICENSE("GPL"); diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c index 56d68b13..23b07f51 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-1.c @@ -1,13 +1,11 @@ /* - * An I2C multiplexer dirver for delta as5812 CPLD + * An I2C multiplexer dirver for delta ag6248c CPLD * - * Copyright (C) 2017 Delta Networks, Inc. - * Brandon Chuang + * Copyright (C) 2018 Delta Networks, Inc. + * Shaohua Xiong * * This module supports the delta cpld that hold the channel select * mechanism for other i2c slave devices, such as SFP. - * This includes the: - * Delta ag7648c CPLD1/CPLD2/CPLD3 * * Based on: * pca954x.c from Kumar Gala @@ -233,7 +231,7 @@ static void __exit delta_i2c_cpld_mux_exit(void) __delta_i2c_cpld_mux_remove (); } -MODULE_AUTHOR("Dave Hu "); +MODULE_AUTHOR("Shaohua Xiong "); MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); MODULE_LICENSE("GPL"); diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c index 12b5fb38..a133439e 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/arm-delta-ag6248c/modules/builds/arm-delta-ag6248c-cpld-mux-2.c @@ -1,13 +1,11 @@ /* - * An I2C multiplexer dirver for delta as5812 CPLD + * An I2C multiplexer dirver for delta ag6248c CPLD * - * Copyright (C) 2017 Delta Networks, Inc. - * Brandon Chuang + * Copyright (C) 2018 Delta Networks, Inc. + * Shaohua Xiong * * This module supports the delta cpld that hold the channel select - * mechanism for other i2c slave devices, such as SFP. - * This includes the: - * Delta ag7648c CPLD1/CPLD2/CPLD3 + * mechanism for other i2c slave devices, such as PSU. * * Based on: * pca954x.c from Kumar Gala @@ -234,7 +232,7 @@ static void __exit delta_i2c_cpld_mux_exit(void) __delta_i2c_cpld_mux_remove (); } -MODULE_AUTHOR("Dave Hu "); +MODULE_AUTHOR("Shaohua Xiong "); MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); MODULE_LICENSE("GPL"); From 58d6801e57c36cc4d5fd1a324f40ea1df109ca7f Mon Sep 17 00:00:00 2001 From: "shaohua.xiong" Date: Tue, 27 Feb 2018 18:42:15 +0800 Subject: [PATCH 152/244] modified the comment and module name for ag6248c and ag6248c_poe --- .../module/auto/arm_delta_ag6248c.yml | 30 +++--- .../inc/arm_delta_ag6248c/arm_delta_ag6248c.x | 7 +- .../arm_delta_ag6248c_config.h | 70 +++++++------- .../arm_delta_ag6248c/arm_delta_ag6248c_dox.h | 13 +-- .../arm_delta_ag6248c_porting.h | 96 +++++++++---------- .../module/src/arm_delta_ag6248c_config.c | 59 ++++++------ .../module/src/arm_delta_ag6248c_enums.c | 7 +- .../module/src/arm_delta_ag6248c_int.h | 13 +-- .../module/src/arm_delta_ag6248c_log.c | 13 +-- .../module/src/arm_delta_ag6248c_log.h | 13 +-- .../module/src/arm_delta_ag6248c_module.c | 10 +- .../module/src/arm_delta_ag6248c_ucli.c | 10 +- .../module/src/arm_delta_i2c.c | 11 +-- .../module/src/arm_delta_i2c.h | 10 +- .../src/arm_delta_ag6248c/module/src/fani.c | 4 +- .../module/src/platform_lib.c | 2 +- .../src/arm_delta_ag6248c/module/src/sysi.c | 8 +- 17 files changed, 149 insertions(+), 227 deletions(-) diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml index 80f1a97d..c807d0c5 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/auto/arm_delta_ag6248c.yml @@ -1,13 +1,7 @@ ############################################################ # # -# Copyright 2014, 2015 Big Switch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html +# Copyright 2018, Delta Networks, Inc. # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -23,39 +17,39 @@ ############################################################ cdefs: &cdefs -- ONLPSIM_CONFIG_INCLUDE_LOGGING: +- ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT: +- ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- ONLPSIM_CONFIG_LOG_BITS_DEFAULT: +- ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- ONLPSIM_CONFIG_PORTING_STDLIB: +- ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." - default: ONLPSIM_CONFIG_PORTING_STDLIB -- ONLPSIM_CONFIG_INCLUDE_UCLI: + default: ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB +- ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- ONLPSIM_CONFIG_SFP_COUNT: +- ARM_DELTA_AG6248C_CONFIG_SFP_COUNT: doc: "SFP Count." default: 0 definitions: cdefs: - ONLPSIM_CONFIG_HEADER: + ARM_DELTA_AG6248C_CONFIG_HEADER: defs: *cdefs basename: arm_delta_ag6248c_config portingmacro: - ONLPSIM: + ARM_DELTA_AG6248C: macros: - malloc - free diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x index f15500cc..fe36b7c6 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c.x @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h index 68664185..33b217e1 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_config.h @@ -1,14 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * + * Copyright 2018, Delta Networks, Inc. + * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, @@ -32,96 +26,96 @@ * @{ * *****************************************************************************/ -#ifndef __ONLPSIM_CONFIG_H__ -#define __ONLPSIM_CONFIG_H__ +#ifndef __ARM_DELTA_AG6248C_CONFIG_H__ +#define __ARM_DELTA_AG6248C_CONFIG_H__ #ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG #include #endif -#ifdef ONLPSIM_INCLUDE_CUSTOM_CONFIG +#ifdef ARM_DELTA_AG6248C_INCLUDE_CUSTOM_CONFIG #include #endif -/* */ +/* */ #include /** - * ONLPSIM_CONFIG_INCLUDE_LOGGING + * ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef ONLPSIM_CONFIG_INCLUDE_LOGGING -#define ONLPSIM_CONFIG_INCLUDE_LOGGING 1 +#ifndef ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING +#define ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING 1 #endif /** - * ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT + * ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT -#define ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT +#define ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * ONLPSIM_CONFIG_LOG_BITS_DEFAULT + * ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef ONLPSIM_CONFIG_LOG_BITS_DEFAULT -#define ONLPSIM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT +#define ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * ONLPSIM_CONFIG_PORTING_STDLIB + * ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef ONLPSIM_CONFIG_PORTING_STDLIB -#define ONLPSIM_CONFIG_PORTING_STDLIB 1 +#ifndef ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB +#define ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB 1 #endif /** - * ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLPSIM_CONFIG_PORTING_STDLIB +#ifndef ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB #endif /** - * ONLPSIM_CONFIG_INCLUDE_UCLI + * ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef ONLPSIM_CONFIG_INCLUDE_UCLI -#define ONLPSIM_CONFIG_INCLUDE_UCLI 0 +#ifndef ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI +#define ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI 0 #endif /** - * ONLPSIM_CONFIG_SFP_COUNT + * ARM_DELTA_AG6248C_CONFIG_SFP_COUNT * * SFP Count. */ -#ifndef ONLPSIM_CONFIG_SFP_COUNT -#define ONLPSIM_CONFIG_SFP_COUNT 0 +#ifndef ARM_DELTA_AG6248C_CONFIG_SFP_COUNT +#define ARM_DELTA_AG6248C_CONFIG_SFP_COUNT 0 #endif @@ -154,9 +148,9 @@ const char* arm_delta_ag6248c_config_lookup(const char* setting); */ int arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "arm_delta_ag6248c_porting.h" -#endif /* __ONLPSIM_CONFIG_H__ */ +#endif /* __ARM_DELTA_AG6248C_CONFIG_H__ */ /* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h index 20f312ed..bc2e4f7a 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_dox.h @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -28,8 +23,8 @@ * arm_delta_ag6248c Doxygen Header * ***********************************************************/ -#ifndef __ONLPSIM_DOX_H__ -#define __ONLPSIM_DOX_H__ +#ifndef __ARM_DELTA_AG6248C_DOX_H__ +#define __ARM_DELTA_AG6248C_DOX_H__ /** * @defgroup arm_delta_ag6248c arm_delta_ag6248c - onlpsim Description @@ -48,4 +43,4 @@ The documentation overview for this module should go here. * */ -#endif /* __ONLPSIM_DOX_H__ */ +#endif /* __ARM_DELTA_AG6248C_DOX_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h index 19853401..15f715f3 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/inc/arm_delta_ag6248c/arm_delta_ag6248c_porting.h @@ -1,13 +1,7 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html + * Copyright 2018, Delta Networks, Inc. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -32,12 +26,12 @@ * @{ * ***********************************************************/ -#ifndef __ONLPSIM_PORTING_H__ -#define __ONLPSIM_PORTING_H__ +#ifndef __ARM_DELTA_AG6248C_PORTING_H__ +#define __ARM_DELTA_AG6248C_PORTING_H__ /* */ -#if ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -45,88 +39,88 @@ #include #endif -#ifndef ONLPSIM_MALLOC +#ifndef ARM_DELTA_AG6248C_MALLOC #if defined(GLOBAL_MALLOC) - #define ONLPSIM_MALLOC GLOBAL_MALLOC - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_MALLOC malloc + #define ARM_DELTA_AG6248C_MALLOC GLOBAL_MALLOC + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_MALLOC malloc #else - #error The macro ONLPSIM_MALLOC is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_MALLOC is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_FREE +#ifndef ARM_DELTA_AG6248C_FREE #if defined(GLOBAL_FREE) - #define ONLPSIM_FREE GLOBAL_FREE - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_FREE free + #define ARM_DELTA_AG6248C_FREE GLOBAL_FREE + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_FREE free #else - #error The macro ONLPSIM_FREE is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_FREE is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_MEMSET +#ifndef ARM_DELTA_AG6248C_MEMSET #if defined(GLOBAL_MEMSET) - #define ONLPSIM_MEMSET GLOBAL_MEMSET - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_MEMSET memset + #define ARM_DELTA_AG6248C_MEMSET GLOBAL_MEMSET + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_MEMSET memset #else - #error The macro ONLPSIM_MEMSET is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_MEMSET is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_MEMCPY +#ifndef ARM_DELTA_AG6248C_MEMCPY #if defined(GLOBAL_MEMCPY) - #define ONLPSIM_MEMCPY GLOBAL_MEMCPY - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_MEMCPY memcpy + #define ARM_DELTA_AG6248C_MEMCPY GLOBAL_MEMCPY + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_MEMCPY memcpy #else - #error The macro ONLPSIM_MEMCPY is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_MEMCPY is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_STRNCPY +#ifndef ARM_DELTA_AG6248C_STRNCPY #if defined(GLOBAL_STRNCPY) - #define ONLPSIM_STRNCPY GLOBAL_STRNCPY - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_STRNCPY strncpy + #define ARM_DELTA_AG6248C_STRNCPY GLOBAL_STRNCPY + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_STRNCPY strncpy #else - #error The macro ONLPSIM_STRNCPY is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_STRNCPY is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_VSNPRINTF +#ifndef ARM_DELTA_AG6248C_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define ONLPSIM_VSNPRINTF GLOBAL_VSNPRINTF - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_VSNPRINTF vsnprintf + #define ARM_DELTA_AG6248C_VSNPRINTF GLOBAL_VSNPRINTF + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_VSNPRINTF vsnprintf #else - #error The macro ONLPSIM_VSNPRINTF is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_SNPRINTF +#ifndef ARM_DELTA_AG6248C_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define ONLPSIM_SNPRINTF GLOBAL_SNPRINTF - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_SNPRINTF snprintf + #define ARM_DELTA_AG6248C_SNPRINTF GLOBAL_SNPRINTF + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_SNPRINTF snprintf #else - #error The macro ONLPSIM_SNPRINTF is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef ONLPSIM_STRLEN +#ifndef ARM_DELTA_AG6248C_STRLEN #if defined(GLOBAL_STRLEN) - #define ONLPSIM_STRLEN GLOBAL_STRLEN - #elif ONLPSIM_CONFIG_PORTING_STDLIB == 1 - #define ONLPSIM_STRLEN strlen + #define ARM_DELTA_AG6248C_STRLEN GLOBAL_STRLEN + #elif ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB == 1 + #define ARM_DELTA_AG6248C_STRLEN strlen #else - #error The macro ONLPSIM_STRLEN is required but cannot be defined. + #error The macro ARM_DELTA_AG6248C_STRLEN is required but cannot be defined. #endif #endif /* */ -#endif /* __ONLPSIM_PORTING_H__ */ +#endif /* __ARM_DELTA_AG6248C_PORTING_H__ */ /* @} */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c index 6447135c..e116934f 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_config.c @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -25,50 +20,50 @@ #include -/* */ +/* */ #define __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) #_x #define __arm_delta_ag6248c_config_STRINGIFY_VALUE(_x) __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[] = { -#ifdef ONLPSIM_CONFIG_INCLUDE_LOGGING - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_LOGGING), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_LOGGING) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING) }, #else -{ ONLPSIM_CONFIG_INCLUDE_LOGGING(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_INCLUDE_LOGGING(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_LOG_BITS_DEFAULT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT) }, #else -{ ONLPSIM_CONFIG_LOG_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_PORTING_STDLIB - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_STDLIB), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_STDLIB) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB) }, #else -{ ONLPSIM_CONFIG_PORTING_STDLIB(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_PORTING_STDLIB(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_INCLUDE_UCLI - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_UCLI), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_UCLI) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI) }, #else -{ ONLPSIM_CONFIG_INCLUDE_UCLI(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef ONLPSIM_CONFIG_SFP_COUNT - { __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_SFP_COUNT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_SFP_COUNT) }, +#ifdef ARM_DELTA_AG6248C_CONFIG_SFP_COUNT + { __arm_delta_ag6248c_config_STRINGIFY_NAME(ARM_DELTA_AG6248C_CONFIG_SFP_COUNT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ARM_DELTA_AG6248C_CONFIG_SFP_COUNT) }, #else -{ ONLPSIM_CONFIG_SFP_COUNT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, +{ ARM_DELTA_AG6248C_CONFIG_SFP_COUNT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -97,5 +92,5 @@ arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs) return i; } -/* */ +/* */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c index 2a14c2cc..f8b2d375 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_enums.c @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h index 8dfd2c7c..d87656ee 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_int.h @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -23,10 +18,10 @@ * ***********************************************************/ -#ifndef __ONLPSIM_INT_H__ -#define __ONLPSIM_INT_H__ +#ifndef __ARM_DELTA_AG6248C_INT_H__ +#define __ARM_DELTA_AG6248C_INT_H__ #include -#endif /* __ONLPSIM_INT_H__ */ +#endif /* __ARM_DELTA_AG6248C_INT_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c index 1941f294..772566b5 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.c @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -30,9 +25,9 @@ * arm_delta_ag6248c log struct. */ AIM_LOG_STRUCT_DEFINE( - ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT, - ONLPSIM_CONFIG_LOG_BITS_DEFAULT, + ARM_DELTA_AG6248C_CONFIG_LOG_OPTIONS_DEFAULT, + ARM_DELTA_AG6248C_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ARM_DELTA_AG6248C_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h index 13d00bc5..3d5d1e79 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_log.h @@ -1,13 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2018, Delta Networks, Inc. * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -23,10 +18,10 @@ * ***********************************************************/ -#ifndef __ONLPSIM_LOG_H__ -#define __ONLPSIM_LOG_H__ +#ifndef __ARM_DELTA_AG6248C_LOG_H__ +#define __ARM_DELTA_AG6248C_LOG_H__ #define AIM_LOG_MODULE_NAME arm_delta_ag6248c #include -#endif /* __ONLPSIM_LOG_H__ */ +#endif /* __ARM_DELTA_AG6248C_LOG_H__ */ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c index fdb080f0..c2e8bad5 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_module.c @@ -1,13 +1,7 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html + * Copyright 2018, Delta Networks, Inc. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -30,7 +24,7 @@ static int datatypes_init__(void) { -#define ONLPSIM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#define ARM_DELTA_AG6248C_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/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c index 4dbeeed0..b99ca825 100644 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_ag6248c_ucli.c @@ -1,13 +1,7 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html + * Copyright 2018, Delta Networks, Inc. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -25,7 +19,7 @@ #include -#if ONLPSIM_CONFIG_INCLUDE_UCLI == 1 +#if ARM_DELTA_AG6248C_CONFIG_INCLUDE_UCLI == 1 #include #include diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c index a7a83e0e..6a280e65 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.c @@ -1,15 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html + * Copyright 2018 Delta Technology Corporation. + * Copyright 2018 Delta Networks, Inc * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h index 76c35cbb..5b24b76d 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/arm_delta_i2c.h @@ -1,14 +1,8 @@ /************************************************************ * * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. - * Copyright 2017 Delta Networks, Inc - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html + * Copyright 2018 Delta Technology Corporation. + * Copyright 2018 Delta Networks, Inc * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c index b0c16526..e511eca6 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/fani.c @@ -64,7 +64,7 @@ enum onlp_fan_id #define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ { \ { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ - ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ + ONLP_FAN_STATUS_F2B | ONLP_FAN_STATUS_PRESENT, \ (ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM| ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ 0, \ 0, \ @@ -74,7 +74,7 @@ enum onlp_fan_id #define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ { \ { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ - ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \ + ONLP_FAN_STATUS_F2B | ONLP_FAN_STATUS_PRESENT, \ (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ 0, \ 0, \ diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c index 118cc437..a5b27735 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/platform_lib.c @@ -37,7 +37,7 @@ psu_type_t get_psu_type(int id) { if ((id == PSU1_ID)||(id == PSU2_ID)) - return PSU_TYPE_AC_B2F; + return PSU_TYPE_AC_F2B; return PSU_TYPE_UNKNOWN; } diff --git a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c index b8b0adec..649a4e04 100755 --- a/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c +++ b/packages/platforms/delta/armel/arm-delta-ag6248c/src/arm_delta_ag6248c/module/src/sysi.c @@ -165,13 +165,13 @@ onlp_sysi_platform_manage_fans(void) } /* Get temperature */ - rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); if (rc != ONLP_STATUS_OK) { return rc; } - rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); if (rc != ONLP_STATUS_OK) { return rc; @@ -192,8 +192,8 @@ onlp_sysi_platform_manage_fans(void) return ONLP_STATUS_OK; } - onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); - onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); return ONLP_STATUS_OK; From db5237de9f0c3a530738152b1fa7ba55ace5e20d Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 27 Feb 2018 19:59:52 +0000 Subject: [PATCH 153/244] Initial support for the Wedge100s. --- .../x86-64-accton-wedge100s-32x/.gitignore | 3 + .../x86-64-accton-wedge100s-32x/onlp/PKG.yml | 17 +- .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 44 +++ .../onlp/builds/onlpdump/Makefile | 46 ++++ .../onlp/builds/src/.module | 1 + .../src/x86_64_accton_wedge100s_32x/.module | 1 + .../src/x86_64_accton_wedge100s_32x/Makefile | 9 + .../src/x86_64_accton_wedge100s_32x/README | 6 + .../module/auto/make.mk | 9 + .../auto/x86_64_accton_wedge100s_32x.yml | 47 ++++ .../x86_64_accton_wedge100s_32x.x | 14 + .../x86_64_accton_wedge100s_32x_config.h | 127 +++++++++ .../x86_64_accton_wedge100s_32x_dox.h | 26 ++ .../x86_64_accton_wedge100s_32x_porting.h | 107 ++++++++ .../module/make.mk | 10 + .../module/src/Makefile | 9 + .../module/src/fani.c | 222 ++++++++++++++++ .../module/src/ledi.c | 219 +++++++++++++++ .../module/src/make.mk | 9 + .../module/src/platform_lib.c | 250 ++++++++++++++++++ .../module/src/platform_lib.h | 69 +++++ .../module/src/psui.c | 174 ++++++++++++ .../module/src/sfpi.c | 196 ++++++++++++++ .../module/src/sysi.c | 113 ++++++++ .../module/src/thermali.c | 140 ++++++++++ .../src/x86_64_accton_wedge100s_32x_config.c | 76 ++++++ .../src/x86_64_accton_wedge100s_32x_enums.c | 10 + .../src/x86_64_accton_wedge100s_32x_int.h | 12 + .../src/x86_64_accton_wedge100s_32x_log.c | 18 ++ .../src/x86_64_accton_wedge100s_32x_log.h | 12 + .../src/x86_64_accton_wedge100s_32x_module.c | 24 ++ .../src/x86_64_accton_wedge100s_32x_ucli.c | 50 ++++ .../utest/_make.mk | 8 + .../x86_64_accton_wedge100s_32x/utest/main.c | 19 ++ .../x86_64_accton_wedge100s_32x.doxy | 0 .../lib/x86-64-accton-wedge100s-32x-r0.yml | 17 +- .../__init__.py | 19 +- 38 files changed, 2102 insertions(+), 33 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/x86_64_accton_wedge100s_32x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/_make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/main.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.doxy diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/.gitignore new file mode 100644 index 00000000..d82fa974 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*wedge100*32x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml index b1524668..4fe7098e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/PKG.yml @@ -1,16 +1 @@ -variables: - platform: x86-64-accton-wedge100s-32x-r0 - install: /lib/platform-config/${platform}/onl - -common: - version: 1.0.0 - arch: amd64 - copyright: Copyright 2013, 2014, 2015 Big Switch Networks - maintainer: support@bigswitch.com - support: opennetworklinux@googlegroups.com - comment: dummy package for ONLP on Wedge -packages: - - name: onlp-${platform} - summary: ONLP Package for the ${platform} platform. - - changelog: initial version +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-wedge100s-32x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/lib/Makefile new file mode 100644 index 00000000..54e34001 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/lib/Makefile @@ -0,0 +1,44 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-wedge100s-32x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_wedge100s_32x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-wedge100s-32x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..1aa18ee5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_wedge100s_32x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module new file mode 100644 index 00000000..91bd6c78 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_wedge100s_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.module b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.module new file mode 100644 index 00000000..91bd6c78 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.module @@ -0,0 +1 @@ +name: x86_64_accton_wedge100s_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/Makefile new file mode 100644 index 00000000..3ca74fc4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_accton_wedge100s_32x +AUTOMODULE := x86_64_accton_wedge100s_32x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/README b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/README new file mode 100644 index 00000000..631a1ce2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_wedge100s_32x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/make.mk new file mode 100644 index 00000000..b9034a34 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_wedge100s_32x Autogeneration +# +############################################################################### +x86_64_accton_wedge100s_32x_AUTO_DEFS := module/auto/x86_64_accton_wedge100s_32x.yml +x86_64_accton_wedge100s_32x_AUTO_DIRS := module/inc/x86_64_accton_wedge100s_32x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/x86_64_accton_wedge100s_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/x86_64_accton_wedge100s_32x.yml new file mode 100644 index 00000000..608b348d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/auto/x86_64_accton_wedge100s_32x.yml @@ -0,0 +1,47 @@ +############################################################################### +# +# x86_64_accton_wedge100s_32x Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_WEDGE100S_32X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_wedge100s_32x_config + + portingmacro: + X86_64_ACCTON_WEDGE100S_32X: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.x b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.x new file mode 100644 index 00000000..4deea51a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_config.h new file mode 100644 index 00000000..b1610cdc --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_config.h @@ -0,0 +1,127 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100s_32x Configuration Header + * + * @addtogroup x86_64_accton_wedge100s_32x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100S_32X_CONFIG_H__ +#define __X86_64_ACCTON_WEDGE100S_32X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_wedge100s_32x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_wedge100s_32x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_wedge100s_32x_config_settings table. */ +extern x86_64_accton_wedge100s_32x_config_settings_t x86_64_accton_wedge100s_32x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_wedge100s_32x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_wedge100s_32x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_wedge100s_32x_porting.h" + +#endif /* __X86_64_ACCTON_WEDGE100S_32X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_dox.h new file mode 100644 index 00000000..ef861e46 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100s_32x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100S_32X_DOX_H__ +#define __X86_64_ACCTON_WEDGE100S_32X_DOX_H__ + +/** + * @defgroup x86_64_accton_wedge100s_32x x86_64_accton_wedge100s_32x - x86_64_accton_wedge100s_32x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_wedge100s_32x-x86_64_accton_wedge100s_32x Public Interface + * @defgroup x86_64_accton_wedge100s_32x-config Compile Time Configuration + * @defgroup x86_64_accton_wedge100s_32x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_WEDGE100S_32X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_porting.h new file mode 100644 index 00000000..6d6ce571 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/inc/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_wedge100s_32x Porting Macros. + * + * @addtogroup x86_64_accton_wedge100s_32x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100S_32X_PORTING_H__ +#define __X86_64_ACCTON_WEDGE100S_32X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_ACCTON_WEDGE100S_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_MALLOC malloc + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_FREE + #if defined(GLOBAL_FREE) + #define X86_64_ACCTON_WEDGE100S_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_FREE free + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_ACCTON_WEDGE100S_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_MEMSET memset + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_ACCTON_WEDGE100S_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_MEMCPY memcpy + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_ACCTON_WEDGE100S_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_STRNCPY strncpy + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_ACCTON_WEDGE100S_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_VSNPRINTF vsnprintf + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_ACCTON_WEDGE100S_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_SNPRINTF snprintf + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100S_32X_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_ACCTON_WEDGE100S_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100S_32X_STRLEN strlen + #else + #error The macro X86_64_ACCTON_WEDGE100S_32X_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_WEDGE100S_32X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/make.mk new file mode 100644 index 00000000..3b812b9d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_wedge100s_32x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_wedge100s_32x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_wedge100s_32x_DEPENDMODULE_ENTRIES := init:x86_64_accton_wedge100s_32x ucli:x86_64_accton_wedge100s_32x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/Makefile new file mode 100644 index 00000000..40d43acd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_wedge100s_32x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/fani.c new file mode 100644 index 00000000..32a39401 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/fani.c @@ -0,0 +1,222 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define MAX_FAN_SPEED 15400 +#define BIT(i) (1 << (i)) + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, +}; + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/8-0033/" + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5) +}; + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int value = 0, fid; + char path[64] = {0}; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + /* get fan present status + */ + sprintf(path, "%s""fantray_present", FAN_BOARD_PATH); + + if (bmc_file_read_int(&value, path, 16) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value & BIT(fid-1)) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get front fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2 - 1); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan rpm + */ + sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2); + + if (bmc_file_read_int(&value, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + + /* set fan status based on rpm + */ + if (!info->rpm) { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + /* set fan direction + */ + info->status |= ONLP_FAN_STATUS_F2B; + + return ONLP_STATUS_OK; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + char cmd[32] = {0}; + + sprintf(cmd, "set_fan_speed.sh %d", p); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/ledi.c new file mode 100644 index 00000000..5f4d375c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/ledi.c @@ -0,0 +1,219 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id + { + LED_RESERVED = 0, + LED_SYS1, + LED_SYS2 + }; + +typedef struct led_address_s { + enum onlp_led_id id; + uint8_t bus; + uint8_t devaddr; + uint8_t offset; +} led_address_t; + +typedef struct led_mode_info_s { + onlp_led_mode_t mode; + uint8_t regval; +} led_mode_info_t; + +static led_address_t led_addr[] = + { + { }, /* Not used */ + {LED_SYS1, 1, 0x32, 0x3e}, + {LED_SYS2, 1, 0x32, 0x3f}, + }; + +static led_mode_info_t led_mode_info[] = + { + {ONLP_LED_MODE_OFF, 0x0}, + {ONLP_LED_MODE_OFF, 0x8}, + {ONLP_LED_MODE_RED, 0x1}, + {ONLP_LED_MODE_RED_BLINKING, 0x9}, + {ONLP_LED_MODE_GREEN, 0x2}, + {ONLP_LED_MODE_GREEN_BLINKING, 0xa}, + {ONLP_LED_MODE_BLUE, 0x4}, + {ONLP_LED_MODE_BLUE_BLINKING, 0xc}, + }; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = + { + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS1), "Chassis LED 1 (SYS LED 1)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_SYS2), "Chassis LED 1 (SYS LED 2)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | + ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, + }, + }; + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +reg_value_to_onlp_led_mode(enum onlp_led_id id, int value) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (value != led_mode_info[i].regval) { + continue; + } + + return led_mode_info[i].mode; + } + + return ONLP_LED_MODE_AUTO; +} + +static int +onlp_led_mode_to_reg_value(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i; + + for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) { + if (onlp_led_mode != led_mode_info[i].mode) { + continue; + } + + return led_mode_info[i].regval; + } + + return 0; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + value = onlp_i2c_readb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = reg_value_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid, value; + + VALIDATE(id); + lid = ONLP_OID_ID_GET(id); + + value = onlp_led_mode_to_reg_value(lid, mode); + if (onlp_i2c_writeb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, value, ONLP_I2C_F_FORCE) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/make.mk new file mode 100644 index 00000000..04e805d7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_wedge100s_32x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.c new file mode 100644 index 00000000..759426c6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.c @@ -0,0 +1,250 @@ +/************************************************************ + * + * + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define TTY_DEVICE "/dev/ttyACM0" +#define TTY_PROMPT "@bmc:" +#define TTY_I2C_TIMEOUT 60000 +#define TTY_BMC_LOGIN_TIMEOUT 1000000 +#define TTY_RETRY 10 +#define MAXIMUM_TTY_BUFFER_LENGTH 1024 +#define MAXIMUM_TTY_STRING_LENGTH (MAXIMUM_TTY_BUFFER_LENGTH - 1) + +static int tty_fd = -1; +static char tty_buf[MAXIMUM_TTY_BUFFER_LENGTH] = {0}; + +static int tty_open(void) +{ + int i = 20; + struct termios attr; + + if (tty_fd > -1) { + return 0; + } + + do { + if ((tty_fd = open(TTY_DEVICE, O_RDWR | O_NOCTTY | O_NDELAY)) > -1) { + tcgetattr(tty_fd, &attr); + attr.c_cflag = B57600 | CS8 | CLOCAL | CREAD; + attr.c_iflag = IGNPAR; + attr.c_oflag = 0; + attr.c_lflag = 0; + attr.c_cc[VMIN] = (unsigned char) + ((MAXIMUM_TTY_STRING_LENGTH > 0xFF) ? 0xFF : MAXIMUM_TTY_STRING_LENGTH); + attr.c_cc[VTIME] = 0; + cfsetospeed(&attr, B57600); + cfsetispeed(&attr, B57600); + tcsetattr(tty_fd, TCSANOW, &attr); + return 0; + } + + i--; + usleep(100000); + } while (i > 0); + + return -1; +} + +static int tty_close(void) +{ + close(tty_fd); + tty_fd = -1; + return 0; +} + +static int tty_exec_buf(unsigned long udelay, const char *str) +{ + if (tty_fd < 0) + return -1; + + write(tty_fd, tty_buf, strlen(tty_buf)+1); + usleep(udelay); + read(tty_fd, tty_buf, MAXIMUM_TTY_BUFFER_LENGTH); + return (strstr(tty_buf, str) != NULL) ? 0 : -1; +} + +static int tty_login(void) +{ + int i = 10; + + for (i = 1; i <= TTY_RETRY; i++) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "\r\r"); + if (!tty_exec_buf(0, TTY_PROMPT)) { + return 0; + } + + if (strstr(tty_buf, "bmc login:") != NULL) + { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "root\r"); + + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, "Password:")) { + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "0penBmc\r"); + if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, TTY_PROMPT)) { + return 0; + } + + } + } + usleep(50000); + } + + return -1; +} + +int bmc_send_command(char *cmd) +{ + int i, ret = 0; + + for (i = 1; i <= TTY_RETRY; i++) { + if (tty_open() != 0) { + printf("ERROR: Cannot open TTY device\n"); + continue; + } + if (tty_login() != 0) { + //printf("ERROR: Cannot login TTY device\n"); + tty_close(); + continue; + } + + snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "%s", cmd); + ret = tty_exec_buf(TTY_I2C_TIMEOUT * i, TTY_PROMPT); + tty_close(); + if (ret != 0) { + printf("ERROR: bmc_send_command timed out\n"); + continue; + } + + return 0; + } + + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return -1; +} + +int +bmc_command_read_int(int* value, char *cmd, int base) +{ + int len; + int i; + char *prev_str = NULL; + char *current_str= NULL; + if (bmc_send_command(cmd) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + len = (int)strlen(cmd); + prev_str = strstr(tty_buf, cmd); + if (prev_str == NULL) { + return -1; + } + for (i = 1; i <= TTY_RETRY; i++) { + current_str = strstr(prev_str + len, cmd); + if(current_str == NULL) { + *value = strtoul(prev_str + len, NULL, base); + break; + }else { + prev_str = current_str; + continue; + } + } + return 0; +} + +int +bmc_file_read_int(int* value, char *file, int base) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "cat %s\r\n", file); + return bmc_command_read_int(value, cmd, base); +} + +int +bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + char cmd[64] = {0}; + snprintf(cmd, sizeof(cmd), "i2cset -f -y %d 0x%x 0x%02x 0x%x\r\n", bus, devaddr, addr, value); + return bmc_send_command(cmd); +} + +int +bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr) +{ + int ret = 0, value; + char cmd[64] = {0}; + + snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x w\r\n", bus, devaddr, addr); + ret = bmc_command_read_int(&value, cmd, 16); + return (ret < 0) ? ret : value; +} + +int +bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size) +{ + int data_len, i = 0; + char cmd[64] = {0}; + char *str = NULL; + snprintf(cmd, sizeof(cmd), "i2craw -w 0x%x -r 0 %d 0x%02x\r\n", addr, bus, devaddr); + + if (bmc_send_command(cmd) < 0) { + AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd); + return ONLP_STATUS_E_INTERNAL; + } + + str = strstr(tty_buf, "Received:\r\n "); + if (str == NULL) { + return -1; + } + + /* first byte is data length */ + str += strlen("Received:\r\n ");; + data_len = strtoul(str, NULL, 16); + if (data_size < data_len) { + data_len = data_size; + } + + for (i = 0; (i < data_len) && (str != NULL); i++) { + str = strstr(str, " ") + 1; /* Jump to next token */ + data[i] = strtoul(str, NULL, 16); + } + + data[i] = 0; + return 0; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.h new file mode 100644 index 00000000..e7338378 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/platform_lib.h @@ -0,0 +1,69 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_wedge100s_32x_log.h" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define CHASSIS_FAN_COUNT 5 +#define CHASSIS_THERMAL_COUNT 8 +#define CHASSIS_LED_COUNT 2 +#define CHASSIS_PSU_COUNT 2 + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-40/40-0050/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_6_ON_MAIN_BROAD, + THERMAL_7_ON_MAIN_BROAD, +}; + +int bmc_send_command(char *cmd); +int bmc_file_read_int(int* value, char *file, int base); +int bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value); +int bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr); +int bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size); + +#endif /* __PLATFORM_LIB_H__ */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/psui.c new file mode 100644 index 00000000..c86661ba --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/psui.c @@ -0,0 +1,174 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define PSU1_ID 1 +#define PSU2_ID 2 + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +twos_complement_to_int(uint16_t data, uint8_t valid_bit, int mask) +{ + uint16_t valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static int +pmbus_parse_literal_format(uint16_t value) +{ + int exponent, mantissa, multiplier = 1000; + + exponent = twos_complement_to_int(value >> 11, 5, 0x1f); + mantissa = twos_complement_to_int(value & 0x7ff, 11, 0x7ff); + + return (exponent >= 0) ? (mantissa << exponent) * multiplier : + (mantissa * multiplier) / (1 << -exponent); +} + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int pid, value, addr; + + uint8_t mask = 0; + + VALIDATE(id); + + pid = ONLP_OID_ID_GET(id); + *info = pinfo[pid]; /* Set the onlp_oid_hdr_t */ + + /* Get the present status + */ + mask = 1 << ((pid-1) * 4); + value = onlp_i2c_readb(1, 0x32, 0x10, ONLP_I2C_F_FORCE); + if (value < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value & mask) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + info->caps = ONLP_PSU_CAPS_AC; + + /* Get power good status + */ + mask = 1 << ((pid-1) * 4 + 1); + if (!(value & mask)) { + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + + /* Get input output power status + */ + value = (pid == PSU1_ID) ? 0x2 : 0x1; /* mux channel for psu */ + if (bmc_i2c_writeb(7, 0x70, 0, value) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* Read vin */ + addr = (pid == PSU1_ID) ? 0x59 : 0x5a; + value = bmc_i2c_readw(7, addr, 0x88); + if (value >= 0) { + info->mvin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_VIN; + } + + /* Read iin */ + value = bmc_i2c_readw(7, addr, 0x89); + if (value >= 0) { + info->miin = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IIN; + } + + /* Get pin */ + if ((info->caps & ONLP_PSU_CAPS_VIN) && (info->caps & ONLP_PSU_CAPS_IIN)) { + info->mpin = info->mvin * info->miin / 1000; + info->caps |= ONLP_PSU_CAPS_PIN; + } + + /* Read iout */ + value = bmc_i2c_readw(7, addr, 0x8c); + if (value >= 0) { + info->miout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Read pout */ + value = bmc_i2c_readw(7, addr, 0x96); + if (value >= 0) { + info->mpout = pmbus_parse_literal_format(value); + info->caps |= ONLP_PSU_CAPS_POUT; + } + + /* Get vout */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_POUT) && info->miout != 0) { + info->mvout = info->mpout / info->miout * 1000; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get model name */ + return bmc_i2c_readraw(7, addr, 0x9a, info->model, sizeof(info->model)); +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sfpi.c new file mode 100644 index 00000000..62997ff5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sfpi.c @@ -0,0 +1,196 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100s_32x_log.h" + +#define BIT(i) (1 << (i)) +#define NUM_OF_SFP_PORT 32 +static const int sfp_bus_index[] = { + 3, 2, 5, 4, 7, 6, 9, 8, + 11, 10, 13, 12, 15, 14, 17, 16, + 19, 18, 21, 20, 23, 22, 25, 24, + 27, 26, 29, 28, 31, 30, 33, 32 +}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +static uint8_t +onlp_sfpi_reg_val_to_port_sequence(uint8_t value, int revert) +{ + int i; + uint8_t ret = 0; + + for (i = 0; i < 8; i++) { + if (i % 2) { + ret |= (value & BIT(i)) >> 1; + } + else { + ret |= (value & BIT(i)) << 1; + } + } + + return revert ? ~ret : ret; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus = (port < 16) ? 36 : 37; + int addr = (port < 16) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset; + + if (port < 8 || (port >= 16 && port <= 23)) { + offset = 0; + } + else { + offset = 1; + } + + present = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (present < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + present = onlp_sfpi_reg_val_to_port_sequence(present, 0); + return !(present & BIT(port % 8)); +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int i; + uint8_t bytes[4] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(bytes); i++) { + int bus = (i < 2) ? 36 : 37; + int addr = (i < 2) ? 0x22 : 0x23; /* pca9535 slave address */ + int offset = (i % 2); + + bytes[i] = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); + if (bytes[i] < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + bytes[i] = onlp_sfpi_reg_val_to_port_sequence(bytes[i], 1); + } + + /* Convert to 32 bit integer in port order */ + i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_OK; +} + +static int +sfpi_eeprom_read(int port, uint8_t devaddr, uint8_t data[256]) +{ + memset(data, 0, 256); + int bus = sfp_bus_index[port]; + return onlp_i2c_read(bus, devaddr, 0, 256, data, ONLP_I2C_F_FORCE); + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x50, data); +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + return sfpi_eeprom_read(port, 0x51, data); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sysi.c new file mode 100644 index 00000000..d7140744 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/sysi.c @@ -0,0 +1,113 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_wedge100s_32x_int.h" +#include "x86_64_accton_wedge100s_32x_log.h" + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-wedge100s-32x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 8 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 2 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 5 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ +} + +int +onlp_sysi_platform_manage_fans(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/thermali.c new file mode 100644 index 00000000..7eccf4d0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/thermali.c @@ -0,0 +1,140 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/drivers/lm75/%s/temp1_input" + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "3-0048", + "3-0049", + "3-004a", + "3-004b", + "3-004c", + "8-0048", + "8-0049", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp1_input", + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "TMP75-1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "TMP75-2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "TMP75-3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "TMP75-4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "TMP75-5", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "TMP75-6", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_7_ON_MAIN_BROAD), "TMP75-7", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if (THERMAL_CPU_CORE == tid) { + return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + } + + /* get path */ + sprintf(path, THERMAL_PATH_FORMAT, directory[tid]); + if (bmc_file_read_int(&info->mcelsius, path, 10) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_config.c new file mode 100644 index 00000000..e650f13d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_config.c @@ -0,0 +1,76 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(_x) +x86_64_accton_wedge100s_32x_config_settings_t x86_64_accton_wedge100s_32x_config_settings[] = +{ +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_wedge100s_32x_config_STRINGIFY_VALUE +#undef __x86_64_accton_wedge100s_32x_config_STRINGIFY_NAME + +const char* +x86_64_accton_wedge100s_32x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_wedge100s_32x_config_settings[i].name; i++) { + if(!strcmp(x86_64_accton_wedge100s_32x_config_settings[i].name, setting)) { + return x86_64_accton_wedge100s_32x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_wedge100s_32x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_wedge100s_32x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_wedge100s_32x_config_settings[i].name, x86_64_accton_wedge100s_32x_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_enums.c new file mode 100644 index 00000000..48b694db --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_int.h new file mode 100644 index 00000000..09c66eaf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_wedge100s_32x Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100S_32X_INT_H__ +#define __X86_64_ACCTON_WEDGE100S_32X_INT_H__ + +#include + + +#endif /* __X86_64_ACCTON_WEDGE100S_32X_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.c new file mode 100644 index 00000000..139e3f61 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100s_32x_log.h" +/* + * x86_64_accton_wedge100s_32x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_WEDGE100S_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.h new file mode 100644 index 00000000..fe2a945d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_WEDGE100S_32X_LOG_H__ +#define __X86_64_ACCTON_WEDGE100S_32X_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_wedge100s_32x +#include + +#endif /* __X86_64_ACCTON_WEDGE100S_32X_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_module.c new file mode 100644 index 00000000..26a47d52 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_wedge100s_32x_log.h" + +static int +datatypes_init__(void) +{ +#define X86_64_ACCTON_WEDGE100S_32X_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_wedge100s_32x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_ucli.c new file mode 100644 index 00000000..5be4839b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/module/src/x86_64_accton_wedge100s_32x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_ACCTON_WEDGE100S_32X_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_wedge100s_32x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_wedge100s_32x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_wedge100s_32x_ucli_module__ = + { + "x86_64_accton_wedge100s_32x_ucli", + NULL, + x86_64_accton_wedge100s_32x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_wedge100s_32x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_wedge100s_32x_ucli_module__); + n = ucli_node_create("x86_64_accton_wedge100s_32x", NULL, &x86_64_accton_wedge100s_32x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_wedge100s_32x")); + return n; +} + +#else +void* +x86_64_accton_wedge100s_32x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/_make.mk b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/_make.mk new file mode 100644 index 00000000..a946c2ff --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/_make.mk @@ -0,0 +1,8 @@ +############################################################################### +# +# x86_64_accton_wedge100s_32x Unit Test Makefile. +# +############################################################################### +UMODULE := x86_64_accton_wedge100s_32x +UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/utest.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/main.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/main.c new file mode 100644 index 00000000..e5351a40 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/utest/main.c @@ -0,0 +1,19 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include +#include +#include +#include + +int aim_main(int argc, char* argv[]) +{ + printf("x86_64_accton_wedge100s_32x Utest Is Empty\n"); + x86_64_accton_wedge100s_32x_config_show(&aim_pvs_stdout); + return 0; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.doxy b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/x86_64_accton_wedge100s_32x.doxy new file mode 100644 index 00000000..e69de29b diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml index b72d94a8..1eb2632a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml @@ -1,11 +1,5 @@ --- -###################################################################### -# -# platform-config for WEDGE -# -###################################################################### - x86-64-accton-wedge100s-32x-r0: grub: @@ -17,8 +11,8 @@ x86-64-accton-wedge100s-32x-r0: --parity=0 --stop=1 - kernel: - <<: *kernel-4-9 + kernel: + <<: *kernel-3-16 args: >- nopat @@ -26,9 +20,4 @@ x86-64-accton-wedge100s-32x-r0: rd_NO_MD rd_NO_LUKS intel_iommu=off - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 + noapic diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py index 3ec4b68d..a8f653bc 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/python/x86_64_accton_wedge100s_32x_r0/__init__.py @@ -2,7 +2,20 @@ from onl.platform.base import * from onl.platform.accton import * class OnlPlatform_x86_64_accton_wedge100s_32x_r0(OnlPlatformAccton, - OnlPlatformPortConfig_32x100): - MODEL="Wedge-100s-32x" + OnlPlatformPortConfig_32x100): + MODEL="Wedge-100s-32X" PLATFORM="x86-64-accton-wedge100s-32x-r0" - SYS_OBJECT_ID=".100.2" + SYS_OBJECT_ID=".100.2.32.1" + + def baseconfig(self): + self.new_i2c_devices([ + ('pca9548', 0x70, 1), + ('pca9548', 0x71, 1), + ('pca9548', 0x72, 1), + ('pca9548', 0x73, 1), + ('pca9548', 0x74, 1), + + ('24c64', 0x50, 40), + ]) + + return True From b0e6ad22bd341a2b4db4ff27fb333f3ee00b7c50 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 28 Feb 2018 10:12:29 -0800 Subject: [PATCH 154/244] Add the 4.9 module package. --- builds/any/rootfs/jessie/common/amd64-base-packages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/builds/any/rootfs/jessie/common/amd64-base-packages.yml b/builds/any/rootfs/jessie/common/amd64-base-packages.yml index efaf425b..8b3ed88b 100644 --- a/builds/any/rootfs/jessie/common/amd64-base-packages.yml +++ b/builds/any/rootfs/jessie/common/amd64-base-packages.yml @@ -11,5 +11,6 @@ - hw-management - sx-kernel - onl-kernel-3.16-lts-x86-64-all-modules +- onl-kernel-4.9-lts-x86-64-all-modules - efibootmgr - gdisk From 63a7c293028c0657a6226759955f6a1946231c1e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 28 Feb 2018 10:15:24 -0800 Subject: [PATCH 155/244] AT24, CP2112, and GPIO updates. --- .../configs/x86_64-all/x86_64-all.config | 127 +++++++++++++++++- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index 612c7a07..70ad5059 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -1112,6 +1112,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 CONFIG_RFKILL=y CONFIG_RFKILL_LEDS=y CONFIG_RFKILL_INPUT=y +# CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set # CONFIG_CAIF is not set # CONFIG_CEPH_LIB is not set @@ -1222,9 +1223,9 @@ CONFIG_VIRTIO_BLK=y # # EEPROM support # -CONFIG_EEPROM_AT24=m -# CONFIG_EEPROM_AT25 is not set -# CONFIG_EEPROM_LEGACY is not set +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_AT25=y +CONFIG_EEPROM_LEGACY=y # CONFIG_EEPROM_MAX6875 is not set # CONFIG_EEPROM_93CX6 is not set # CONFIG_EEPROM_93XX46 is not set @@ -1233,6 +1234,7 @@ CONFIG_EEPROM_AT24=m # # Texas Instruments shared transport line discipline # +# CONFIG_TI_ST is not set # CONFIG_SENSORS_LIS3_I2C is not set # @@ -1855,8 +1857,11 @@ CONFIG_KEYBOARD_ATKBD=y # CONFIG_KEYBOARD_QT1070 is not set # CONFIG_KEYBOARD_QT2160 is not set # CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_GPIO is not set +# CONFIG_KEYBOARD_GPIO_POLLED is not set # CONFIG_KEYBOARD_TCA6416 is not set # CONFIG_KEYBOARD_TCA8418 is not set +# CONFIG_KEYBOARD_MATRIX is not set # CONFIG_KEYBOARD_LM8323 is not set # CONFIG_KEYBOARD_LM8333 is not set # CONFIG_KEYBOARD_MAX7359 is not set @@ -1887,6 +1892,7 @@ CONFIG_MOUSE_PS2_FOCALTECH=y # CONFIG_MOUSE_CYAPA is not set # CONFIG_MOUSE_ELAN_I2C is not set # CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set # CONFIG_MOUSE_SYNAPTICS_I2C is not set # CONFIG_MOUSE_SYNAPTICS_USB is not set CONFIG_INPUT_JOYSTICK=y @@ -1926,7 +1932,9 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y # CONFIG_TOUCHSCREEN_AD7877 is not set # CONFIG_TOUCHSCREEN_AD7879 is not set # CONFIG_TOUCHSCREEN_ATMEL_MXT is not set +# CONFIG_TOUCHSCREEN_AUO_PIXCIR is not set # CONFIG_TOUCHSCREEN_BU21013 is not set +# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set # CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set # CONFIG_TOUCHSCREEN_CYTTSP4_CORE is not set # CONFIG_TOUCHSCREEN_DYNAPRO is not set @@ -1934,6 +1942,7 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y # CONFIG_TOUCHSCREEN_EETI is not set # CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set # CONFIG_TOUCHSCREEN_FUJITSU is not set +# CONFIG_TOUCHSCREEN_GOODIX is not set # CONFIG_TOUCHSCREEN_ILI210X is not set # CONFIG_TOUCHSCREEN_GUNZE is not set # CONFIG_TOUCHSCREEN_EKTF2127 is not set @@ -1960,10 +1969,14 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y # CONFIG_TOUCHSCREEN_TSC2004 is not set # CONFIG_TOUCHSCREEN_TSC2005 is not set # CONFIG_TOUCHSCREEN_TSC2007 is not set +# CONFIG_TOUCHSCREEN_RM_TS is not set # CONFIG_TOUCHSCREEN_SILEAD is not set +# CONFIG_TOUCHSCREEN_SIS_I2C is not set # CONFIG_TOUCHSCREEN_ST1232 is not set +# CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set # CONFIG_TOUCHSCREEN_SX8654 is not set # CONFIG_TOUCHSCREEN_TPS6507X is not set +# CONFIG_TOUCHSCREEN_ZFORCE is not set # CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set CONFIG_INPUT_MISC=y # CONFIG_INPUT_AD714X is not set @@ -1973,6 +1986,10 @@ CONFIG_INPUT_MISC=y # CONFIG_INPUT_MMA8450 is not set # CONFIG_INPUT_MPU3050 is not set # CONFIG_INPUT_APANEL is not set +# CONFIG_INPUT_GP2A is not set +# CONFIG_INPUT_GPIO_BEEPER is not set +# CONFIG_INPUT_GPIO_TILT_POLLED is not set +# CONFIG_INPUT_GPIO_DECODER is not set # CONFIG_INPUT_ATLAS_BTNS is not set # CONFIG_INPUT_ATI_REMOTE2 is not set # CONFIG_INPUT_KEYSPAN_REMOTE is not set @@ -1982,10 +1999,12 @@ CONFIG_INPUT_MISC=y # CONFIG_INPUT_CM109 is not set # CONFIG_INPUT_UINPUT is not set # CONFIG_INPUT_PCF8574 is not set +# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set # CONFIG_INPUT_ADXL34X is not set # CONFIG_INPUT_IMS_PCU is not set # CONFIG_INPUT_CMA3000 is not set # CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set +# CONFIG_INPUT_DRV260X_HAPTICS is not set # CONFIG_INPUT_DRV2665_HAPTICS is not set # CONFIG_INPUT_DRV2667_HAPTICS is not set # CONFIG_RMI4_CORE is not set @@ -2074,6 +2093,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_SC16IS7XX is not set # CONFIG_SERIAL_ALTERA_JTAGUART is not set # CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_IFX6X60 is not set # CONFIG_SERIAL_ARC is not set # CONFIG_SERIAL_RP2 is not set # CONFIG_SERIAL_FSL_LPUART is not set @@ -2127,7 +2147,9 @@ CONFIG_I2C_MUX=y # # Multiplexer I2C Chip support # -# CONFIG_I2C_MUX_PCA9541 is not set +# CONFIG_I2C_MUX_GPIO is not set +CONFIG_I2C_MUX_PCA9541=y +CONFIG_I2C_MUX_PCA954x=y CONFIG_I2C_MUX_REG=y CONFIG_I2C_MUX_MLXCPLD=y CONFIG_I2C_HELPER_AUTO=y @@ -2165,7 +2187,9 @@ CONFIG_I2C_ISMT=y # # I2C system bus drivers (mostly embedded / system-on-chip) # +# CONFIG_I2C_CBUS_GPIO is not set # CONFIG_I2C_DESIGNWARE_PCI is not set +# CONFIG_I2C_GPIO is not set # CONFIG_I2C_OCORES is not set # CONFIG_I2C_PCA_PLATFORM is not set # CONFIG_I2C_PXA_PCI is not set @@ -2202,6 +2226,8 @@ CONFIG_SPI_MASTER=y # CONFIG_SPI_BITBANG is not set # CONFIG_SPI_CADENCE is not set # CONFIG_SPI_DESIGNWARE is not set +# CONFIG_SPI_GPIO is not set +# CONFIG_SPI_OC_TINY is not set # CONFIG_SPI_PXA2XX is not set # CONFIG_SPI_PXA2XX_PCI is not set # CONFIG_SPI_ROCKCHIP is not set @@ -2244,7 +2270,69 @@ CONFIG_PTP_1588_CLOCK=y # # Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. # -# CONFIG_GPIOLIB is not set +CONFIG_GPIOLIB=y +CONFIG_GPIO_ACPI=y +# CONFIG_DEBUG_GPIO is not set +# CONFIG_GPIO_SYSFS is not set + +# +# Memory mapped GPIO drivers +# +# CONFIG_GPIO_AMDPT is not set +# CONFIG_GPIO_DWAPB is not set +# CONFIG_GPIO_GENERIC_PLATFORM is not set +# CONFIG_GPIO_ICH is not set +# CONFIG_GPIO_LYNXPOINT is not set +# CONFIG_GPIO_MOCKUP is not set +# CONFIG_GPIO_VX855 is not set +# CONFIG_GPIO_ZX is not set + +# +# Port-mapped I/O GPIO drivers +# +# CONFIG_GPIO_F7188X is not set +# CONFIG_GPIO_IT87 is not set +# CONFIG_GPIO_SCH is not set +# CONFIG_GPIO_SCH311X is not set + +# +# I2C GPIO expanders +# +# CONFIG_GPIO_ADP5588 is not set +# CONFIG_GPIO_MAX7300 is not set +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set +# CONFIG_GPIO_SX150X is not set +# CONFIG_GPIO_TPIC2810 is not set +# CONFIG_GPIO_TS4900 is not set + +# +# MFD GPIO expanders +# + +# +# PCI GPIO expanders +# +# CONFIG_GPIO_AMD8111 is not set +# CONFIG_GPIO_BT8XX is not set +# CONFIG_GPIO_ML_IOH is not set +# CONFIG_GPIO_RDC321X is not set + +# +# SPI GPIO expanders +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MC33880 is not set +# CONFIG_GPIO_PISOSR is not set + +# +# SPI or I2C GPIO expanders +# + +# +# USB GPIO expanders +# # CONFIG_W1 is not set # CONFIG_POWER_AVS is not set # CONFIG_POWER_RESET is not set @@ -2262,9 +2350,15 @@ CONFIG_POWER_SUPPLY=y # CONFIG_BATTERY_MAX17042 is not set # CONFIG_CHARGER_MAX8903 is not set # CONFIG_CHARGER_LP8727 is not set +# CONFIG_CHARGER_GPIO is not set # CONFIG_CHARGER_BQ2415X is not set +# CONFIG_CHARGER_BQ24190 is not set +# CONFIG_CHARGER_BQ24257 is not set +# CONFIG_CHARGER_BQ24735 is not set +# CONFIG_CHARGER_BQ25890 is not set # CONFIG_CHARGER_SMB347 is not set # CONFIG_BATTERY_GAUGE_LTC2941 is not set +# CONFIG_CHARGER_RT9455 is not set CONFIG_HWMON=y # CONFIG_HWMON_VID is not set # CONFIG_HWMON_DEBUG_CHIP is not set @@ -2309,6 +2403,7 @@ CONFIG_HWMON=y # CONFIG_SENSORS_GL520SM is not set # CONFIG_SENSORS_G760A is not set # CONFIG_SENSORS_G762 is not set +# CONFIG_SENSORS_GPIO_FAN is not set # CONFIG_SENSORS_HIH6130 is not set # CONFIG_SENSORS_IBMAEM is not set # CONFIG_SENSORS_IBMPEX is not set @@ -2379,6 +2474,7 @@ CONFIG_SENSORS_TPS53679=y CONFIG_SENSORS_UCD9000=y CONFIG_SENSORS_UCD9200=y # CONFIG_SENSORS_ZL6100 is not set +# CONFIG_SENSORS_SHT15 is not set # CONFIG_SENSORS_SHT21 is not set # CONFIG_SENSORS_SHT3x is not set # CONFIG_SENSORS_SHTC1 is not set @@ -2496,6 +2592,7 @@ CONFIG_WATCHDOG=y # CONFIG_MACHZ_WDT is not set # CONFIG_SBC_EPX_C3_WATCHDOG is not set # CONFIG_NI903X_WDT is not set +# CONFIG_MEN_A21_WDT is not set # # PCI-based Watchdog Cards @@ -2531,6 +2628,7 @@ CONFIG_BCMA_POSSIBLE=y CONFIG_MFD_CORE=y # CONFIG_MFD_AS3711 is not set # CONFIG_PMIC_ADP5520 is not set +# CONFIG_MFD_AAT2870_CORE is not set # CONFIG_MFD_BCM590XX is not set # CONFIG_MFD_AXP20X_I2C is not set # CONFIG_MFD_CROS_EC is not set @@ -2546,8 +2644,10 @@ CONFIG_MFD_CORE=y # CONFIG_MFD_MC13XXX_SPI is not set # CONFIG_MFD_MC13XXX_I2C is not set # CONFIG_HTC_PASIC3 is not set +# CONFIG_HTC_I2CPLD is not set # CONFIG_LPC_ICH is not set CONFIG_LPC_SCH=y +# CONFIG_INTEL_SOC_PMIC is not set # CONFIG_MFD_INTEL_LPSS_ACPI is not set # CONFIG_MFD_INTEL_LPSS_PCI is not set # CONFIG_MFD_JANZ_CMODIO is not set @@ -2585,6 +2685,7 @@ CONFIG_LPC_SCH=y # CONFIG_MFD_LP8788 is not set # CONFIG_MFD_PALMAS is not set # CONFIG_TPS6105X is not set +# CONFIG_TPS65010 is not set # CONFIG_TPS6507X is not set # CONFIG_MFD_TPS65086 is not set # CONFIG_MFD_TPS65090 is not set @@ -2592,6 +2693,7 @@ CONFIG_LPC_SCH=y # CONFIG_MFD_TI_LP873X is not set # CONFIG_MFD_TPS65218 is not set # CONFIG_MFD_TPS6586X is not set +# CONFIG_MFD_TPS65910 is not set # CONFIG_MFD_TPS65912_I2C is not set # CONFIG_MFD_TPS65912_SPI is not set # CONFIG_MFD_TPS80031 is not set @@ -2724,6 +2826,7 @@ CONFIG_FB_EFI=y # CONFIG_FB_S3 is not set # CONFIG_FB_SAVAGE is not set # CONFIG_FB_SIS is not set +# CONFIG_FB_VIA is not set # CONFIG_FB_NEOMAGIC is not set # CONFIG_FB_KYRO is not set # CONFIG_FB_3DFX is not set @@ -2753,6 +2856,7 @@ CONFIG_BACKLIGHT_GENERIC=y # CONFIG_BACKLIGHT_ADP8860 is not set # CONFIG_BACKLIGHT_ADP8870 is not set # CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_GPIO is not set # CONFIG_BACKLIGHT_LV5207LP is not set # CONFIG_BACKLIGHT_BD6107 is not set # CONFIG_VGASTATE is not set @@ -2942,6 +3046,7 @@ CONFIG_HID_A4TECH=y # CONFIG_HID_ACRUX is not set CONFIG_HID_APPLE=y # CONFIG_HID_APPLEIR is not set +# CONFIG_HID_ASUS is not set # CONFIG_HID_AUREAL is not set CONFIG_HID_BELKIN=y # CONFIG_HID_BETOP_FF is not set @@ -2950,6 +3055,7 @@ CONFIG_HID_CHICONY=y # CONFIG_HID_CORSAIR is not set # CONFIG_HID_PRODIKEYS is not set # CONFIG_HID_CMEDIA is not set +CONFIG_HID_CP2112=y CONFIG_HID_CYPRESS=y # CONFIG_HID_DRAGONRISE is not set # CONFIG_HID_EMS_FF is not set @@ -3024,7 +3130,7 @@ CONFIG_USB_HIDDEV=y # # I2C HID support # -# CONFIG_I2C_HID is not set +CONFIG_I2C_HID=y # # Intel ISH HID support @@ -3155,6 +3261,7 @@ CONFIG_USB_STORAGE=y # # CONFIG_USB_PHY is not set # CONFIG_NOP_USB_XCEIV is not set +# CONFIG_USB_GPIO_VBUS is not set # CONFIG_USB_ISP1301 is not set # CONFIG_USB_GADGET is not set # CONFIG_USB_LED_TRIG is not set @@ -3172,7 +3279,9 @@ CONFIG_LEDS_CLASS=y # CONFIG_LEDS_LM3530 is not set # CONFIG_LEDS_LM3642 is not set # CONFIG_LEDS_PCA9532 is not set +# CONFIG_LEDS_GPIO is not set # CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_LP3952 is not set # CONFIG_LEDS_LP5521 is not set # CONFIG_LEDS_LP5523 is not set # CONFIG_LEDS_LP5562 is not set @@ -3184,6 +3293,7 @@ CONFIG_LEDS_CLASS=y # CONFIG_LEDS_DAC124S085 is not set # CONFIG_LEDS_BD2802 is not set # CONFIG_LEDS_INTEL_SS4200 is not set +# CONFIG_LEDS_LT3593 is not set # CONFIG_LEDS_TCA6507 is not set # CONFIG_LEDS_TLC591XX is not set # CONFIG_LEDS_LM355x is not set @@ -3207,6 +3317,7 @@ CONFIG_LEDS_TRIGGER_TIMER=y # CONFIG_LEDS_TRIGGER_HEARTBEAT is not set # CONFIG_LEDS_TRIGGER_BACKLIGHT is not set # CONFIG_LEDS_TRIGGER_CPU is not set +# CONFIG_LEDS_TRIGGER_GPIO is not set # CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set # @@ -3620,6 +3731,7 @@ CONFIG_MAX1363=y # Humidity sensors # # CONFIG_AM2315 is not set +# CONFIG_DHT11 is not set # CONFIG_HDC100X is not set # CONFIG_HTU21 is not set # CONFIG_SI7005 is not set @@ -3671,6 +3783,8 @@ CONFIG_MAX1363=y # # Magnetometer sensors # +# CONFIG_AK8975 is not set +# CONFIG_AK09911 is not set # CONFIG_BMC150_MAGN_I2C is not set # CONFIG_BMC150_MAGN_SPI is not set # CONFIG_MAG3110 is not set @@ -4157,6 +4271,7 @@ CONFIG_PROBE_EVENTS=y # CONFIG_RING_BUFFER_BENCHMARK is not set # CONFIG_RING_BUFFER_STARTUP_TEST is not set # CONFIG_TRACE_ENUM_MAP_FILE is not set +CONFIG_TRACING_EVENTS_GPIO=y # # Runtime Testing From a303ece05cfd6e1f219b051ff03184fb40f43d1b Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 28 Feb 2018 10:16:44 -0800 Subject: [PATCH 156/244] Move the Wedge100S to kernel 4.9. --- .../r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml index 1eb2632a..64da395f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/platform-config/r0/src/lib/x86-64-accton-wedge100s-32x-r0.yml @@ -12,7 +12,7 @@ x86-64-accton-wedge100s-32x-r0: --stop=1 kernel: - <<: *kernel-3-16 + <<: *kernel-4-9 args: >- nopat From 867ac4152f977aa6442337088d004f33d52fb019 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 28 Feb 2018 10:36:51 -0800 Subject: [PATCH 157/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 751d0b2a..5a031a2f 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 751d0b2a603a184626f412e120532559dedf6c7d +Subproject commit 5a031a2f0ffd06e5b018fd2a101d54f46b3f2465 From 03f066d45cb2925edc7e62276a3c072ec0a2880c Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 28 Feb 2018 17:41:08 -0800 Subject: [PATCH 158/244] Be more aggressive with the manifest --- make/rfs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/rfs.mk b/make/rfs.mk index c3741bae..17002059 100644 --- a/make/rfs.mk +++ b/make/rfs.mk @@ -33,7 +33,7 @@ RFS_MANIFEST := etc/onl/rootfs/manifest.json endif RFS: - $(ONL_V_at) rm -rf manifest.json + $(ONL_V_at) sudo rm -rf manifest.json $(ONL_V_at) $(RFS_COMMAND) $(ONL_V_at) [ -f $(RFS_DIR)/$(RFS_MANIFEST) ] && cp $(RFS_DIR)/$(RFS_MANIFEST) . From 7aa876cda471aadcd8042a02c0a56664a337cca0 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 28 Feb 2018 17:41:16 -0800 Subject: [PATCH 159/244] Enable the --lookup feature --- tools/onlpm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/onlpm.py b/tools/onlpm.py index deaad7c7..b1bcfb7d 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -1345,6 +1345,11 @@ if __name__ == '__main__': if ops.delete: pm.opr.remove_packages(ops.delete) + if ops.lookup: + logger.debug("looking up %s", ops.lookup) + for p in pm.opr.lookup_all(ops.lookup): + print p + except (OnlPackageError, onlyaml.OnlYamlError), e: logger.error(e) sys.exit(1) From 55615155b3184fdd88f3b6d1a1669ab89332bc86 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 28 Feb 2018 17:41:46 -0800 Subject: [PATCH 160/244] Incremental update/install support - also add a '--no-configure' flag --- tools/onlrfs.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 4 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index 96c4c2f5..2f471ea0 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -376,12 +376,9 @@ rm -f /usr/sbin/policy-rc.d onlu.execute("sudo mount -t proc proc %s" % os.path.join(dir_, "proc"), ex=OnlRfsError("Could not mount proc in new filesystem.")) - script = os.path.join(dir_, "tmp/configure.sh") - if not os.getenv('NO_DPKG_CONFIGURE'): self.dpkg_configure(dir_) - os_release = os.path.join(dir_, 'etc', 'os-release') if os.path.exists(os_release): # Convert /etc/os-release to /etc/os-release.json @@ -559,6 +556,76 @@ rm -f /usr/sbin/policy-rc.d finally: onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc"))) + def update(self, dir_, packages): + + ONLPM = "%s/tools/onlpm.py" % os.getenv('ONL') + + try: + + onlu.execute("sudo mount -t devtmpfs dev %s" % os.path.join(dir_, "dev"), + ex=OnlRfsError("Could not mount dev in new filesystem.")) + + onlu.execute("sudo mount -t proc proc %s" % os.path.join(dir_, "proc"), + ex=OnlRfsError("Could not mount proc in new filesystem.")) + + for pspec in packages: + for pkg in pspec.split(','): + logger.info("updating %s into %s", pkg, dir_) + cmd = (ONLPM, '--verbose', + '--sudo', + '--extract-dir', pkg, dir_,) + onlu.execute(cmd, + ex=OnlRfsError("update of %s failed" % pkg)) + + finally: + onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc"))) + + def install(self, dir_, packages): + + ONLPM = "%s/tools/onlpm.py" % os.getenv('ONL') + + try: + + onlu.execute("sudo mount -t devtmpfs dev %s" % os.path.join(dir_, "dev"), + ex=OnlRfsError("Could not mount dev in new filesystem.")) + + onlu.execute("sudo mount -t proc proc %s" % os.path.join(dir_, "proc"), + ex=OnlRfsError("Could not mount proc in new filesystem.")) + + for pspec in packages: + for pkg in pspec.split(','): + + cmd = (ONLPM, '--lookup', pkg,) + try: + buf = subprocess.check_output(cmd) + except subprocess.CalledProcessError as ex: + logger.error("cannot find %s", pkg) + raise ValueError("update failed") + + if not buf.strip(): + raise ValueError("cannot find %s" % pkg) + src = buf.splitlines(False)[0] + d, b = os.path.split(src) + dst = os.path.join(dir_, "tmp", b) + shutil.copy2(src, dst) + src2 = os.path.join("/tmp", b) + + logger.info("installing %s into %s", pkg, dir_) + cmd = ('/usr/bin/rfs-dpkg', '-i', src2,) + onlu.execute(cmd, + chroot=dir_, + ex=OnlRfsError("install of %s failed" % pkg)) + + name, _, _ = pkg.partition(':') + logger.info("updating dependencies for %s", pkg) + cmd = ('/usr/bin/rfs-apt-get', '-f', 'install', name,) + onlu.execute(cmd, + chroot=dir_, + ex=OnlRfsError("install of %s failed" % pkg)) + + finally: + onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc"))) + if __name__ == '__main__': @@ -575,6 +642,11 @@ if __name__ == '__main__': ap.add_argument("--cpio") ap.add_argument("--squash") ap.add_argument("--enable-root") + + ap.add_argument("--no-configure", action='store_true') + ap.add_argument("--update", action='append') + ap.add_argument("--install", action='append') + ops = ap.parse_args() if ops.enable_root: @@ -627,7 +699,14 @@ if __name__ == '__main__': if not ops.no_multistrap and not os.getenv('NO_MULTISTRAP'): x.multistrap(ops.dir) - x.configure(ops.dir) + if not ops.no_configure and not os.getenv('NO_DPKG_CONFIGURE'): + x.configure(ops.dir) + + if ops.update: + x.update(ops.dir, ops.update) + + if ops.install: + x.install(ops.dir, ops.install) if ops.cpio: if onlu.execute("%s/tools/scripts/make-cpio.sh %s %s" % (os.getenv('ONL'), ops.dir, ops.cpio)) != 0: From 9094eb7dbe36c529c8b3a764d9f71cf3f26f2594 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 6 Mar 2018 16:15:47 +0800 Subject: [PATCH 161/244] [as7312-54x] Support PSU serial number --- .../onlp/builds/src/module/src/platform_lib.c | 27 +++++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 1 + .../onlp/builds/src/module/src/psui.c | 4 ++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c index 7d7d8d31..e820a63e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.c @@ -1,3 +1,5 @@ +#include +#include #include #include #include "platform_lib.h" @@ -173,3 +175,28 @@ int psu_ym2651y_pmbus_info_set(int id, char *node, int value) return ONLP_STATUS_OK; } + +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h index 7fb175b0..2f0ad8c9 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/platform_lib.h @@ -72,6 +72,7 @@ typedef enum psu_type { } psu_type_t; psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); //#define DEBUG_MODE 1 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/psui.c index 77074bb8..006402d6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/psui.c @@ -102,7 +102,9 @@ psu_ym2651y_info_get(onlp_psu_info_t* info) if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { info->mpout = val; info->caps |= ONLP_PSU_CAPS_POUT; - } + } + + psu_serial_number_get(index, info->serial, sizeof(info->serial)); return ONLP_STATUS_OK; } From 6eacf04db4dfb32a41ed488fae1fa4fe6ab1e322 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 6 Mar 2018 16:18:52 +0800 Subject: [PATCH 162/244] [as5912-54x] Support PSU serial number --- .../onlp/builds/src/module/src/platform_lib.c | 24 +++++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 1 + .../onlp/builds/src/module/src/psui.c | 4 +++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.c index b14867bd..a79bb0b0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.c @@ -200,3 +200,27 @@ int psu_ym2651y_pmbus_info_set(int id, char *node, int value) return ONLP_STATUS_OK; } +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.h index 24242bfb..97163cad 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/platform_lib.h @@ -67,6 +67,7 @@ typedef enum psu_type { } psu_type_t; psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); enum onlp_thermal_id { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/psui.c index 6da5aa58..7beedeb5 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/psui.c @@ -101,7 +101,9 @@ psu_ym2651y_info_get(onlp_psu_info_t* info) if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { info->mpout = val; info->caps |= ONLP_PSU_CAPS_POUT; - } + } + + psu_serial_number_get(index, info->serial, sizeof(info->serial)); return ONLP_STATUS_OK; } From 07e8ad4013d28f7dad108c6c8707b9a486e8cafb Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 6 Mar 2018 16:21:35 +0800 Subject: [PATCH 163/244] [as7712-32x] Support PSU serial number --- .../onlp/builds/src/module/src/platform_lib.c | 27 +++++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 1 + .../onlp/builds/src/module/src/psui.c | 2 ++ 3 files changed, 30 insertions(+) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.c index b4ef2d04..ea139ae7 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.c @@ -23,6 +23,8 @@ * * ***********************************************************/ +#include +#include #include #include #include @@ -198,3 +200,28 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) return PSU_TYPE_UNKNOWN; } + +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.h index 10c3f8d6..a1e32542 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/platform_lib.h @@ -64,6 +64,7 @@ typedef enum psu_type { } psu_type_t; psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); #define DEBUG_MODE 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/psui.c index 88c02f03..9a1a1436 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/psui.c @@ -128,6 +128,8 @@ psu_ym2651_info_get(onlp_psu_info_t* info) info->caps |= ONLP_PSU_CAPS_POUT; } + psu_serial_number_get(index, info->serial, sizeof(info->serial)); + return ONLP_STATUS_OK; } From 09633ae72c8fba069d0e90f174c0124e36a35582 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 6 Mar 2018 16:24:44 +0800 Subject: [PATCH 164/244] [as7716-32x] Support PSU serial number --- .../onlp/builds/src/module/src/platform_lib.c | 27 +++++++++++++++++++ .../onlp/builds/src/module/src/platform_lib.h | 1 + .../onlp/builds/src/module/src/psui.c | 2 ++ 3 files changed, 30 insertions(+) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.c index b4ef2d04..ea139ae7 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.c @@ -23,6 +23,8 @@ * * ***********************************************************/ +#include +#include #include #include #include @@ -198,3 +200,28 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) return PSU_TYPE_UNKNOWN; } + +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.h index 6c88df33..d6d367ed 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/platform_lib.h @@ -64,6 +64,7 @@ typedef enum psu_type { } psu_type_t; psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); #define DEBUG_MODE 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/psui.c index 562901d2..f12f6e8e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/psui.c @@ -128,6 +128,8 @@ psu_ym2651_info_get(onlp_psu_info_t* info) info->caps |= ONLP_PSU_CAPS_POUT; } + psu_serial_number_get(index, info->serial, sizeof(info->serial)); + return ONLP_STATUS_OK; } From 60b4db8f82514ff4f230708457f35c1e89b24ac1 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 6 Mar 2018 17:15:56 +0000 Subject: [PATCH 165/244] Remove dead module definition. --- .../x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module | 1 - 1 file changed, 1 deletion(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module deleted file mode 100644 index 91bd6c78..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_accton_wedge100s_32x From eafbd5c95e028873adbd728206567cf3e6084a35 Mon Sep 17 00:00:00 2001 From: roylee123 Date: Wed, 7 Mar 2018 04:02:47 +0000 Subject: [PATCH 166/244] [accton] add new platform x86-64-accton-as5916-54xk. Signed-off-by: roylee123 --- .../x86-64-accton-as5916-54xk/.gitignore | 2 + .../x86-64/x86-64-accton-as5916-54xk/Makefile | 1 + .../modules/Makefile | 1 + .../x86-64-accton-as5916-54xk/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as5916-54xk-fan.c | 485 ++++++ .../builds/x86-64-accton-as5916-54xk-leds.c | 386 +++++ .../builds/x86-64-accton-as5916-54xk-psu.c | 288 ++++ .../builds/x86-64-accton-as5916-54xk-sfp.c | 1315 +++++++++++++++++ .../x86-64-accton-as5916-54xk/onlp/Makefile | 1 + .../x86-64-accton-as5916-54xk/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../module/auto/x86_64_accton_as5916_54xk.yml | 50 + .../x86_64_accton_as5916_54xk.x | 14 + .../x86_64_accton_as5916_54xk_config.h | 137 ++ .../x86_64_accton_as5916_54xk_dox.h | 26 + .../x86_64_accton_as5916_54xk_porting.h | 107 ++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 303 ++++ .../onlp/builds/src/module/src/ledi.c | 247 ++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 124 ++ .../onlp/builds/src/module/src/platform_lib.h | 89 ++ .../onlp/builds/src/module/src/psui.c | 177 +++ .../onlp/builds/src/module/src/sfpi.c | 287 ++++ .../onlp/builds/src/module/src/sysi.c | 339 +++++ .../onlp/builds/src/module/src/thermali.c | 128 ++ .../src/x86_64_accton_as5916_54xk_config.c | 80 + .../src/x86_64_accton_as5916_54xk_enums.c | 10 + .../src/x86_64_accton_as5916_54xk_int.h | 12 + .../src/x86_64_accton_as5916_54xk_log.c | 18 + .../src/x86_64_accton_as5916_54xk_log.h | 12 + .../src/x86_64_accton_as5916_54xk_module.c | 24 + .../src/x86_64_accton_as5916_54xk_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r1/Makefile | 1 + .../platform-config/r1/PKG.yml | 1 + .../src/lib/x86-64-accton-as5916-54xk-r1.yml | 33 + .../x86_64_accton_as5916_54xk_r1/__init__.py | 72 + 47 files changed, 4976 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore new file mode 100644 index 00000000..2e2944b3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore @@ -0,0 +1,2 @@ +*x86*64*accton*as5916*54x*.mk +onlpdump.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml new file mode 100644 index 00000000..b6c16c5e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as5916-54x ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile new file mode 100644 index 00000000..0ae14eaa --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as5916-54x +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c new file mode 100644 index 00000000..e69660e4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c @@ -0,0 +1,485 @@ +/* + * A hwmon driver for the Accton as5916 54x fan + * + * Copyright (C) 2016 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_54x_fan" +#define MAX_FAN_SPEED_RPM 25500 + +static struct as5916_54x_fan_data *as5916_54x_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x0F, /* fan 1-6 present status */ + 0x10, /* fan 1-6 direction(0:B2F 1:F2B) */ + 0x11, /* fan PWM(for all fan) */ + 0x12, /* front fan 1 speed(rpm) */ + 0x13, /* front fan 2 speed(rpm) */ + 0x14, /* front fan 3 speed(rpm) */ + 0x15, /* front fan 4 speed(rpm) */ + 0x16, /* front fan 5 speed(rpm) */ + 0x17, /* front fan 6 speed(rpm) */ + 0x22, /* rear fan 1 speed(rpm) */ + 0x23, /* rear fan 2 speed(rpm) */ + 0x24, /* rear fan 3 speed(rpm) */ + 0x25, /* rear fan 4 speed(rpm) */ + 0x26, /* rear fan 5 speed(rpm) */ + 0x27, /* rear fan 6 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as5916_54x_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID, + FAN5_ID, + FAN6_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DIRECTION_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN5_FRONT_SPEED_RPM, + FAN6_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN5_REAR_SPEED_RPM, + FAN6_REAR_SPEED_RPM, + FAN1_DIRECTION, + FAN2_DIRECTION, + FAN3_DIRECTION, + FAN4_DIRECTION, + FAN5_DIRECTION, + FAN6_DIRECTION, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN6_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT, + FAN5_FAULT, + FAN6_FAULT, + FAN_MAX_RPM +}; + +/* Define attributes + */ +#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 + +#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr + +static SENSOR_DEVICE_ATTR(fan_max_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN_MAX_RPM); +#define DECLARE_FAN_MAX_RPM_ATTR(index) &sensor_dev_attr_fan_max_speed_rpm.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); +/* 6 fan direction attribute in this platform */ +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); + +static struct attribute *as5916_54x_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_FAULT_ATTR(4), + DECLARE_FAN_FAULT_ATTR(5), + DECLARE_FAN_FAULT_ATTR(6), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(4), + DECLARE_FAN_SPEED_RPM_ATTR(5), + DECLARE_FAN_SPEED_RPM_ATTR(6), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(5), + DECLARE_FAN_PRESENT_ATTR(6), + DECLARE_FAN_DIRECTION_ATTR(1), + DECLARE_FAN_DIRECTION_ATTR(2), + DECLARE_FAN_DIRECTION_ATTR(3), + DECLARE_FAN_DIRECTION_ATTR(4), + DECLARE_FAN_DIRECTION_ATTR(5), + DECLARE_FAN_DIRECTION_ATTR(6), + DECLARE_FAN_DUTY_CYCLE_ATTR(), + DECLARE_FAN_MAX_RPM_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as5916_54x_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as5916_54x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val+1) * 625 + 75)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + return ((u32)duty_cycle * 100 / 625) - 1; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + return !!(reg_val & BIT(id)); +} + +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + return !(reg_val & BIT(id)); +} + +static u8 is_fan_fault(struct as5916_54x_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as5916_54x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as5916_54x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5916_54x_fan_data *data = as5916_54x_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN5_FRONT_SPEED_RPM: + case FAN6_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + case FAN5_REAR_SPEED_RPM: + case FAN6_REAR_SPEED_RPM: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + case FAN6_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + case FAN5_FAULT: + case FAN6_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIRECTION: + case FAN2_DIRECTION: + case FAN3_DIRECTION: + case FAN4_DIRECTION: + case FAN5_DIRECTION: + case FAN6_DIRECTION: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], + attr->index - FAN1_DIRECTION)); + break; + case FAN_MAX_RPM: + ret = sprintf(buf, "%d\n", MAX_FAN_SPEED_RPM); + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as5916_54x_fan_group = { + .attrs = as5916_54x_fan_attributes, +}; + +static struct as5916_54x_fan_data *as5916_54x_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54x_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as5916_54x_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as5916_54x_fan_read_value(client, fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as5916_54x_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as5916_54x_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as5916_54x_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5916_54x_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as5916_54x_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as5916_54x_fan_remove(struct i2c_client *client) +{ + struct as5916_54x_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as5916_54x_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; + +static const struct i2c_device_id as5916_54x_fan_id[] = { + { "as5916_54x_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as5916_54x_fan_id); + +static struct i2c_driver as5916_54x_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as5916_54x_fan_probe, + .remove = as5916_54x_fan_remove, + .id_table = as5916_54x_fan_id, + .address_list = normal_i2c, +}; + +static int __init as5916_54x_fan_init(void) +{ + return i2c_add_driver(&as5916_54x_fan_driver); +} + +static void __exit as5916_54x_fan_exit(void) +{ + i2c_del_driver(&as5916_54x_fan_driver); +} + +module_init(as5916_54x_fan_init); +module_exit(as5916_54x_fan_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as5916_54x_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c new file mode 100644 index 00000000..7f55dae7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c @@ -0,0 +1,386 @@ +/* + * A LED driver for the accton_as5916_54x_led + * + * Copyright (C) 2016 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "accton_as5916_54x_led" + +#define DEBUG_MODE 1 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +struct accton_as5916_54x_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[2]; /* Register value, 0 = RELEASE/DIAG LED, + 1 = FAN/PSU LED, + 2 ~ 4 = SYSTEM LED */ +}; + +static struct accton_as5916_54x_led_data *ledctl = NULL; + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x0C) +#define LED_MODE_DIAG_GREEN_VALUE (0x04) +#define LED_MODE_DIAG_ORANGE_VALUE (0x08) +#define LED_MODE_DIAG_OFF_VALUE (0x0C) + + +#define LED_TYPE_LOC_REG_MASK (0x10) +#define LED_MODE_LOC_ORANGE_VALUE (0x00) +#define LED_MODE_LOC_OFF_VALUE (0x10) + +static const u8 led_reg[] = { + 0x65, /* LOC/DIAG/FAN LED */ + 0x66, /* PSU LED */ +}; + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +/* FAN/PSU/DIAG/RELEASE led mode */ +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +struct led_type_mode { + enum led_type type; + enum led_light_mode mode; + int type_mask; + int mode_value; +}; + +static struct led_type_mode led_type_mode_data[] = { +{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE}, +{LED_TYPE_LOC, LED_MODE_ORANGE, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_ORANGE_VALUE}, +{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE}, +{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE}, +{LED_TYPE_DIAG, LED_MODE_ORANGE, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_ORANGE_VALUE}, +}; + +static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + if (type != led_type_mode_data[i].type) { + continue; + } + + if ((led_type_mode_data[i].type_mask & reg_val) == + led_type_mode_data[i].mode_value) { + return led_type_mode_data[i].mode; + } + } + + return LED_MODE_UNKNOWN; +} + +static u8 led_light_mode_to_reg_val(enum led_type type, + enum led_light_mode mode, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + int type_mask, mode_value; + + if (type != led_type_mode_data[i].type) + continue; + + if (mode != led_type_mode_data[i].mode) + continue; + + type_mask = led_type_mode_data[i].type_mask; + mode_value = led_type_mode_data[i].mode_value; + reg_val = (reg_val & ~type_mask) | mode_value; + } + + return reg_val; +} + +static int accton_as5916_54x_led_read_value(u8 reg) +{ + return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); +} + +static int accton_as5916_54x_led_write_value(u8 reg, u8 value) +{ + return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); +} + +static void accton_as5916_54x_led_update(void) +{ + mutex_lock(&ledctl->update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as5916_54x_led update\n"); + ledctl->valid = 0; + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as5916_54x_led_read_value(led_reg[i]); + + if (status < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); + goto exit; + } + else + ledctl->reg_val[i] = status; + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as5916_54x_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + u8 reg, enum led_type type) +{ + int reg_val; + + mutex_lock(&ledctl->update_lock); + reg_val = accton_as5916_54x_led_read_value(reg); + + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + accton_as5916_54x_led_write_value(reg, reg_val); + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as7312_54x_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness accton_as7312_54x_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static void accton_as5916_54x_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as5916_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_DIAG); +} + +static enum led_brightness accton_as5916_54x_led_diag_get(struct led_classdev *cdev) +{ + accton_as5916_54x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static enum led_brightness accton_as5916_54x_led_loc_get(struct led_classdev *cdev) +{ + accton_as5916_54x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void accton_as5916_54x_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as5916_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_LOC); +} + +static struct led_classdev accton_as5916_54x_leds[] = { + [LED_TYPE_LOC] = { + .name = "accton_as5916_54x_led::loc", + .default_trigger = "unused", + .brightness_set = accton_as5916_54x_led_loc_set, + .brightness_get = accton_as5916_54x_led_loc_get, + .max_brightness = LED_MODE_ORANGE, + }, + [LED_TYPE_DIAG] = { + .name = "accton_as5916_54x_led::diag", + .default_trigger = "unused", + .brightness_set = accton_as5916_54x_led_diag_set, + .brightness_get = accton_as5916_54x_led_diag_get, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_PSU1] = { + .name = "accton_as5916_54x_led::psu1", + .default_trigger = "unused", + .brightness_set = accton_as7312_54x_led_auto_set, + .brightness_get = accton_as7312_54x_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "accton_as5916_54x_led::psu2", + .default_trigger = "unused", + .brightness_set = accton_as7312_54x_led_auto_set, + .brightness_get = accton_as7312_54x_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_FAN] = { + .name = "accton_as5916_54x_led::fan", + .default_trigger = "unused", + .brightness_set = accton_as7312_54x_led_auto_set, + .brightness_get = accton_as7312_54x_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as5916_54x_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as5916_54x_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as5916_54x_leds[i]); + + if (ret < 0) { + break; + } + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as5916_54x_leds)){ + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as5916_54x_leds[i]); + } + } + + return ret; +} + +static int accton_as5916_54x_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as5916_54x_leds); i++) { + led_classdev_unregister(&accton_as5916_54x_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as5916_54x_led_driver = { + .probe = accton_as5916_54x_led_probe, + .remove = accton_as5916_54x_led_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as5916_54x_led_init(void) +{ + int ret; + + ret = platform_driver_register(&accton_as5916_54x_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as5916_54x_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + goto exit_driver; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + goto exit_free; + } + + return 0; + +exit_free: + kfree(ledctl); +exit_driver: + platform_driver_unregister(&accton_as5916_54x_led_driver); +exit: + return ret; +} + +static void __exit accton_as5916_54x_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as5916_54x_led_driver); + kfree(ledctl); +} + +late_initcall(accton_as5916_54x_led_init); +module_exit(accton_as5916_54x_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as5916_54x_led driver"); +MODULE_LICENSE("GPL"); + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c new file mode 100644 index 00000000..4627df9c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c @@ -0,0 +1,288 @@ +/* + * An hwmon driver for accton as5916_54x Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static int as5916_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as5916_54x_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[9]; /* Model name, read from eeprom */ +}; + +static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *dev); + +enum as5916_54x_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as5916_54x_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5916_54x_psu_data *data = as5916_54x_psu_update_device(dev); + u8 status = 0; + + if (attr->index == PSU_PRESENT) { + status = !(data->status & BIT(1 - data->index));; + } + else { /* PSU_POWER_GOOD */ + status = !!(data->status & BIT(3 - data->index)); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as5916_54x_psu_data *data = as5916_54x_psu_update_device(dev); + + return sprintf(buf, "%s\n", data->model_name); +} + +static const struct attribute_group as5916_54x_psu_group = { + .attrs = as5916_54x_psu_attributes, +}; + +static int as5916_54x_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as5916_54x_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as5916_54x_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5916_54x_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as5916_54x_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as5916_54x_psu_remove(struct i2c_client *client) +{ + struct as5916_54x_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as5916_54x_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as5916_54x_psu1, + as5916_54x_psu2 +}; + +static const struct i2c_device_id as5916_54x_psu_id[] = { + { "as5916_54x_psu1", as5916_54x_psu1 }, + { "as5916_54x_psu2", as5916_54x_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as5916_54x_psu_id); + +static struct i2c_driver as5916_54x_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as5916_54x_psu", + }, + .probe = as5916_54x_psu_probe, + .remove = as5916_54x_psu_remove, + .id_table = as5916_54x_psu_id, + .address_list = normal_i2c, +}; + +static int as5916_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54x_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as5916_54x update\n"); + + /* Read psu status */ + status = accton_i2c_cpld_read(0x60, 0x2); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + power_good = data->status & BIT(3 - data->index); + + if (power_good) { + status = as5916_54x_psu_read_block(client, 0x20, data->model_name, + ARRAY_SIZE(data->model_name)-1); + + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int __init as5916_54x_psu_init(void) +{ + return i2c_add_driver(&as5916_54x_psu_driver); +} + +static void __exit as5916_54x_psu_exit(void) +{ + i2c_del_driver(&as5916_54x_psu_driver); +} + +module_init(as5916_54x_psu_init); +module_exit(as5916_54x_psu_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as5916_54x_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c new file mode 100644 index 00000000..c924772b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c @@ -0,0 +1,1315 @@ +/* + * SFP driver for accton as5916_54x sfp + * + * Copyright (C) Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "as5916_54x_sfp" /* Platform dependent */ + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 54 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 3 +#define I2C_RW_RETRY_INTERVAL 100 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) +#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8472_DIAG_MON_TYPE_ADDR 92 +#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 +#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 +#define SFF8472_10G_BASE_MASK 0xF0 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +/* Platform dependent +++ */ +#define I2C_ADDR_CPLD1 0x60 +#define I2C_ADDR_CPLD2 0x62 +/* Platform dependent --- */ + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL +}; + +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_port_type.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* SFP msa attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); +static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); +static struct attribute *sfp_msa_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_port_type.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + NULL +}; + +/* SFP ddm attributes for sysfs */ +static struct attribute *sfp_ddm_attributes[] = { + NULL +}; + +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +as5916_54x_sfp1, as5916_54x_sfp2, as5916_54x_sfp3, as5916_54x_sfp4, as5916_54x_sfp5, as5916_54x_sfp6, as5916_54x_sfp7, as5916_54x_sfp8, +as5916_54x_sfp9, as5916_54x_sfp10, as5916_54x_sfp11, as5916_54x_sfp12, as5916_54x_sfp13, as5916_54x_sfp14, as5916_54x_sfp15, as5916_54x_sfp16, +as5916_54x_sfp17, as5916_54x_sfp18, as5916_54x_sfp19, as5916_54x_sfp20, as5916_54x_sfp21, as5916_54x_sfp22, as5916_54x_sfp23, as5916_54x_sfp24, +as5916_54x_sfp25, as5916_54x_sfp26, as5916_54x_sfp27, as5916_54x_sfp28, as5916_54x_sfp29, as5916_54x_sfp30, as5916_54x_sfp31, as5916_54x_sfp32, +as5916_54x_sfp33, as5916_54x_sfp34, as5916_54x_sfp35, as5916_54x_sfp36, as5916_54x_sfp37, as5916_54x_sfp38, as5916_54x_sfp39, as5916_54x_sfp40, +as5916_54x_sfp41, as5916_54x_sfp42, as5916_54x_sfp43, as5916_54x_sfp44, as5916_54x_sfp45, as5916_54x_sfp46, as5916_54x_sfp47, as5916_54x_sfp48, +as5916_54x_sfp49, as5916_54x_sfp50, as5916_54x_sfp51, as5916_54x_sfp52, as5916_54x_sfp53, as5916_54x_sfp54 +}; + +static const struct i2c_device_id sfp_device_id[] = { +{ "as5916_54x_sfp1", as5916_54x_sfp1 }, { "as5916_54x_sfp2", as5916_54x_sfp2 }, { "as5916_54x_sfp3", as5916_54x_sfp3 }, { "as5916_54x_sfp4", as5916_54x_sfp4 }, +{ "as5916_54x_sfp5", as5916_54x_sfp5 }, { "as5916_54x_sfp6", as5916_54x_sfp6 }, { "as5916_54x_sfp7", as5916_54x_sfp7 }, { "as5916_54x_sfp8", as5916_54x_sfp8 }, +{ "as5916_54x_sfp9", as5916_54x_sfp9 }, { "as5916_54x_sfp10", as5916_54x_sfp10 }, { "as5916_54x_sfp11", as5916_54x_sfp11 }, { "as5916_54x_sfp12", as5916_54x_sfp12 }, +{ "as5916_54x_sfp13", as5916_54x_sfp13 }, { "as5916_54x_sfp14", as5916_54x_sfp14 }, { "as5916_54x_sfp15", as5916_54x_sfp15 }, { "as5916_54x_sfp16", as5916_54x_sfp16 }, +{ "as5916_54x_sfp17", as5916_54x_sfp17 }, { "as5916_54x_sfp18", as5916_54x_sfp18 }, { "as5916_54x_sfp19", as5916_54x_sfp19 }, { "as5916_54x_sfp20", as5916_54x_sfp20 }, +{ "as5916_54x_sfp21", as5916_54x_sfp21 }, { "as5916_54x_sfp22", as5916_54x_sfp22 }, { "as5916_54x_sfp23", as5916_54x_sfp23 }, { "as5916_54x_sfp24", as5916_54x_sfp24 }, +{ "as5916_54x_sfp25", as5916_54x_sfp25 }, { "as5916_54x_sfp26", as5916_54x_sfp26 }, { "as5916_54x_sfp27", as5916_54x_sfp27 }, { "as5916_54x_sfp28", as5916_54x_sfp28 }, +{ "as5916_54x_sfp29", as5916_54x_sfp29 }, { "as5916_54x_sfp30", as5916_54x_sfp30 }, { "as5916_54x_sfp31", as5916_54x_sfp31 }, { "as5916_54x_sfp32", as5916_54x_sfp32 }, +{ "as5916_54x_sfp33", as5916_54x_sfp33 }, { "as5916_54x_sfp34", as5916_54x_sfp34 }, { "as5916_54x_sfp35", as5916_54x_sfp35 }, { "as5916_54x_sfp36", as5916_54x_sfp36 }, +{ "as5916_54x_sfp37", as5916_54x_sfp37 }, { "as5916_54x_sfp38", as5916_54x_sfp38 }, { "as5916_54x_sfp39", as5916_54x_sfp39 }, { "as5916_54x_sfp40", as5916_54x_sfp40 }, +{ "as5916_54x_sfp41", as5916_54x_sfp41 }, { "as5916_54x_sfp42", as5916_54x_sfp42 }, { "as5916_54x_sfp43", as5916_54x_sfp43 }, { "as5916_54x_sfp44", as5916_54x_sfp44 }, +{ "as5916_54x_sfp45", as5916_54x_sfp45 }, { "as5916_54x_sfp46", as5916_54x_sfp46 }, { "as5916_54x_sfp47", as5916_54x_sfp47 }, { "as5916_54x_sfp48", as5916_54x_sfp48 }, +{ "as5916_54x_sfp49", as5916_54x_sfp49 }, { "as5916_54x_sfp50", as5916_54x_sfp50 }, { "as5916_54x_sfp51", as5916_54x_sfp51 }, { "as5916_54x_sfp52", as5916_54x_sfp52 }, +{ "as5916_54x_sfp53", as5916_54x_sfp53 }, { "as5916_54x_sfp54", as5916_54x_sfp54 }, +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +/* + * list of valid port types + * note OOM_PORT_TYPE_NOT_PRESENT to indicate no + * module is present in this port + */ +typedef enum oom_driver_port_type_e { + OOM_DRIVER_PORT_TYPE_INVALID, + OOM_DRIVER_PORT_TYPE_NOT_PRESENT, + OOM_DRIVER_PORT_TYPE_SFP, + OOM_DRIVER_PORT_TYPE_SFP_PLUS, + OOM_DRIVER_PORT_TYPE_QSFP, + OOM_DRIVER_PORT_TYPE_QSFP_PLUS, + OOM_DRIVER_PORT_TYPE_QSFP28 +} oom_driver_port_type_t; + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct sfp_msa_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u64 status[6]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss + 3 => device id + 4 => 10G Ethernet Compliance Codes + to distinguish SFP or SFP+ + 5 => DIAGNOSTIC MONITORING TYPE */ + struct eeprom_data eeprom; +}; + +struct sfp_ddm_data { + struct eeprom_data eeprom; +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + oom_driver_port_type_t port_type; + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct sfp_msa_data *msa; + struct sfp_ddm_data *ddm; + struct qsfp_data *qsfp; + + struct i2c_client *client; +}; + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} + +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + int i = 0, j = 0, status = -1; + u8 reg; + unsigned short cpld_addr; + struct sfp_port_data *data = i2c_get_clientdata(client); + + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + data->present = 0; + + /* Read present status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 3; j++) { + cpld_addr = I2C_ADDR_CPLD1 + i*2; + reg = 0x10+j; + status = accton_i2c_cpld_read(cpld_addr, reg); + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); + data->present |= (u64)status << ((i*24) + (j%3)*8); + } + } + + /* Read present status of port 49-52(QSFP port) */ + cpld_addr = I2C_ADDR_CPLD2; + reg = 0x52; + status = accton_i2c_cpld_read(cpld_addr, reg); + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + else { + data->present |= (u64)(status & 0x3F) << 48; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0, j = 0; + int status = -1; + u8 tx_rx_regs[] = {0x14, 0x16, 0x18, 0x20, 0x22, 0x24, 0x30, 0x32, 0x34}; + + if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { + return data; + } + + DEBUG_PRINT("Starting as5916_54x sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->msa->valid = 0; + memset(data->msa->status, 0, sizeof(data->msa->status)); + + /* Read status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < ARRAY_SIZE(tx_rx_regs); j++) { + unsigned short cpld_addr = I2C_ADDR_CPLD1 + i*2; + + status = accton_i2c_cpld_read(cpld_addr, tx_rx_regs[j]); + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, tx_rx_regs[i], status); + goto exit; + } + + data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); + } + } + + data->msa->valid = 1; + data->msa->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + unsigned short cpld_addr = 0; + u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; + long disable; + int error; + u8 tx_disable_regs[] = {0x20, 0x22, 0x24}; + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_set_tx_disable(dev, da, buf, count); + } + + error = kstrtol(buf, 10, &disable); + if (error) { + return error; + } + + mutex_lock(&data->update_lock); + + if(data->port < 24) { + cpld_addr = I2C_ADDR_CPLD1; + cpld_reg = tx_disable_regs[data->port / 8]; + cpld_bit = 1 << (data->port % 8); + } + else { /* port 24 ~ 48 */ + cpld_addr = I2C_ADDR_CPLD2; + cpld_reg = tx_disable_regs[(data->port - 24) / 8]; + cpld_bit = 1 << (data->port % 8); + } + + /* Read current status */ + cpld_val = accton_i2c_cpld_read(cpld_addr, cpld_reg); + + /* Update tx_disable status */ + if (disable) { + data->msa->status[1] |= BIT_INDEX(data->port); + cpld_val |= cpld_bit; + } + else { + data->msa->status[1] &= ~BIT_INDEX(data->port); + cpld_val &= ~cpld_bit; + } + + accton_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); + mutex_unlock(&data->update_lock); + return count; +} + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ +} + +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + int i; + u8 values[7] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } + + /* Return values 1 -> 54 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5], + values[6] & 0x3F); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d\n", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *sfp_update_port_type(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + u8 buf = 0; + int status; + + mutex_lock(&data->update_lock); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + { + status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); + if (unlikely(status < 0)) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + if (buf != SFF8024_DEVICE_ID_SFP) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); + if (unlikely(status < 0)) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); + data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; + break; + } + case DRIVER_TYPE_QSFP: + { + status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); + if (unlikely(status < 0)) { + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); + switch (buf) { + case SFF8024_DEVICE_ID_QSFP: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; + break; + case SFF8024_DEVICE_ID_QSFP_PLUS: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; + break; + case SFF8024_DEVICE_ID_QSFP28: + data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; + break; + default: + data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; + break; + } + + break; + } + default: + break; + } + + mutex_unlock(&data->update_lock); + return data; +} + +static ssize_t show_port_type(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + if (!present) { + return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); + } + + sfp_update_port_type(dev); + return sprintf(buf, "%d\n", data->port_type); +} + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + data->qsfp->status[1] = disable & 0xF; + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + char ddm; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (status == 0) { + /* port is not present */ + return -ENODEV; + } + + status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); + if (unlikely(status < 0)) { + return status; + } + + return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); +} + +/* Platform dependent +++ */ +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 val = 0, index = 0; + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_show_tx_rx_status(dev, da, buf); + } + + data = sfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + if(attr->index == RX_LOS_ALL) { + int i = 0; + u8 values[6] = {0}; + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = (u8)(data->msa->status[2] >> (i * 8)); + } + + /** Return values 1 -> 48 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5]); + } + + switch (attr->index) { + case TX_FAULT: + index = 0; + break; + case TX_DISABLE: + index = 1; + break; + case RX_LOS: + index = 2; + break; + default: + return 0; + } + + val = !!(data->msa->status[index] & BIT_INDEX(data->port)); + return sprintf(buf, "%d\n", val); +} +/* Platform dependent --- */ +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} + + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + + return sfp_port_write(data, buf, off, count); +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + + return sfp_port_read(data, buf, off, count); +} + +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; + eeprom->size = EEPROM_SIZE; + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; + +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} + +static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_msa_data **data) +{ + int status; + struct sfp_msa_data *msa; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); + if (!msa) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = msa; + dev_info(&client->dev, "sfp msa '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); +exit_free: + kfree(msa); +exit: + + return status; +} + +static const struct attribute_group sfp_ddm_group = { + .attrs = sfp_ddm_attributes, +}; + +static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_ddm_data **data) +{ + int status; + struct sfp_ddm_data *ddm; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); + if (!ddm) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = ddm; + dev_info(&client->dev, "sfp ddm '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); +exit_free: + kfree(ddm); +exit: + + return status; +} + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); + if (status) { + goto exit_remove; + } + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct sfp_port_data *data = NULL; + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + + if (dev_id->driver_data >= as5916_54x_sfp1 && dev_id->driver_data <= as5916_54x_sfp48) { + if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { + data->driver_type = DRIVER_TYPE_SFP_MSA; + return sfp_msa_probe(client, dev_id, &data->msa); + } + else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { + data->driver_type = DRIVER_TYPE_SFP_DDM; + return sfp_ddm_probe(client, dev_id, &data->ddm); + } + } + else { /* as5916_54x_sfp49 ~ as5916_54x_sfp54 */ + if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { + data->driver_type = DRIVER_TYPE_QSFP; + return qsfp_probe(client, dev_id, &data->qsfp); + } + } + + return -ENODEV; +} +/* Platform dependent --- */ + +static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); + kfree(data); + return 0; +} + +static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); + kfree(data); + return 0; +} + +static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + return sfp_msa_remove(client, data->msa); + case DRIVER_TYPE_SFP_DDM: + return sfp_ddm_remove(client, data->ddm); + case DRIVER_TYPE_QSFP: + return qfp_remove(client, data->qsfp); + } + + return 0; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as5916_54x_sfp driver"); +MODULE_LICENSE("GPL"); + +late_initcall(sfp_init); +module_exit(sfp_exit); + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml new file mode 100644 index 00000000..ee1812ff --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-revision.yml PLATFORM=x86-64-accton-as5916-54x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu REVISION=r1 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile new file mode 100644 index 00000000..1f155bfc --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as5916-54x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as5916_54x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as5916-54x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..0c41fbc0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as5916_54x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module new file mode 100644 index 00000000..b7e5840e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as5916_54x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile new file mode 100644 index 00000000..10f71d72 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_as5916_54x +AUTOMODULE := x86_64_accton_as5916_54x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README new file mode 100644 index 00000000..64864843 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as5916_54x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..9db4a259 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_as5916_54x Autogeneration +# +############################################################################### +x86_64_accton_as5916_54x_AUTO_DEFS := module/auto/x86_64_accton_as5916_54x.yml +x86_64_accton_as5916_54x_AUTO_DIRS := module/inc/x86_64_accton_as5916_54x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml new file mode 100644 index 00000000..987f682f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_accton_as5916_54x Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_AS5916_54X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as5916_54x_config + + portingmacro: + x86_64_accton_as5916_54x: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x new file mode 100644 index 00000000..7776b59e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h new file mode 100644 index 00000000..43572880 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as5916_54x Configuration Header + * + * @addtogroup x86_64_accton_as5916_54x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_54X_CONFIG_H__ +#define __X86_64_ACCTON_AS5916_54X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_AS5916_54X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as5916_54x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as5916_54x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as5916_54x_config_settings table. */ +extern x86_64_accton_as5916_54x_config_settings_t x86_64_accton_as5916_54x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as5916_54x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as5916_54x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as5916_54x_porting.h" + +#endif /* __X86_64_ACCTON_AS5916_54X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h new file mode 100644 index 00000000..67e69645 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as5916_54x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_54X_DOX_H__ +#define __X86_64_ACCTON_AS5916_54X_DOX_H__ + +/** + * @defgroup x86_64_accton_as5916_54x x86_64_accton_as5916_54x - x86_64_accton_as5916_54x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as5916_54x-x86_64_accton_as5916_54x Public Interface + * @defgroup x86_64_accton_as5916_54x-config Compile Time Configuration + * @defgroup x86_64_accton_as5916_54x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_AS5916_54X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h new file mode 100644 index 00000000..e7dcddc8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as5916_54x Porting Macros. + * + * @addtogroup x86_64_accton_as5916_54x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_54X_PORTING_H__ +#define __X86_64_ACCTON_AS5916_54X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_as5916_54x_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_as5916_54x_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_MALLOC malloc + #else + #error The macro x86_64_accton_as5916_54x_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_as5916_54x_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_FREE free + #else + #error The macro x86_64_accton_as5916_54x_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_as5916_54x_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_MEMSET memset + #else + #error The macro x86_64_accton_as5916_54x_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_as5916_54x_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_MEMCPY memcpy + #else + #error The macro x86_64_accton_as5916_54x_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_as5916_54x_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_STRNCPY strncpy + #else + #error The macro x86_64_accton_as5916_54x_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_as5916_54x_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_as5916_54x_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_as5916_54x_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_SNPRINTF snprintf + #else + #error The macro x86_64_accton_as5916_54x_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as5916_54x_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_as5916_54x_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54x_STRLEN strlen + #else + #error The macro x86_64_accton_as5916_54x_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_AS5916_54X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..568066a4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as5916_54x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as5916_54x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as5916_54x_DEPENDMODULE_ENTRIES := init:x86_64_accton_as5916_54x ucli:x86_64_accton_as5916_54x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..04d2f92b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as5916_54x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..6e990cfd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/fani.c @@ -0,0 +1,303 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + CHASSIS_FAN_INFO(6), + PSU_FAN_INFO(1, 1), + PSU_FAN_INFO(2, 1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value, ret; + + /* get fan present status + */ + ret = onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; /* fan is not present */ + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; + + + /* get front fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + ret = onlp_file_read_int(&value, "%s""fan_max_speed_rpm", FAN_BOARD_PATH); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + info->percentage = (info->rpm * 100)/value; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + if (onlp_file_write_int(p, path) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..4cb41893 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,247 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define LED_FORMAT "/sys/class/leds/accton_as5916_54x_led::%s/brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_LOC, + LED_DIAG, + LED_PSU1, + LED_PSU2, + LED_FAN, +}; + +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_ORANGE, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_ORANGE, ONLP_LED_MODE_ORANGE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char *leds[] = /* must map with onlp_led_id */ +{ + NULL, + "loc", + "diag", + "psu1", + "psu2", + "fan" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 1 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 2 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 3 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 5 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * Turn off the LOCATION and DIAG LEDs at startup + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Get LED mode */ + if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) { + DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid; + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..b3aafcb3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as5916_54x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..1837a772 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,124 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_NODE_MAX_PATH_LEN 64 +#define PSU_MODEL_NAME_LEN 9 +#define PSU_FAN_DIR_LEN 3 + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + int ret = 0, value = 0; + char model[PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[PSU_FAN_DIR_LEN + 1] = {0}; + char *path = NULL; + + if (modelname && modelname_len < PSU_MODEL_NAME_LEN) { + return PSU_TYPE_UNKNOWN; + } + + /* Check AC model name */ + path = (id == PSU1_ID) ? PSU1_AC_EEPROM_NODE(psu_model_name) : PSU2_AC_EEPROM_NODE(psu_model_name); + ret = onlp_file_read((uint8_t*)model, PSU_MODEL_NAME_LEN, &value, path); + if (ret != ONLP_STATUS_OK || value != PSU_MODEL_NAME_LEN) { + return PSU_TYPE_UNKNOWN; + + } + + if (strncmp(model, "YM-2651Y", strlen("YM-2651Y")) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (modelname) { + strncpy(modelname, model, modelname_len-1); + } + + path = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + ret = onlp_file_read((uint8_t*)fan_dir, sizeof(fan_dir), &value, path); + if (ret != ONLP_STATUS_OK) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + ret = onlp_file_read_int(value, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + ret = onlp_file_read_int(value, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..f00d5d41 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,89 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_as5916_54x_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 +#define CHASSIS_LED_COUNT 5 +#define CHASSIS_PSU_COUNT 2 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/18-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/17-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/18-0053/" +#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/17-0050/" + +#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node +#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/9-0066/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/bus/i2c/devices/0-0054/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..f7f64f0e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/psui.c @@ -0,0 +1,177 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + char *prefix = NULL; + + *value = 0; + + prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; + if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node); + return ONLP_STATUS_E_INTERNAL; + } + + return 0; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..d1606f47 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,287 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_as5916_54x_log.h" + +#define NUM_OF_SFP_PORT 54 +#define MAX_PORT_PATH 64 + +#define SFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" +#define SFP_PORT_DOM_FORMAT "/sys/bus/i2c/devices/%d-0051/%s" +#define SFP_BUS_INDEX(port) (port+33) + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 54} + */ + int p; + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + if (onlp_file_read_int(&present, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_is_present") < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[7]; + char path[MAX_PORT_PATH] = {0}; + FILE* fp; + + sprintf(path, SFP_PORT_FORMAT, SFP_BUS_INDEX(0), "sfp_is_present_all"); + fp = fopen(path, "r"); + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3, + bytes+4, + bytes+5, + bytes+6 + ); + fclose(fp); + if(count != AIM_ARRAYSIZE(bytes)) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Mask out non-existant QSFP ports */ + bytes[6] &= 0x3F; + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + int size = 0; + if(onlp_file_read(data, 256, &size, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { + if(size == 256) { + return ONLP_STATUS_OK; + } + } + + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + int size = 0; + if(onlp_file_read(data, 256, &size, SFP_PORT_DOM_FORMAT, SFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { + if(size == 256) { + return ONLP_STATUS_OK; + } + } + + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[6]; + char path[MAX_PORT_PATH] = {0}; + FILE* fp; + + sprintf(path, SFP_PORT_FORMAT, SFP_BUS_INDEX(0), "sfp_rx_los_all"); + fp = fopen(path, "r"); + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3, + bytes+4, + bytes+5 + ); + fclose(fp); + if(count != 6) { + AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t rx_los_all = 0 ; + for(i = 5; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_write_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_disable") != 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_rx_los") < 0) { + AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_fault") < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_disable") < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..44bf47a1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,339 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#include "x86_64_accton_as5916_54x_int.h" +#include "x86_64_accton_as5916_54x_log.h" + +#define CPLD_VERSION_FORMAT "/sys/bus/i2c/devices/%s/version" +#define NUM_OF_CPLD 2 + +static char* cpld_path[NUM_OF_CPLD] = +{ + "11-0060", + "12-0062" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as5916-54x-r1"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 5 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int i, v[NUM_OF_CPLD] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(cpld_path); i++) { + v[i] = 0; + + if(onlp_file_read_int(v+i, CPLD_VERSION_FORMAT , cpld_path[i]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + } + + pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ + aim_free(pi->cpld_versions); +} + +#define FAN_DUTY_MAX (100) +#define FAN_DUTY_MID (69) +#define FAN_DUTY_MIN (38) + +#define FANCTRL_DIR_FACTOR (ONLP_FAN_STATUS_B2F) +#define FANCTRL_DIR_FACTOR_DUTY_ADDON (6) + +static int +sysi_fanctrl_fan_fault_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* Bring fan speed to FAN_DUTY_MAX if any fan is not operational */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + if (!(fi[i].status & ONLP_FAN_STATUS_FAILED)) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_fan_absent_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* Bring fan speed to FAN_DUTY_MAX if fan is not present */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + if (fi[i].status & ONLP_FAN_STATUS_PRESENT) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_fan_unknown_speed_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int fanduty; + int fanduty_min = FAN_DUTY_MIN; + int fanduty_mid = FAN_DUTY_MID; + + *adjusted = 0; + fanduty_min += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + fanduty_mid += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + + if (onlp_file_read_int(&fanduty, FAN_NODE(fan_duty_cycle_percentage)) < 0) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + /* Bring fan speed to max if current speed is not expected + */ + if (fanduty != fanduty_min && fanduty != fanduty_mid && fanduty != FAN_DUTY_MAX) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_single_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* When anyone higher than 50 degrees, all fans run with duty 100%. + */ + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_3_ON_MAIN_BROAD); i++) { + if (ti[i-1].mcelsius < 50000) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + /* When anyone higher than 45 degrees, all fans run with duty 62.5%. + */ + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_3_ON_MAIN_BROAD); i++) { + if (ti[i-1].mcelsius < 45000) { + continue; + } + + int fanduty_mid = FAN_DUTY_MID; + fanduty_mid += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fanduty_mid); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_overall_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int fanduty_min = FAN_DUTY_MIN; + int fanduty_mid = FAN_DUTY_MID; + int i, num_of_sensor = 0, temp_avg = 0; + + *adjusted = 0; + fanduty_min += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + fanduty_mid += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_3_ON_MAIN_BROAD); i++) { + num_of_sensor++; + temp_avg += ti[i-1].mcelsius; + } + + temp_avg /= num_of_sensor; + + if (temp_avg >= 45000) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + else if (temp_avg >= 40000) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fanduty_mid); + } + else if (temp_avg < 35000) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fanduty_min); + } + + return ONLP_STATUS_OK; +} + +typedef int (*fan_control_policy)(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted); + +fan_control_policy fan_control_policies[] = { +sysi_fanctrl_fan_fault_policy, +sysi_fanctrl_fan_absent_policy, +sysi_fanctrl_fan_unknown_speed_policy, +sysi_fanctrl_single_thermal_sensor_policy, +sysi_fanctrl_overall_thermal_sensor_policy, +}; + +int +onlp_sysi_platform_manage_fans(void) +{ + int i, rc; + onlp_fan_info_t fi[CHASSIS_FAN_COUNT]; + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT]; + + memset(fi, 0, sizeof(fi)); + memset(ti, 0, sizeof(ti)); + + /* Get fan status + */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fi[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Get thermal sensor status + */ + for (i = 0; i < CHASSIS_THERMAL_COUNT; i++) { + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i+1), &ti[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Apply thermal policy according the policy list, + * If fan duty is adjusted by one of the policies, skip the others + */ + for (i = 0; i < AIM_ARRAYSIZE(fan_control_policies); i++) { + int adjusted = 0; + + rc = fan_control_policies[i](fi, ti, &adjusted); + if (!adjusted) { + continue; + } + + return rc; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..742a4dd1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,128 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "/sys/bus/i2c/devices/10-0048*temp1_input", + "/sys/bus/i2c/devices/10-0049*temp1_input", + "/sys/bus/i2c/devices/10-004a*temp1_input", + "/sys/bus/i2c/devices/10-004b*temp1_input", + "/sys/bus/i2c/devices/18-005b*psu_temp1_input", + "/sys/bus/i2c/devices/17-0058*psu_temp1_input", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "LM75-3-4B", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if(tid == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[tid]); +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c new file mode 100644 index 00000000..3579a89f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(_x) +x86_64_accton_as5916_54x_config_settings_t x86_64_accton_as5916_54x_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE +#undef __x86_64_accton_as5916_54x_config_STRINGIFY_NAME + +const char* +x86_64_accton_as5916_54x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as5916_54x_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_as5916_54x_config_settings[i].name, setting)) { + return x86_64_accton_as5916_54x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as5916_54x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as5916_54x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as5916_54x_config_settings[i].name, x86_64_accton_as5916_54x_config_settings[i].value); + } + return i; +} + +/* */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c new file mode 100644 index 00000000..b2b98d07 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h new file mode 100644 index 00000000..4543ef58 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as5916_54x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as5916_54x_INT_H__ +#define __x86_64_accton_as5916_54x_INT_H__ + +#include + + +#endif /* __x86_64_accton_as5916_54x_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c new file mode 100644 index 00000000..1537e358 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as5916_54x_log.h" +/* + * x86_64_accton_as5916_54x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h new file mode 100644 index 00000000..5e6ad4d0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as5916_54x_LOG_H__ +#define __x86_64_accton_as5916_54x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as5916_54x +#include + +#endif /* __x86_64_accton_as5916_54x_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c new file mode 100644 index 00000000..efd313db --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as5916_54x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as5916_54x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as5916_54x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c new file mode 100644 index 00000000..fe6e423f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as5916_54x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as5916_54x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as5916_54x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as5916_54x_ucli_module__ = + { + "x86_64_accton_as5916_54x_ucli", + NULL, + x86_64_accton_as5916_54x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as5916_54x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as5916_54x_ucli_module__); + n = ucli_node_create("x86_64_accton_as5916_54x", NULL, &x86_64_accton_as5916_54x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as5916_54x")); + return n; +} + +#else +void* +x86_64_accton_as5916_54x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml new file mode 100644 index 00000000..caedb664 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as5916-54x REVISION=r1 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml new file mode 100644 index 00000000..42278b23 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml @@ -0,0 +1,33 @@ +--- + +###################################################################### +# +# platform-config for AS5916 +# +###################################################################### + +x86-64-accton-as5916-54x-r1: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,115200n8 + tg3.short_preamble=1 + tg3.bcm5718s_reset=1 + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py new file mode 100644 index 00000000..171b3c20 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py @@ -0,0 +1,72 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, + OnlPlatformPortConfig_48x10_6x40): + PLATFORM='x86-64-accton-as5916-54x-r1' + MODEL="AS5916-54X" + SYS_OBJECT_ID=".5916.54" + + def baseconfig(self): + self.insmod("accton_i2c_cpld") + self.insmod("ym2651y") + for m in [ "sfp", "psu", "fan", "leds" ]: + self.insmod("x86-64-accton-as5916-54x-%s" % m) + + ########### initialize I2C bus 0 ########### + self.new_i2c_devices( + [ + # initialize multiplexer (PCA9548) + ('pca9548', 0x77, 0), + ('pca9548', 0x76, 1), + + # initiate chassis fan + ('as5916_54x_fan', 0x66, 9), + + # inititate LM75 + ('lm75', 0x48, 10), + ('lm75', 0x49, 10), + ('lm75', 0x4a, 10), + ('lm75', 0x4b, 10), + + # initialize CPLDs + ('accton_i2c_cpld', 0x60, 11), + ('accton_i2c_cpld', 0x62, 12), + + # initialize multiplexer (PCA9548) + ('pca9548', 0x74, 2), + + # initiate PSU-1 AC Power + ('as5916_54x_psu1', 0x53, 18), + ('ym2651', 0x5b, 18), + + # initiate PSU-2 AC Power + ('as5916_54x_psu2', 0x50, 17), + ('ym2651', 0x58, 17), + + # initialize multiplexer (PCA9548) + ('pca9548', 0x72, 2), + ('pca9548', 0x75, 25), + ('pca9548', 0x75, 26), + ('pca9548', 0x75, 27), + ('pca9548', 0x75, 28), + ('pca9548', 0x75, 29), + ('pca9548', 0x75, 30), + ('pca9548', 0x75, 31), + + # initiate IDPROM + ('24c02', 0x54, 0), + ] + ) + + # initialize SFP devices + for port in range(1, 49): + self.new_i2c_device('as5916_54x_sfp%d' % port, 0x50, port+32) + self.new_i2c_device('as5916_54x_sfp%d' % port, 0x51, port+32) + + # initialize QSFP devices + for port in range(49, 55): + self.new_i2c_device('as5916_54x_sfp%d' % port, 0x50, port+32) + + return True + From 3b304d59c49546a1696c2c07a3b9ae30dcf2be53 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Thu, 8 Mar 2018 17:54:50 +0800 Subject: [PATCH 167/244] Add to support read psu serial number for as6812-32x --- .../builds/x86-64-accton-as6812-32x-psu.c | 92 ++++++++++++++++--- .../onlp/builds/src/module/src/platform_lib.c | 28 ++++++ .../onlp/builds/src/module/src/platform_lib.h | 1 + .../onlp/builds/src/module/src/psui.c | 3 + 4 files changed, 113 insertions(+), 11 deletions(-) mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.c mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.h mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/psui.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c old mode 100644 new mode 100755 index ead60143..7a96c931 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c @@ -42,9 +42,10 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_serial_number(struct device *dev, struct device_attribute *da,char *buf); static int as6812_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); extern int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -static int as6812_32x_psu_model_name_get(struct device *dev); +static int as6812_32x_psu_model_name_get(struct device *dev, int get_serial); /* Addresses scanned */ @@ -60,6 +61,7 @@ struct as6812_32x_psu_data { u8 index; /* PSU index */ u8 status; /* Status(present/power_good) register read from CPLD */ char model_name[14]; /* Model name, read from eeprom */ + char serial[16]; /* Model name, read from eeprom */ }; static struct as6812_32x_psu_data *as6812_32x_psu_update_device(struct device *dev); @@ -68,7 +70,8 @@ enum as6812_32x_psu_sysfs_attributes { PSU_INDEX, PSU_PRESENT, PSU_MODEL_NAME, - PSU_POWER_GOOD + PSU_POWER_GOOD, + PSU_SERIAL_NUMBER }; /* sysfs attributes for hwmon @@ -76,12 +79,14 @@ enum as6812_32x_psu_sysfs_attributes { static SENSOR_DEVICE_ATTR(psu_index, S_IRUGO, show_index, NULL, PSU_INDEX); static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_serial, S_IRUGO, show_serial_number, NULL, PSU_SERIAL_NUMBER); static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); static struct attribute *as6812_32x_psu_attributes[] = { &sensor_dev_attr_psu_index.dev_attr.attr, &sensor_dev_attr_psu_present.dev_attr.attr, &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_serial.dev_attr.attr, &sensor_dev_attr_psu_power_good.dev_attr.attr, NULL }; @@ -116,6 +121,25 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", status); } +static ssize_t show_serial_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as6812_32x_psu_data *data = as6812_32x_psu_update_device(dev); + + if (!data->valid) { + return 0; + } + + if (!IS_PRESENT(data->index, data->status)) { + return 0; + } + + if (as6812_32x_psu_model_name_get(dev, 1) < 0) { + return -ENXIO; + } + return sprintf(buf, "%s\n", data->serial); +} + static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf) { @@ -129,7 +153,7 @@ static ssize_t show_model_name(struct device *dev, struct device_attribute *da, return 0; } - if (as6812_32x_psu_model_name_get(dev) < 0) { + if (as6812_32x_psu_model_name_get(dev, 0) < 0) { return -ENXIO; } return sprintf(buf, "%s\n", data->model_name); @@ -264,6 +288,57 @@ enum psu_type { PSU_UM400D01_01G /* DC48V - B2F */ }; +struct serial_number_info { + enum psu_type type; + u8 offset; + u8 length; +}; + +struct serial_number_info serials[] = { +{PSU_YM_2401_JCR, 0x20, 11}, +{PSU_YM_2401_JDR, 0x20, 11}, +{PSU_CPR_4011_4M11, 0x46, 15}, +{PSU_CPR_4011_4M21, 0x46, 15}, +{PSU_CPR_6011_2M11, 0x46, 15}, +{PSU_CPR_6011_2M21, 0x46, 15}, +{PSU_UM400D_01G, 0x50, 9}, +{PSU_UM400D01_01G, 0x50, 12}, +}; + +static int as6812_32x_psu_serial_number_get(struct device *dev, enum psu_type type) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as6812_32x_psu_data *data = i2c_get_clientdata(client); + int i, status; + + switch (type) { + case PSU_CPR_4011_4M11: + case PSU_CPR_4011_4M21: + case PSU_CPR_6011_2M11: + case PSU_CPR_6011_2M21: + { + status = as6812_32x_psu_read_block(client, serials[i].offset, + data->serial, serials[i].length); + if (status < 0) { + data->serial[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial number from (0x%x) offset(0x%x)\n", + client->addr, serials[i].offset); + return status; + } + else { + data->serial[serials[i].length] = '\0'; + return 0; + } + } + break; + default: + break; + } + + return -ENODATA; +} + + struct model_name_info { enum psu_type type; u8 offset; @@ -282,7 +357,7 @@ struct model_name_info models[] = { {PSU_UM400D01_01G, 0x50, 12, "um400d01-01G"}, }; -static int as6812_32x_psu_model_name_get(struct device *dev) +static int as6812_32x_psu_model_name_get(struct device *dev, int get_serial) { struct i2c_client *client = to_i2c_client(dev); struct as6812_32x_psu_data *data = i2c_get_clientdata(client); @@ -313,7 +388,7 @@ static int as6812_32x_psu_model_name_get(struct device *dev) /* Determine if the model name is known, if not, read next index */ if (strncmp(data->model_name, models[i].model_name, models[i].length) == 0) { - return 0; + return get_serial ? as6812_32x_psu_serial_number_get(dev, i) : 0; } else { data->model_name[0] = '\0'; @@ -359,12 +434,7 @@ exit: } static int __init as6812_32x_psu_init(void) -{ - extern int platform_accton_as6812_32x(void); - if(!platform_accton_as6812_32x()) { - return -ENODEV; - } - +{ return i2c_add_driver(&as6812_32x_psu_driver); } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.c old mode 100644 new mode 100755 index 1591cddd..789ac74d --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.c @@ -23,6 +23,8 @@ * * ***********************************************************/ +#include +#include #include #include #include @@ -248,3 +250,29 @@ int psu_ym2401_pmbus_info_set(int id, char *node, int value) return ONLP_STATUS_OK; } +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, int is_ac, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + memset((void *)serial, 0x0, serial_len); + if(is_ac) + prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; + else + prefix = (id == PSU1_ID) ? PSU1_DC_EEPROM_PREFIX : PSU2_DC_EEPROM_PREFIX; + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.h old mode 100644 new mode 100755 index 77a1aec4..7cc3f21a --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/platform_lib.h @@ -72,6 +72,7 @@ typedef enum psu_type { } psu_type_t; psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, int is_ac, char *serial, int serial_len); int psu_ym2401_pmbus_info_get(int id, char *node, int *value); int psu_ym2401_pmbus_info_set(int id, char *node, int value); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/psui.c old mode 100644 new mode 100755 index cfaffbaf..f1bd0309 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/psui.c @@ -225,6 +225,7 @@ 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); + int is_ac=1; psu_type_t psu_type; VALIDATE(id); @@ -270,12 +271,14 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) break; case PSU_TYPE_DC_48V_F2B: case PSU_TYPE_DC_48V_B2F: + is_ac=0; ret = psu_um400d_info_get(info); break; default: ret = ONLP_STATUS_E_UNSUPPORTED; break; } + psu_serial_number_get(index, is_ac, info->serial, sizeof(info->serial)); return ret; } From ac3aef6597e9d6b752c07187140f572f9d0bd481 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 8 Mar 2018 17:56:11 +0000 Subject: [PATCH 168/244] Remove autogenerated makefiles from git. --- packages/base/any/onlp/src/onlp/.gitignore | 1 + .../any/onlp/src/onlp_platform_defaults/.gitignore | 1 + .../onlp_platform_defaults.mk | 14 -------------- packages/base/any/onlp/src/onlplib/.gitignore | 1 + packages/base/any/onlp/src/onlplib/onlplib.mk | 14 -------------- packages/base/any/onlp/src/sff/.gitignore | 1 + packages/base/any/onlp/src/sff/sff.mk | 14 -------------- packages/base/any/oom-shim/src/.gitignore | 1 + packages/base/any/oom-shim/src/oom_shim.mk | 14 -------------- .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/x86_64_accton_as7512_32x.mk | 13 ------------- .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/x86_64_accton_as7712_32x.mk | 13 ------------- .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../src/x86_64_accton_wedge100s_32x/.gitignore | 1 + .../x86_64_alphanetworks_snx60a0_486f/.gitignore | 1 + .../x86_64_alphanetworks_snx60a0_486f.mk | 14 -------------- .../onlp/builds/src/.gitignore | 1 + .../x86-64-delta-ag5648/onlp/builds/src/.gitignore | 1 + .../x86-64-delta-ag7648/onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/x86_64_delta_ag7648.mk | 13 ------------- .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../x86-64-delta-ag9064/onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.gitignore | 1 + .../x86-64-delta-wb2448/onlp/builds/src/.gitignore | 1 + ...ngrasys-s9100.yml => x86_64_ingrasys_s9100.yml} | 0 .../onlp/builds/src/.gitignore | 1 + .../x86-64-mlnx-msn2100/onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/x86_64_mlnx_msn2100.mk | 13 ------------- .../x86-64-mlnx-msn2410/onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/x86_64_mlnx_msn2410.mk | 13 ------------- .../x86-64-mlnx-msn2700/onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/x86_64_mlnx_msn2700.mk | 13 ------------- .../x86_64_netberg_aurora_620_rangeley/.gitignore | 1 + .../x86_64_netberg_aurora_720_rangeley/.gitignore | 1 + .../quanta/any/src/quanta_sys_eeprom/.gitignore | 1 + .../any/src/quanta_sys_eeprom/quanta_sys_eeprom.mk | 14 -------------- .../powerpc-quanta-lb9/onlp/builds/src/.gitignore | 1 + .../powerpc-quanta-ly2/onlp/builds/src/.gitignore | 1 + .../src/x86_64_quanta_ix1_rangeley/.gitignore | 1 + .../src/x86_64_quanta_ix1b_rglbmc/.gitignore | 1 + .../src/x86_64_quanta_ix2_rangeley/.gitignore | 1 + .../builds/src/x86_64_quanta_ix8_rglbmc/.gitignore | 1 + .../onlp/builds/src/x86_64_quanta_ly4r/.gitignore | 1 + .../src/x86_64_quanta_ly6_rangeley/.gitignore | 1 + .../builds/src/x86_64_quanta_ly7_rglbmc/.gitignore | 1 + .../src/x86_64_quanta_ly8_rangeley/.gitignore | 1 + .../src/x86_64_quanta_ly9_rangeley/.gitignore | 1 + 68 files changed, 55 insertions(+), 162 deletions(-) create mode 100644 packages/base/any/onlp/src/onlp/.gitignore create mode 100644 packages/base/any/onlp/src/onlp_platform_defaults/.gitignore delete mode 100644 packages/base/any/onlp/src/onlp_platform_defaults/onlp_platform_defaults.mk create mode 100644 packages/base/any/onlp/src/onlplib/.gitignore delete mode 100644 packages/base/any/onlp/src/onlplib/onlplib.mk create mode 100644 packages/base/any/onlp/src/sff/.gitignore delete mode 100644 packages/base/any/onlp/src/sff/sff.mk create mode 100644 packages/base/any/oom-shim/src/.gitignore delete mode 100644 packages/base/any/oom-shim/src/oom_shim.mk create mode 100644 packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/.gitignore delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/x86_64_accton_as7512_32x.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/.gitignore delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/x86_64_accton_as7712_32x.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.gitignore create mode 100644 packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/.gitignore delete mode 100644 packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/x86_64_alphanetworks_snx60a0_486f.mk create mode 100644 packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/.gitignore delete mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/x86_64_delta_ag7648.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/.gitignore rename packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/{x86-64-ingrasys-s9100.yml => x86_64_ingrasys_s9100.yml} (100%) create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.gitignore create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/.gitignore delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/x86_64_mlnx_msn2100.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/.gitignore delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/x86_64_mlnx_msn2410.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/.gitignore delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/x86_64_mlnx_msn2700.mk create mode 100644 packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/.gitignore create mode 100644 packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/.gitignore create mode 100644 packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore delete mode 100644 packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.mk create mode 100644 packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/.gitignore create mode 100644 packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/.gitignore create mode 100644 packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/.gitignore diff --git a/packages/base/any/onlp/src/onlp/.gitignore b/packages/base/any/onlp/src/onlp/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/base/any/onlp/src/onlp/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/.gitignore b/packages/base/any/onlp/src/onlp_platform_defaults/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/base/any/onlp/src/onlp_platform_defaults/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/onlp_platform_defaults.mk b/packages/base/any/onlp/src/onlp_platform_defaults/onlp_platform_defaults.mk deleted file mode 100644 index fa66350e..00000000 --- a/packages/base/any/onlp/src/onlp_platform_defaults/onlp_platform_defaults.mk +++ /dev/null @@ -1,14 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the onlp_platform_defaults module. -# -# Autogenerated 2016-05-17 17:43:05.660985 -# -############################################################################### -onlp_platform_defaults_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(onlp_platform_defaults_BASEDIR)module/make.mk -include $(onlp_platform_defaults_BASEDIR)module/auto/make.mk -include $(onlp_platform_defaults_BASEDIR)module/src/make.mk -include $(onlp_platform_defaults_BASEDIR)utest/_make.mk - diff --git a/packages/base/any/onlp/src/onlplib/.gitignore b/packages/base/any/onlp/src/onlplib/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/base/any/onlp/src/onlplib/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/base/any/onlp/src/onlplib/onlplib.mk b/packages/base/any/onlp/src/onlplib/onlplib.mk deleted file mode 100644 index 4b6a380d..00000000 --- a/packages/base/any/onlp/src/onlplib/onlplib.mk +++ /dev/null @@ -1,14 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the onlplib module. -# -# Autogenerated 2017-05-26 00:39:15.535760 -# -############################################################################### -onlplib_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(onlplib_BASEDIR)module/make.mk -include $(onlplib_BASEDIR)module/auto/make.mk -include $(onlplib_BASEDIR)module/src/make.mk -include $(onlplib_BASEDIR)utest/_make.mk - diff --git a/packages/base/any/onlp/src/sff/.gitignore b/packages/base/any/onlp/src/sff/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/base/any/onlp/src/sff/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/base/any/onlp/src/sff/sff.mk b/packages/base/any/onlp/src/sff/sff.mk deleted file mode 100644 index 3760cec8..00000000 --- a/packages/base/any/onlp/src/sff/sff.mk +++ /dev/null @@ -1,14 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the sff module. -# -# Autogenerated 2017-09-25 18:15:50.901582 -# -############################################################################### -sff_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(sff_BASEDIR)module/make.mk -include $(sff_BASEDIR)module/auto/make.mk -include $(sff_BASEDIR)module/src/make.mk -include $(sff_BASEDIR)utest/_make.mk - diff --git a/packages/base/any/oom-shim/src/.gitignore b/packages/base/any/oom-shim/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/base/any/oom-shim/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/base/any/oom-shim/src/oom_shim.mk b/packages/base/any/oom-shim/src/oom_shim.mk deleted file mode 100644 index 106445d0..00000000 --- a/packages/base/any/oom-shim/src/oom_shim.mk +++ /dev/null @@ -1,14 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the oom_shim module. -# -# Autogenerated 2016-02-16 12:05:28.510482 -# -############################################################################### -oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(oom_shim_BASEDIR)/module/make.mk -include $(oom_shim_BASEDIR)/module/auto/make.mk -include $(oom_shim_BASEDIR)/module/src/make.mk -include $(oom_shim_BASEDIR)/utest/_make.mk - diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/.gitignore b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/.gitignore b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/x86_64_accton_as7512_32x.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/x86_64_accton_as7512_32x.mk deleted file mode 100644 index 1c0f78f8..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/x86_64_accton_as7512_32x.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_accton_as7512_32x module. -# -# Autogenerated 2015-12-23 20:42:53.224637 -# -############################################################################### -x86_64_accton_as7512_32x_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_accton_as7512_32x_BASEDIR)/module/make.mk -include $(x86_64_accton_as7512_32x_BASEDIR)/module/auto/make.mk -include $(x86_64_accton_as7512_32x_BASEDIR)/module/src/make.mk - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/x86_64_accton_as7712_32x.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/x86_64_accton_as7712_32x.mk deleted file mode 100644 index de6c1e63..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/x86_64_accton_as7712_32x.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_accton_as7712_32x module. -# -# Autogenerated 2015-12-23 23:45:56.754200 -# -############################################################################### -x86_64_accton_as7712_32x_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_accton_as7712_32x_BASEDIR)/module/make.mk -include $(x86_64_accton_as7712_32x_BASEDIR)/module/auto/make.mk -include $(x86_64_accton_as7712_32x_BASEDIR)/module/src/make.mk - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100s-32x/onlp/builds/src/x86_64_accton_wedge100s_32x/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/.gitignore b/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/x86_64_alphanetworks_snx60a0_486f.mk b/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/x86_64_alphanetworks_snx60a0_486f.mk deleted file mode 100644 index 5652d605..00000000 --- a/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/x86_64_alphanetworks_snx60a0_486f.mk +++ /dev/null @@ -1,14 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_alphanetworks_snx60a0_486f module. -# -# Autogenerated 2016-07-15 15:47:05.304474 -# -############################################################################### -x86_64_alphanetworks_snx60a0_486f_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_alphanetworks_snx60a0_486f_BASEDIR)module/make.mk -include $(x86_64_alphanetworks_snx60a0_486f_BASEDIR)module/auto/make.mk -include $(x86_64_alphanetworks_snx60a0_486f_BASEDIR)module/src/make.mk -include $(x86_64_alphanetworks_snx60a0_486f_BASEDIR)utest/_make.mk - diff --git a/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/.gitignore b/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/x86_64_delta_ag7648.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/x86_64_delta_ag7648.mk deleted file mode 100644 index 0bcfffec..00000000 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/x86_64_delta_ag7648.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_delta_ag7648 module. -# -# Autogenerated 2017-03-20 15:05:23.627200 -# -############################################################################### -x86_64_delta_ag7648_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_delta_ag7648_BASEDIR)module/make.mk -include $(x86_64_delta_ag7648_BASEDIR)module/auto/make.mk -include $(x86_64_delta_ag7648_BASEDIR)module/src/make.mk - diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/x86-64-ingrasys-s9100.yml b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/x86_64_ingrasys_s9100.yml similarity index 100% rename from packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/x86-64-ingrasys-s9100.yml rename to packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/x86_64_ingrasys_s9100.yml diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/.gitignore b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/x86_64_mlnx_msn2100.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/x86_64_mlnx_msn2100.mk deleted file mode 100644 index 88588977..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/x86_64_mlnx_msn2100.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_mlnx_msn2100 module. -# -# Autogenerated 2015-12-23 23:45:56.754200 -# -############################################################################### -x86_64_mlnx_msn2100_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_mlnx_msn2100_BASEDIR)/module/make.mk -include $(x86_64_mlnx_msn2100_BASEDIR)/module/auto/make.mk -include $(x86_64_mlnx_msn2100_BASEDIR)/module/src/make.mk - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/.gitignore b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/x86_64_mlnx_msn2410.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/x86_64_mlnx_msn2410.mk deleted file mode 100644 index c72d417f..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/x86_64_mlnx_msn2410.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_mlnx_msn2410 module. -# -# Autogenerated 2015-12-23 23:45:56.754200 -# -############################################################################### -x86_64_mlnx_msn2410_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_mlnx_msn2410_BASEDIR)/module/make.mk -include $(x86_64_mlnx_msn2410_BASEDIR)/module/auto/make.mk -include $(x86_64_mlnx_msn2410_BASEDIR)/module/src/make.mk - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/.gitignore b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/x86_64_mlnx_msn2700.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/x86_64_mlnx_msn2700.mk deleted file mode 100644 index 7d9819d9..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/x86_64_mlnx_msn2700.mk +++ /dev/null @@ -1,13 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the x86_64_mlnx_msn2700 module. -# -# Autogenerated 2015-12-23 23:45:56.754200 -# -############################################################################### -x86_64_mlnx_msn2700_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(x86_64_mlnx_msn2700_BASEDIR)/module/make.mk -include $(x86_64_mlnx_msn2700_BASEDIR)/module/auto/make.mk -include $(x86_64_mlnx_msn2700_BASEDIR)/module/src/make.mk - diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/.gitignore b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/.gitignore b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore b/packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.mk b/packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.mk deleted file mode 100644 index 0f74073f..00000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.mk +++ /dev/null @@ -1,14 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the quanta_sys_eeprom module. -# -# Autogenerated 2014-08-03 09:25:20.039252 -# -############################################################################### -quanta_sys_eeprom_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(quanta_sys_eeprom_BASEDIR)/module/make.mk -include $(quanta_sys_eeprom_BASEDIR)/module/auto/make.mk -include $(quanta_sys_eeprom_BASEDIR)/module/src/make.mk -include $(quanta_sys_eeprom_BASEDIR)/utest/_make.mk - diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/.gitignore b/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/.gitignore b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/.gitignore @@ -0,0 +1 @@ +*.mk From 312f67ecdf1b050cf5ba4be70a57a2b96dbbd3ae Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 8 Mar 2018 20:19:42 +0000 Subject: [PATCH 169/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 5a031a2f..47d6d0a8 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 5a031a2f0ffd06e5b018fd2a101d54f46b3f2465 +Subproject commit 47d6d0a878046990981b7bc023e0d5cb03ce455c From 3ef3bb3b497d62b0b3fdbcbe920937a795e6a338 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 8 Mar 2018 20:20:50 +0000 Subject: [PATCH 170/244] Code Module Cleanup - Fix autogen definitions for all code modules - Rerun autogen on all modules --- .../any/faultd/src/module/src/faultd_config.c | 2 +- .../onlp_snmp/module/src/onlp_snmp_config.c | 2 +- .../src/onlp_platform_defaults_config.c | 2 +- .../src/onlpie/module/src/onlpie_config.c | 2 +- .../src/onlplib/module/src/onlplib_config.c | 2 +- .../src/sff/module/python/onlp/sff/enums.py | 34 +- .../module/src/arm_accton_as4610_config.c | 2 +- .../src/powerpc_accton_as4600_54t_config.c | 2 +- .../src/powerpc_accton_as5610_52x_config.c | 2 +- .../src/powerpc_accton_as5710_54x_config.c | 2 +- .../src/powerpc_accton_as6700_32x_config.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as5512_54x.yml | 16 +- .../x86_64_accton_as5512_54x_config.h | 48 +-- .../x86_64_accton_as5512_54x_porting.h | 82 ++--- .../src/x86_64_accton_as5512_54x_config.c | 50 +-- .../module/src/x86_64_accton_as5512_54x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../src/x86_64_accton_as5712_54x_config.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as5812_54t.yml | 16 +- .../x86_64_accton_as5812_54t_config.h | 48 +-- .../x86_64_accton_as5812_54t_porting.h | 82 ++--- .../src/x86_64_accton_as5812_54t_config.c | 50 +-- .../module/src/x86_64_accton_as5812_54t_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as5812_54x.yml | 18 +- .../x86_64_accton_as5812_54x_config.h | 52 +-- .../x86_64_accton_as5812_54x_porting.h | 82 ++--- .../src/x86_64_accton_as5812_54x_config.c | 55 ++- .../module/src/x86_64_accton_as5812_54x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as5822_54x.yml | 16 +- .../x86_64_accton_as5822_54x_config.h | 48 +-- .../x86_64_accton_as5822_54x_porting.h | 82 ++--- .../src/x86_64_accton_as5822_54x_config.c | 50 +-- .../module/src/x86_64_accton_as5822_54x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as5912_54x.yml | 16 +- .../x86_64_accton_as5912_54x_config.h | 48 +-- .../x86_64_accton_as5912_54x_porting.h | 82 ++--- .../src/x86_64_accton_as5912_54x_config.c | 50 +-- .../module/src/x86_64_accton_as5912_54x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_accton_as5912_54xk_config.h | 52 +-- .../x86_64_accton_as5912_54xk_porting.h | 82 ++--- .../src/x86_64_accton_as5912_54xk_config.c | 54 +-- .../src/x86_64_accton_as5912_54xk_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_accton_as5916_54x_porting.h | 64 ++-- .../src/x86_64_accton_as5916_54x_config.c | 6 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_accton_as5916_54xm_config.h | 52 +-- .../x86_64_accton_as5916_54xm_porting.h | 82 ++--- .../src/x86_64_accton_as5916_54xm_config.c | 54 +-- .../src/x86_64_accton_as5916_54xm_log.c | 7 +- .../src/x86_64_accton_as6712_32x_config.c | 2 +- .../module/auto/x86_64_accton_as6812_32x.yml | 16 +- .../x86_64_accton_as6812_32x_config.h | 48 +-- .../x86_64_accton_as6812_32x_porting.h | 82 ++--- .../src/x86_64_accton_as6812_32x_config.c | 50 +-- .../module/src/x86_64_accton_as6812_32x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as7312_54x.yml | 16 +- .../x86_64_accton_as7312_54x_config.h | 48 +-- .../x86_64_accton_as7312_54x_porting.h | 82 ++--- .../src/x86_64_accton_as7312_54x_config.c | 50 +-- .../module/src/x86_64_accton_as7312_54x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as7512_32x.yml | 16 +- .../x86_64_accton_as7512_32x_config.h | 48 +-- .../x86_64_accton_as7512_32x_porting.h | 82 ++--- .../src/x86_64_accton_as7512_32x_config.c | 50 +-- .../module/src/x86_64_accton_as7512_32x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../module/auto/x86_64_accton_as7712_32x.yml | 16 +- .../x86_64_accton_as7712_32x_config.h | 48 +-- .../x86_64_accton_as7712_32x_porting.h | 82 ++--- .../src/x86_64_accton_as7712_32x_config.c | 50 +-- .../module/src/x86_64_accton_as7712_32x_log.c | 7 +- .../module/auto/x86_64_accton_as7716_32x.yml | 16 +- .../x86_64_accton_as7716_32x_config.h | 48 +-- .../x86_64_accton_as7716_32x_porting.h | 82 ++--- .../src/x86_64_accton_as7716_32x_config.c | 50 +-- .../module/src/x86_64_accton_as7716_32x_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_accton_as7816_64x_porting.h | 64 ++-- .../src/x86_64_accton_as7816_64x_config.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_accton_wedge100_32x_config.h | 222 ++++++------ .../x86_64_accton_wedge100_32x_porting.h | 176 +++++----- .../src/x86_64_accton_wedge100_32x_config.c | 146 ++++---- ...x86_64_alphanetworks_snx60a0_486f_config.c | 2 +- .../src/x86_64_cel_redstone_xp_config.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_delta_ag5648_config.h | 2 +- .../x86_64_delta_ag5648_porting.h | 64 ++-- .../module/src/x86_64_delta_ag5648_config.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_delta_ag7648_porting.h | 64 ++-- .../module/src/x86_64_delta_ag7648_config.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_delta_ag9032v1_config.h | 2 +- .../x86_64_delta_ag9032v1_porting.h | 64 ++-- .../module/src/x86_64_delta_ag9032v1_config.c | 2 +- .../src/module/auto/x86_64_delta_ag9032v2.yml | 22 +- .../x86_64_delta_ag9032v2_config.h | 36 +- .../x86_64_delta_ag9032v2_porting.h | 64 ++-- .../module/src/x86_64_delta_ag9032v2_config.c | 12 +- .../x86_64_delta_ag9064_config.h | 10 +- .../module/src/x86_64_delta_ag9064_config.c | 7 +- .../x86_64_delta_agc5648s_config.h | 14 +- .../module/src/x86_64_delta_agc5648s_config.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../src/module/auto/x86_64_delta_agc7648a.yml | 14 +- .../x86_64_delta_agc7648a_config.h | 44 +-- .../x86_64_delta_agc7648a_porting.h | 82 ++--- .../module/src/x86_64_delta_agc7648a_config.c | 43 ++- .../module/src/x86_64_delta_agc7648a_log.c | 7 +- .../x86_64_delta_wb2448_config.h | 14 +- .../module/src/x86_64_delta_wb2448_config.c | 7 +- .../x86_64_ingrasys_s9100/module/auto/make.mk | 4 +- .../x86_64_ingrasys_s9100_config.h | 64 ++-- .../x86_64_ingrasys_s9100_porting.h | 88 ++--- .../module/src/x86_64_ingrasys_s9100_config.c | 53 ++- .../module/src/x86_64_ingrasys_s9100_log.c | 6 +- .../module/src/x86_64_ingrasys_s9100_module.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_inventec_d7032q28b_config.h | 52 +-- .../x86_64_inventec_d7032q28b_porting.h | 82 ++--- .../src/x86_64_inventec_d7032q28b_config.c | 55 ++- .../src/x86_64_inventec_d7032q28b_log.c | 7 +- .../module/src/x86_64_kvm_x86_64_config.c | 2 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_mlnx_msn2100_config.h | 52 +-- .../x86_64_mlnx_msn2100_porting.h | 82 ++--- .../module/src/x86_64_mlnx_msn2100_config.c | 55 ++- .../src/module/src/x86_64_mlnx_msn2100_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_mlnx_msn2410_config.h | 52 +-- .../x86_64_mlnx_msn2410_porting.h | 82 ++--- .../module/src/x86_64_mlnx_msn2410_config.c | 55 ++- .../src/module/src/x86_64_mlnx_msn2410_log.c | 7 +- .../onlp/builds/src/Makefile | 2 +- .../x86_64_mlnx_msn2700_config.h | 52 +-- .../x86_64_mlnx_msn2700_porting.h | 82 ++--- .../module/src/x86_64_mlnx_msn2700_config.c | 55 ++- .../src/module/src/x86_64_mlnx_msn2700_log.c | 7 +- .../x86_64_netberg_aurora_620_rangeley.yml | 4 +- ...86_64_netberg_aurora_620_rangeley_config.h | 2 + ...86_64_netberg_aurora_620_rangeley_config.c | 2 +- .../x86_64_netberg_aurora_620_rangeley_int.h | 322 ++++++++++-------- .../x86_64_netberg_aurora_720_rangeley.yml | 12 +- ...86_64_netberg_aurora_720_rangeley_config.h | 2 + ...86_64_netberg_aurora_720_rangeley_config.c | 2 +- .../x86_64_netberg_aurora_720_rangeley_int.h | 322 ++++++++++-------- .../module/src/arm64_nxp_ls2080ardb_config.c | 2 +- .../module/src/arm_qemu_armv7a_config.c | 2 +- .../quanta/any/src/quanta_sys_eeprom/Makefile | 2 +- .../module/src/quanta_sys_eeprom_config.c | 2 +- .../module/src/powerpc_quanta_lb9_config.c | 2 +- .../module/src/powerpc_quanta_ly2_config.c | 2 +- .../src/module/src/powerpc_quanta_ly2_int.h | 202 +++++------ .../src/x86_64_quanta_ix1_rangeley_config.c | 2 +- .../src/x86_64_quanta_ix1_rangeley_int.h | 228 ++++++------- .../src/x86_64_quanta_ix1b_rglbmc_config.c | 2 +- .../src/x86_64_quanta_ix1b_rglbmc_int.h | 228 ++++++------- .../src/x86_64_quanta_ix2_rangeley_config.c | 2 +- .../src/x86_64_quanta_ix2_rangeley_int.h | 228 ++++++------- .../src/x86_64_quanta_ix8_rglbmc_config.c | 2 +- .../module/src/x86_64_quanta_ix8_rglbmc_int.h | 228 ++++++------- .../module/src/x86_64_quanta_ly4r_config.c | 2 +- .../module/src/x86_64_quanta_ly4r_int.h | 228 ++++++------- .../src/x86_64_quanta_ly6_rangeley_config.c | 2 +- .../src/x86_64_quanta_ly6_rangeley_int.h | 228 ++++++------- .../src/x86_64_quanta_ly7_rglbmc_config.c | 2 +- .../module/src/x86_64_quanta_ly7_rglbmc_int.h | 228 ++++++------- .../src/x86_64_quanta_ly8_rangeley_config.c | 2 +- .../src/x86_64_quanta_ly8_rangeley_int.h | 228 ++++++------- .../src/x86_64_quanta_ly9_rangeley_config.c | 2 +- .../src/x86_64_quanta_ly9_rangeley_int.h | 228 ++++++------- 181 files changed, 3905 insertions(+), 3857 deletions(-) diff --git a/packages/base/any/faultd/src/module/src/faultd_config.c b/packages/base/any/faultd/src/module/src/faultd_config.c index 97d2e176..c9294f41 100644 --- a/packages/base/any/faultd/src/module/src/faultd_config.c +++ b/packages/base/any/faultd/src/module/src/faultd_config.c @@ -110,7 +110,7 @@ faultd_config_lookup(const char* setting) { int i; for(i = 0; faultd_config_settings[i].name; i++) { - if(strcmp(faultd_config_settings[i].name, setting)) { + if(!strcmp(faultd_config_settings[i].name, setting)) { return faultd_config_settings[i].value; } } diff --git a/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_config.c b/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_config.c index 418b89f1..eef9067f 100644 --- a/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_config.c +++ b/packages/base/any/onlp-snmpd/builds/src/onlp_snmp/module/src/onlp_snmp_config.c @@ -110,7 +110,7 @@ onlp_snmp_config_lookup(const char* setting) { int i; for(i = 0; onlp_snmp_config_settings[i].name; i++) { - if(strcmp(onlp_snmp_config_settings[i].name, setting)) { + if(!strcmp(onlp_snmp_config_settings[i].name, setting)) { return onlp_snmp_config_settings[i].value; } } diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/onlp_platform_defaults_config.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/onlp_platform_defaults_config.c index 1374b1bc..583238e3 100644 --- a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/onlp_platform_defaults_config.c +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/onlp_platform_defaults_config.c @@ -80,7 +80,7 @@ onlp_platform_defaults_config_lookup(const char* setting) { int i; for(i = 0; onlp_platform_defaults_config_settings[i].name; i++) { - if(strcmp(onlp_platform_defaults_config_settings[i].name, setting)) { + if(!strcmp(onlp_platform_defaults_config_settings[i].name, setting)) { return onlp_platform_defaults_config_settings[i].value; } } diff --git a/packages/base/any/onlp/src/onlpie/module/src/onlpie_config.c b/packages/base/any/onlp/src/onlpie/module/src/onlpie_config.c index 6447ca76..2b0e7b93 100644 --- a/packages/base/any/onlp/src/onlpie/module/src/onlpie_config.c +++ b/packages/base/any/onlp/src/onlpie/module/src/onlpie_config.c @@ -75,7 +75,7 @@ onlpie_config_lookup(const char* setting) { int i; for(i = 0; onlpie_config_settings[i].name; i++) { - if(strcmp(onlpie_config_settings[i].name, setting)) { + if(!strcmp(onlpie_config_settings[i].name, setting)) { return onlpie_config_settings[i].value; } } diff --git a/packages/base/any/onlp/src/onlplib/module/src/onlplib_config.c b/packages/base/any/onlp/src/onlplib/module/src/onlplib_config.c index d3e75afe..e7756e39 100644 --- a/packages/base/any/onlp/src/onlplib/module/src/onlplib_config.c +++ b/packages/base/any/onlp/src/onlplib/module/src/onlplib_config.c @@ -95,7 +95,7 @@ onlplib_config_lookup(const char* setting) { int i; for(i = 0; onlplib_config_settings[i].name; i++) { - if(strcmp(onlplib_config_settings[i].name, setting)) { + if(!strcmp(onlplib_config_settings[i].name, setting)) { return onlplib_config_settings[i].value; } } diff --git a/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py b/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py index 5499f7cd..747c7090 100644 --- a/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py +++ b/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py @@ -43,22 +43,23 @@ class SFF_MODULE_TYPE(Enumeration): _40G_BASE_SM4 = 13 _40G_BASE_ER4 = 14 _25G_BASE_CR = 15 - _10G_BASE_SR = 16 - _10G_BASE_LR = 17 - _10G_BASE_LRM = 18 - _10G_BASE_ER = 19 - _10G_BASE_CR = 20 - _10G_BASE_SX = 21 - _10G_BASE_LX = 22 - _10G_BASE_ZR = 23 - _10G_BASE_SRL = 24 - _1G_BASE_SX = 25 - _1G_BASE_LX = 26 - _1G_BASE_CX = 27 - _1G_BASE_T = 28 - _100_BASE_LX = 29 - _100_BASE_FX = 30 - _4X_MUX = 31 + _25G_BASE_SR = 16 + _10G_BASE_SR = 17 + _10G_BASE_LR = 18 + _10G_BASE_LRM = 19 + _10G_BASE_ER = 20 + _10G_BASE_CR = 21 + _10G_BASE_SX = 22 + _10G_BASE_LX = 23 + _10G_BASE_ZR = 24 + _10G_BASE_SRL = 25 + _1G_BASE_SX = 26 + _1G_BASE_LX = 27 + _1G_BASE_CX = 28 + _1G_BASE_T = 29 + _100_BASE_LX = 30 + _100_BASE_FX = 31 + _4X_MUX = 32 class SFF_SFP_TYPE(Enumeration): @@ -66,5 +67,6 @@ class SFF_SFP_TYPE(Enumeration): QSFP = 1 QSFP_PLUS = 2 QSFP28 = 3 + SFP28 = 4 # diff --git a/packages/platforms/accton/armel/arm-accton-as4610/src/arm_accton_as4610/module/src/arm_accton_as4610_config.c b/packages/platforms/accton/armel/arm-accton-as4610/src/arm_accton_as4610/module/src/arm_accton_as4610_config.c index ba06f213..375c5de7 100644 --- a/packages/platforms/accton/armel/arm-accton-as4610/src/arm_accton_as4610/module/src/arm_accton_as4610_config.c +++ b/packages/platforms/accton/armel/arm-accton-as4610/src/arm_accton_as4610/module/src/arm_accton_as4610_config.c @@ -80,7 +80,7 @@ arm_accton_as4610_config_lookup(const char* setting) { int i; for(i = 0; arm_accton_as4610_config_settings[i].name; i++) { - if(strcmp(arm_accton_as4610_config_settings[i].name, setting)) { + if(!strcmp(arm_accton_as4610_config_settings[i].name, setting)) { return arm_accton_as4610_config_settings[i].value; } } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/powerpc_accton_as4600_54t_config.c b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/powerpc_accton_as4600_54t_config.c index 349d7416..75e28e4e 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/powerpc_accton_as4600_54t_config.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/powerpc_accton_as4600_54t_config.c @@ -55,7 +55,7 @@ powerpc_accton_as4600_54t_config_lookup(const char* setting) { int i; for(i = 0; powerpc_accton_as4600_54t_config_settings[i].name; i++) { - if(strcmp(powerpc_accton_as4600_54t_config_settings[i].name, setting)) { + if(!strcmp(powerpc_accton_as4600_54t_config_settings[i].name, setting)) { return powerpc_accton_as4600_54t_config_settings[i].value; } } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/powerpc_accton_as5610_52x_config.c b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/powerpc_accton_as5610_52x_config.c index 2bd453da..a75398dc 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/powerpc_accton_as5610_52x_config.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/powerpc_accton_as5610_52x_config.c @@ -55,7 +55,7 @@ powerpc_accton_as5610_52x_config_lookup(const char* setting) { int i; for(i = 0; powerpc_accton_as5610_52x_config_settings[i].name; i++) { - if(strcmp(powerpc_accton_as5610_52x_config_settings[i].name, setting)) { + if(!strcmp(powerpc_accton_as5610_52x_config_settings[i].name, setting)) { return powerpc_accton_as5610_52x_config_settings[i].value; } } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c index 79d9f640..da550d95 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c @@ -60,7 +60,7 @@ powerpc_accton_as5710_54x_config_lookup(const char* setting) { int i; for(i = 0; powerpc_accton_as5710_54x_config_settings[i].name; i++) { - if(strcmp(powerpc_accton_as5710_54x_config_settings[i].name, setting)) { + if(!strcmp(powerpc_accton_as5710_54x_config_settings[i].name, setting)) { return powerpc_accton_as5710_54x_config_settings[i].value; } } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/module/src/powerpc_accton_as6700_32x_config.c b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/module/src/powerpc_accton_as6700_32x_config.c index f42df2d2..6d4d27b5 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/module/src/powerpc_accton_as6700_32x_config.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/onlp/builds/src/module/src/powerpc_accton_as6700_32x_config.c @@ -55,7 +55,7 @@ powerpc_accton_as6700_32x_config_lookup(const char* setting) { int i; for(i = 0; powerpc_accton_as6700_32x_config_settings[i].name; i++) { - if(strcmp(powerpc_accton_as6700_32x_config_settings[i].name, setting)) { + if(!strcmp(powerpc_accton_as6700_32x_config_settings[i].name, setting)) { return powerpc_accton_as6700_32x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/Makefile index 2b9cbb03..97d30926 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5512_54x AUTOMODULE := x86_64_accton_as5512_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/auto/x86_64_accton_as5512_54x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/auto/x86_64_accton_as5512_54x.yml index d11f560c..faef9683 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/auto/x86_64_accton_as5512_54x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/auto/x86_64_accton_as5512_54x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB -- x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_config.h index 84435002..1a6244a0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_porting.h index ab37ffd8..2533fede 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/inc/x86_64_accton_as5512_54x/x86_64_accton_as5512_54x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5512_54x_MALLOC +#ifndef X86_64_ACCTON_AS5512_54X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5512_54x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_MALLOC malloc + #define X86_64_ACCTON_AS5512_54X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_MALLOC malloc #else - #error The macro x86_64_accton_as5512_54x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_FREE +#ifndef X86_64_ACCTON_AS5512_54X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5512_54x_FREE GLOBAL_FREE - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_FREE free + #define X86_64_ACCTON_AS5512_54X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_FREE free #else - #error The macro x86_64_accton_as5512_54x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_MEMSET +#ifndef X86_64_ACCTON_AS5512_54X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5512_54x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_MEMSET memset + #define X86_64_ACCTON_AS5512_54X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_MEMSET memset #else - #error The macro x86_64_accton_as5512_54x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_MEMCPY +#ifndef X86_64_ACCTON_AS5512_54X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5512_54x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_MEMCPY memcpy + #define X86_64_ACCTON_AS5512_54X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_MEMCPY memcpy #else - #error The macro x86_64_accton_as5512_54x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_STRNCPY +#ifndef X86_64_ACCTON_AS5512_54X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5512_54x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_STRNCPY strncpy + #define X86_64_ACCTON_AS5512_54X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_STRNCPY strncpy #else - #error The macro x86_64_accton_as5512_54x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_VSNPRINTF +#ifndef X86_64_ACCTON_AS5512_54X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5512_54x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5512_54X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5512_54x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_SNPRINTF +#ifndef X86_64_ACCTON_AS5512_54X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5512_54x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_SNPRINTF snprintf + #define X86_64_ACCTON_AS5512_54X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5512_54x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5512_54x_STRLEN +#ifndef X86_64_ACCTON_AS5512_54X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5512_54x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5512_54x_STRLEN strlen + #define X86_64_ACCTON_AS5512_54X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5512_54X_STRLEN strlen #else - #error The macro x86_64_accton_as5512_54x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5512_54X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_config.c index d4f9aca0..905c72f2 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(_x) x86_64_accton_as5512_54x_config_settings_t x86_64_accton_as5512_54x_config_settings[] = { -#ifdef x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5512_54x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5512_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5512_54x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5512_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5512_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5512_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5512_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5512_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5512_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5512_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5512_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5512_54x_config_settings[i].name, setting)) { return x86_64_accton_as5512_54x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_log.c index 2d75aaf7..81d09553 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5512-54x/onlp/builds/src/module/src/x86_64_accton_as5512_54x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5512_54x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5512_54x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5512_54x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5512_54X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5512_54X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5512_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5512_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/Makefile index af6cd0d0..4c3a737b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5712_54x AUTOMODULE := x86_64_accton_as5712_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/x86_64_accton_as5712_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/x86_64_accton_as5712_54x_config.c index 6076b19e..6a34a36a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/x86_64_accton_as5712_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/x86_64_accton_as5712_54x_config.c @@ -55,7 +55,7 @@ x86_64_accton_as5712_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5712_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5712_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5712_54x_config_settings[i].name, setting)) { return x86_64_accton_as5712_54x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/Makefile index 43c57541..51d708ab 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5812_54t AUTOMODULE := x86_64_accton_as5812_54t include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml index fa34d87f..6cea6947 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB -- x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h index 03c7077d..2ece1c39 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_porting.h index 83c19467..015545a2 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5812_54t_MALLOC +#ifndef X86_64_ACCTON_AS5812_54T_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5812_54t_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_MALLOC malloc + #define X86_64_ACCTON_AS5812_54T_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_MALLOC malloc #else - #error The macro x86_64_accton_as5812_54t_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_FREE +#ifndef X86_64_ACCTON_AS5812_54T_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5812_54t_FREE GLOBAL_FREE - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_FREE free + #define X86_64_ACCTON_AS5812_54T_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_FREE free #else - #error The macro x86_64_accton_as5812_54t_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_MEMSET +#ifndef X86_64_ACCTON_AS5812_54T_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5812_54t_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_MEMSET memset + #define X86_64_ACCTON_AS5812_54T_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_MEMSET memset #else - #error The macro x86_64_accton_as5812_54t_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_MEMCPY +#ifndef X86_64_ACCTON_AS5812_54T_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5812_54t_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_MEMCPY memcpy + #define X86_64_ACCTON_AS5812_54T_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_MEMCPY memcpy #else - #error The macro x86_64_accton_as5812_54t_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_STRNCPY +#ifndef X86_64_ACCTON_AS5812_54T_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5812_54t_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_STRNCPY strncpy + #define X86_64_ACCTON_AS5812_54T_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_STRNCPY strncpy #else - #error The macro x86_64_accton_as5812_54t_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_VSNPRINTF +#ifndef X86_64_ACCTON_AS5812_54T_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5812_54t_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5812_54T_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5812_54t_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_SNPRINTF +#ifndef X86_64_ACCTON_AS5812_54T_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5812_54t_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_SNPRINTF snprintf + #define X86_64_ACCTON_AS5812_54T_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5812_54t_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54t_STRLEN +#ifndef X86_64_ACCTON_AS5812_54T_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5812_54t_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54t_STRLEN strlen + #define X86_64_ACCTON_AS5812_54T_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54T_STRLEN strlen #else - #error The macro x86_64_accton_as5812_54t_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54T_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c index 97465a19..3b9e9acf 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(_x) x86_64_accton_as5812_54t_config_settings_t x86_64_accton_as5812_54t_config_settings[] = { -#ifdef x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5812_54t_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5812_54t_CONFIG_PORTING_STDLIB(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_STDLIB(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5812_54t_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5812_54t_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5812_54t_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5812_54t_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5812_54t_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5812_54t_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5812_54t_config_settings[i].name, setting)) { return x86_64_accton_as5812_54t_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_log.c index 5a23ae7e..c4c8dcc4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5812_54t log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5812_54t_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5812_54t_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5812_54T_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5812_54T_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5812_54t_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5812_54T_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/Makefile index b59ead24..0273cd87 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5812_54x AUTOMODULE := x86_64_accton_as5812_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml index bf7902d1..7d360ebd 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml @@ -5,35 +5,35 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB -- x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 definitions: cdefs: - x86_64_accton_as5812_54x_CONFIG_HEADER: + X86_64_ACCTON_AS5812_54X_CONFIG_HEADER: defs: *cdefs basename: x86_64_accton_as5812_54x_config diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h index cd3d1110..a93d2c16 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_accton_as5812_54x_config_lookup(const char* setting); */ int x86_64_accton_as5812_54x_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_accton_as5812_54x_porting.h" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_porting.h index 8377f863..c90124c3 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5812_54x_MALLOC +#ifndef X86_64_ACCTON_AS5812_54X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5812_54x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_MALLOC malloc + #define X86_64_ACCTON_AS5812_54X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_MALLOC malloc #else - #error The macro x86_64_accton_as5812_54x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_FREE +#ifndef X86_64_ACCTON_AS5812_54X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5812_54x_FREE GLOBAL_FREE - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_FREE free + #define X86_64_ACCTON_AS5812_54X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_FREE free #else - #error The macro x86_64_accton_as5812_54x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_MEMSET +#ifndef X86_64_ACCTON_AS5812_54X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5812_54x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_MEMSET memset + #define X86_64_ACCTON_AS5812_54X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_MEMSET memset #else - #error The macro x86_64_accton_as5812_54x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_MEMCPY +#ifndef X86_64_ACCTON_AS5812_54X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5812_54x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_MEMCPY memcpy + #define X86_64_ACCTON_AS5812_54X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_MEMCPY memcpy #else - #error The macro x86_64_accton_as5812_54x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_STRNCPY +#ifndef X86_64_ACCTON_AS5812_54X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5812_54x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_STRNCPY strncpy + #define X86_64_ACCTON_AS5812_54X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_STRNCPY strncpy #else - #error The macro x86_64_accton_as5812_54x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_VSNPRINTF +#ifndef X86_64_ACCTON_AS5812_54X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5812_54x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5812_54X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5812_54x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_SNPRINTF +#ifndef X86_64_ACCTON_AS5812_54X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5812_54x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_SNPRINTF snprintf + #define X86_64_ACCTON_AS5812_54X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5812_54x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5812_54x_STRLEN +#ifndef X86_64_ACCTON_AS5812_54X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5812_54x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5812_54x_STRLEN strlen + #define X86_64_ACCTON_AS5812_54X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5812_54X_STRLEN strlen #else - #error The macro x86_64_accton_as5812_54x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5812_54X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c index 66c6800b..c3301e27 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(_x) #_x #define __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(_x) x86_64_accton_as5812_54x_config_settings_t x86_64_accton_as5812_54x_config_settings[] = { -#ifdef x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5812_54x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5812_54x_CONFIG_PORTING_STDLIB(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5812_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5812_54x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5812_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5812_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5812_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5812_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5812_54x_config_settings[i].name, setting)) { return x86_64_accton_as5812_54x_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_accton_as5812_54x_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_log.c index 4e03c942..b310a891 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5812_54x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5812_54x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5812_54x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5812_54X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5812_54X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5812_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5812_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/Makefile index 0bb80e83..61b3817a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5822_54x AUTOMODULE := x86_64_accton_as5822_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/auto/x86_64_accton_as5822_54x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/auto/x86_64_accton_as5822_54x.yml index 59e3ceac..dee275d0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/auto/x86_64_accton_as5822_54x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/auto/x86_64_accton_as5822_54x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB -- x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_config.h index e624ae2b..eb1e5ed8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_porting.h index ebb2c937..b854933b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/inc/x86_64_accton_as5822_54x/x86_64_accton_as5822_54x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5822_54x_MALLOC +#ifndef X86_64_ACCTON_AS5822_54X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5822_54x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_MALLOC malloc + #define X86_64_ACCTON_AS5822_54X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_MALLOC malloc #else - #error The macro x86_64_accton_as5822_54x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_FREE +#ifndef X86_64_ACCTON_AS5822_54X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5822_54x_FREE GLOBAL_FREE - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_FREE free + #define X86_64_ACCTON_AS5822_54X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_FREE free #else - #error The macro x86_64_accton_as5822_54x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_MEMSET +#ifndef X86_64_ACCTON_AS5822_54X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5822_54x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_MEMSET memset + #define X86_64_ACCTON_AS5822_54X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_MEMSET memset #else - #error The macro x86_64_accton_as5822_54x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_MEMCPY +#ifndef X86_64_ACCTON_AS5822_54X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5822_54x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_MEMCPY memcpy + #define X86_64_ACCTON_AS5822_54X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_MEMCPY memcpy #else - #error The macro x86_64_accton_as5822_54x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_STRNCPY +#ifndef X86_64_ACCTON_AS5822_54X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5822_54x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_STRNCPY strncpy + #define X86_64_ACCTON_AS5822_54X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_STRNCPY strncpy #else - #error The macro x86_64_accton_as5822_54x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_VSNPRINTF +#ifndef X86_64_ACCTON_AS5822_54X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5822_54x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5822_54X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5822_54x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_SNPRINTF +#ifndef X86_64_ACCTON_AS5822_54X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5822_54x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_SNPRINTF snprintf + #define X86_64_ACCTON_AS5822_54X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5822_54x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5822_54x_STRLEN +#ifndef X86_64_ACCTON_AS5822_54X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5822_54x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5822_54x_STRLEN strlen + #define X86_64_ACCTON_AS5822_54X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5822_54X_STRLEN strlen #else - #error The macro x86_64_accton_as5822_54x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5822_54X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_config.c index b83942e8..a6b8cbe8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(_x) x86_64_accton_as5822_54x_config_settings_t x86_64_accton_as5822_54x_config_settings[] = { -#ifdef x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5822_54x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5822_54x_CONFIG_PORTING_STDLIB(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5822_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5822_54x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5822_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5822_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5822_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5822_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5822_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5822_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5822_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5822_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5822_54x_config_settings[i].name, setting)) { return x86_64_accton_as5822_54x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_log.c index 73867ec8..c6adae6a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/x86_64_accton_as5822_54x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5822_54x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5822_54x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5822_54x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5822_54X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5822_54X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5822_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5822_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/Makefile index 909f3729..1581ae27 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5912_54x AUTOMODULE := x86_64_accton_as5912_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/auto/x86_64_accton_as5912_54x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/auto/x86_64_accton_as5912_54x.yml index 16d1d5c5..57a73bb1 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/auto/x86_64_accton_as5912_54x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/auto/x86_64_accton_as5912_54x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB -- x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_config.h index 3efdb7fd..fdc020dd 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_porting.h index 6362542d..afb223c3 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/inc/x86_64_accton_as5912_54x/x86_64_accton_as5912_54x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5912_54x_MALLOC +#ifndef X86_64_ACCTON_AS5912_54X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5912_54x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_MALLOC malloc + #define X86_64_ACCTON_AS5912_54X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_MALLOC malloc #else - #error The macro x86_64_accton_as5912_54x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_FREE +#ifndef X86_64_ACCTON_AS5912_54X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5912_54x_FREE GLOBAL_FREE - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_FREE free + #define X86_64_ACCTON_AS5912_54X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_FREE free #else - #error The macro x86_64_accton_as5912_54x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_MEMSET +#ifndef X86_64_ACCTON_AS5912_54X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5912_54x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_MEMSET memset + #define X86_64_ACCTON_AS5912_54X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_MEMSET memset #else - #error The macro x86_64_accton_as5912_54x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_MEMCPY +#ifndef X86_64_ACCTON_AS5912_54X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5912_54x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_MEMCPY memcpy + #define X86_64_ACCTON_AS5912_54X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_MEMCPY memcpy #else - #error The macro x86_64_accton_as5912_54x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_STRNCPY +#ifndef X86_64_ACCTON_AS5912_54X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5912_54x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_STRNCPY strncpy + #define X86_64_ACCTON_AS5912_54X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_STRNCPY strncpy #else - #error The macro x86_64_accton_as5912_54x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_VSNPRINTF +#ifndef X86_64_ACCTON_AS5912_54X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5912_54x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5912_54X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5912_54x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_SNPRINTF +#ifndef X86_64_ACCTON_AS5912_54X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5912_54x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_SNPRINTF snprintf + #define X86_64_ACCTON_AS5912_54X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5912_54x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54x_STRLEN +#ifndef X86_64_ACCTON_AS5912_54X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5912_54x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54x_STRLEN strlen + #define X86_64_ACCTON_AS5912_54X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54X_STRLEN strlen #else - #error The macro x86_64_accton_as5912_54x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_config.c index c7a6aa8f..9fc3d69a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(_x) x86_64_accton_as5912_54x_config_settings_t x86_64_accton_as5912_54x_config_settings[] = { -#ifdef x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5912_54x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5912_54x_CONFIG_PORTING_STDLIB(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5912_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5912_54x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5912_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5912_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5912_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5912_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5912_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5912_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5912_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5912_54x_config_settings[i].name, setting)) { return x86_64_accton_as5912_54x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_log.c index 39a54061..0f5b93a8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54x/onlp/builds/src/module/src/x86_64_accton_as5912_54x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5912_54x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5912_54x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5912_54x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5912_54X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5912_54X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5912_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5912_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/Makefile index 579d1811..5e3b69ea 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5912_54xk AUTOMODULE := x86_64_accton_as5912_54xk include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_config.h index 00d1559d..8925cbf4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_accton_as5912_54xk_config_lookup(const char* setting); */ int x86_64_accton_as5912_54xk_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_accton_as5912_54xk_porting.h" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_porting.h index 60fb0289..d5c16f08 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/inc/x86_64_accton_as5912_54xk/x86_64_accton_as5912_54xk_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5912_54xk_MALLOC +#ifndef X86_64_ACCTON_AS5912_54XK_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5912_54xk_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_MALLOC malloc + #define X86_64_ACCTON_AS5912_54XK_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_MALLOC malloc #else - #error The macro x86_64_accton_as5912_54xk_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_FREE +#ifndef X86_64_ACCTON_AS5912_54XK_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5912_54xk_FREE GLOBAL_FREE - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_FREE free + #define X86_64_ACCTON_AS5912_54XK_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_FREE free #else - #error The macro x86_64_accton_as5912_54xk_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_MEMSET +#ifndef X86_64_ACCTON_AS5912_54XK_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5912_54xk_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_MEMSET memset + #define X86_64_ACCTON_AS5912_54XK_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_MEMSET memset #else - #error The macro x86_64_accton_as5912_54xk_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_MEMCPY +#ifndef X86_64_ACCTON_AS5912_54XK_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5912_54xk_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_MEMCPY memcpy + #define X86_64_ACCTON_AS5912_54XK_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_MEMCPY memcpy #else - #error The macro x86_64_accton_as5912_54xk_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_STRNCPY +#ifndef X86_64_ACCTON_AS5912_54XK_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5912_54xk_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_STRNCPY strncpy + #define X86_64_ACCTON_AS5912_54XK_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_STRNCPY strncpy #else - #error The macro x86_64_accton_as5912_54xk_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_VSNPRINTF +#ifndef X86_64_ACCTON_AS5912_54XK_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5912_54xk_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5912_54XK_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5912_54xk_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_SNPRINTF +#ifndef X86_64_ACCTON_AS5912_54XK_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5912_54xk_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_SNPRINTF snprintf + #define X86_64_ACCTON_AS5912_54XK_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5912_54xk_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5912_54xk_STRLEN +#ifndef X86_64_ACCTON_AS5912_54XK_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5912_54xk_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5912_54xk_STRLEN strlen + #define X86_64_ACCTON_AS5912_54XK_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5912_54XK_STRLEN strlen #else - #error The macro x86_64_accton_as5912_54xk_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5912_54XK_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_config.c index d403bbc7..e8606eb8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(_x) #_x #define __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(_x) x86_64_accton_as5912_54xk_config_settings_t x86_64_accton_as5912_54xk_config_settings[] = { -#ifdef x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_PORTING_STDLIB(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_STDLIB(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5912_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5912_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5912_54xk_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5912_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5912_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5912_54xk_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5912_54xk_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5912_54xk_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5912_54xk_config_settings[i].name, setting)) { return x86_64_accton_as5912_54xk_config_settings[i].value; } } @@ -77,4 +77,4 @@ x86_64_accton_as5912_54xk_config_show(struct aim_pvs_s* pvs) return i; } -/* */ \ No newline at end of file +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_log.c index f00242a5..7c43f716 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/x86_64_accton_as5912_54xk_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5912_54xk log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5912_54xk_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5912_54xk_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5912_54xk_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5912_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/Makefile index 10f71d72..9cebbeb4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5916_54x AUTOMODULE := x86_64_accton_as5916_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/inc/x86_64_accton_as5916_54x/x86_64_accton_as5916_54x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/inc/x86_64_accton_as5916_54x/x86_64_accton_as5916_54x_porting.h index e7dcddc8..8e156611 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/inc/x86_64_accton_as5916_54x/x86_64_accton_as5916_54x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/inc/x86_64_accton_as5916_54x/x86_64_accton_as5916_54x_porting.h @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5916_54x_MALLOC +#ifndef X86_64_ACCTON_AS5916_54X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5916_54x_MALLOC GLOBAL_MALLOC + #define X86_64_ACCTON_AS5916_54X_MALLOC GLOBAL_MALLOC #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_MALLOC malloc + #define X86_64_ACCTON_AS5916_54X_MALLOC malloc #else - #error The macro x86_64_accton_as5916_54x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_FREE +#ifndef X86_64_ACCTON_AS5916_54X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5916_54x_FREE GLOBAL_FREE + #define X86_64_ACCTON_AS5916_54X_FREE GLOBAL_FREE #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_FREE free + #define X86_64_ACCTON_AS5916_54X_FREE free #else - #error The macro x86_64_accton_as5916_54x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_MEMSET +#ifndef X86_64_ACCTON_AS5916_54X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5916_54x_MEMSET GLOBAL_MEMSET + #define X86_64_ACCTON_AS5916_54X_MEMSET GLOBAL_MEMSET #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_MEMSET memset + #define X86_64_ACCTON_AS5916_54X_MEMSET memset #else - #error The macro x86_64_accton_as5916_54x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_MEMCPY +#ifndef X86_64_ACCTON_AS5916_54X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5916_54x_MEMCPY GLOBAL_MEMCPY + #define X86_64_ACCTON_AS5916_54X_MEMCPY GLOBAL_MEMCPY #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_MEMCPY memcpy + #define X86_64_ACCTON_AS5916_54X_MEMCPY memcpy #else - #error The macro x86_64_accton_as5916_54x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_STRNCPY +#ifndef X86_64_ACCTON_AS5916_54X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5916_54x_STRNCPY GLOBAL_STRNCPY + #define X86_64_ACCTON_AS5916_54X_STRNCPY GLOBAL_STRNCPY #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_STRNCPY strncpy + #define X86_64_ACCTON_AS5916_54X_STRNCPY strncpy #else - #error The macro x86_64_accton_as5916_54x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_VSNPRINTF +#ifndef X86_64_ACCTON_AS5916_54X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5916_54x_VSNPRINTF GLOBAL_VSNPRINTF + #define X86_64_ACCTON_AS5916_54X_VSNPRINTF GLOBAL_VSNPRINTF #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5916_54X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5916_54x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_SNPRINTF +#ifndef X86_64_ACCTON_AS5916_54X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5916_54x_SNPRINTF GLOBAL_SNPRINTF + #define X86_64_ACCTON_AS5916_54X_SNPRINTF GLOBAL_SNPRINTF #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_SNPRINTF snprintf + #define X86_64_ACCTON_AS5916_54X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5916_54x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_STRLEN +#ifndef X86_64_ACCTON_AS5916_54X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5916_54x_STRLEN GLOBAL_STRLEN + #define X86_64_ACCTON_AS5916_54X_STRLEN GLOBAL_STRLEN #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_STRLEN strlen + #define X86_64_ACCTON_AS5916_54X_STRLEN strlen #else - #error The macro x86_64_accton_as5916_54x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/x86_64_accton_as5916_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/x86_64_accton_as5916_54x_config.c index 3579a89f..77e598ee 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/x86_64_accton_as5916_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/x86_64_accton_as5916_54x_config.c @@ -5,7 +5,7 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(_x) #_x #define __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(_x) x86_64_accton_as5916_54x_config_settings_t x86_64_accton_as5916_54x_config_settings[] = @@ -60,7 +60,7 @@ x86_64_accton_as5916_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5916_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5916_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5916_54x_config_settings[i].name, setting)) { return x86_64_accton_as5916_54x_config_settings[i].value; } } @@ -77,4 +77,4 @@ x86_64_accton_as5916_54x_config_show(struct aim_pvs_s* pvs) return i; } -/* */ \ No newline at end of file +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/Makefile index d25ba602..1918fee4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as5916_54xm AUTOMODULE := x86_64_accton_as5916_54xm include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_config.h index bd0d6786..986e578a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB -#define x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_accton_as5916_54xm_config_lookup(const char* setting); */ int x86_64_accton_as5916_54xm_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_accton_as5916_54xm_porting.h" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_porting.h index 7ae02dc5..95f19041 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/inc/x86_64_accton_as5916_54xm/x86_64_accton_as5916_54xm_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as5916_54xm_MALLOC +#ifndef X86_64_ACCTON_AS5916_54XM_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5916_54xm_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_MALLOC malloc + #define X86_64_ACCTON_AS5916_54XM_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_MALLOC malloc #else - #error The macro x86_64_accton_as5916_54xm_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_FREE +#ifndef X86_64_ACCTON_AS5916_54XM_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5916_54xm_FREE GLOBAL_FREE - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_FREE free + #define X86_64_ACCTON_AS5916_54XM_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_FREE free #else - #error The macro x86_64_accton_as5916_54xm_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_MEMSET +#ifndef X86_64_ACCTON_AS5916_54XM_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5916_54xm_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_MEMSET memset + #define X86_64_ACCTON_AS5916_54XM_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_MEMSET memset #else - #error The macro x86_64_accton_as5916_54xm_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_MEMCPY +#ifndef X86_64_ACCTON_AS5916_54XM_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5916_54xm_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_MEMCPY memcpy + #define X86_64_ACCTON_AS5916_54XM_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_MEMCPY memcpy #else - #error The macro x86_64_accton_as5916_54xm_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_STRNCPY +#ifndef X86_64_ACCTON_AS5916_54XM_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5916_54xm_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_STRNCPY strncpy + #define X86_64_ACCTON_AS5916_54XM_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_STRNCPY strncpy #else - #error The macro x86_64_accton_as5916_54xm_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_VSNPRINTF +#ifndef X86_64_ACCTON_AS5916_54XM_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5916_54xm_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS5916_54XM_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5916_54xm_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_SNPRINTF +#ifndef X86_64_ACCTON_AS5916_54XM_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5916_54xm_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_SNPRINTF snprintf + #define X86_64_ACCTON_AS5916_54XM_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5916_54xm_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54xm_STRLEN +#ifndef X86_64_ACCTON_AS5916_54XM_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5916_54xm_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54xm_STRLEN strlen + #define X86_64_ACCTON_AS5916_54XM_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XM_STRLEN strlen #else - #error The macro x86_64_accton_as5916_54xm_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS5916_54XM_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_config.c index a22a97d3..3ce6044d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(_x) #_x #define __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(_x) x86_64_accton_as5916_54xm_config_settings_t x86_64_accton_as5916_54xm_config_settings[] = { -#ifdef x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5916_54xm_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_54xm_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as5916_54xm_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XM_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_54xm_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as5916_54xm_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as5916_54xm_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5916_54xm_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as5916_54xm_config_settings[i].name, setting)) { return x86_64_accton_as5916_54xm_config_settings[i].value; } } @@ -77,4 +77,4 @@ x86_64_accton_as5916_54xm_config_show(struct aim_pvs_s* pvs) return i; } -/* */ \ No newline at end of file +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_log.c index a29f4d68..39552689 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/x86_64_accton_as5916_54xm_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as5916_54xm log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as5916_54xm_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as5916_54xm_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as5916_54xm_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5916_54XM_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/x86_64_accton_as6712_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/x86_64_accton_as6712_32x_config.c index c07ca3b7..25605628 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/x86_64_accton_as6712_32x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/onlp/builds/src/module/src/x86_64_accton_as6712_32x_config.c @@ -60,7 +60,7 @@ x86_64_accton_as6712_32x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as6712_32x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as6712_32x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as6712_32x_config_settings[i].name, setting)) { return x86_64_accton_as6712_32x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/auto/x86_64_accton_as6812_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/auto/x86_64_accton_as6812_32x.yml index 2d9b1532..254c8db0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/auto/x86_64_accton_as6812_32x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/auto/x86_64_accton_as6812_32x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB -- x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_config.h index 413c3331..50da5596 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_porting.h index f318c6c1..9c3056c1 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/inc/x86_64_accton_as6812_32x/x86_64_accton_as6812_32x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as6812_32x_MALLOC +#ifndef X86_64_ACCTON_AS6812_32X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as6812_32x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_MALLOC malloc + #define X86_64_ACCTON_AS6812_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_MALLOC malloc #else - #error The macro x86_64_accton_as6812_32x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_FREE +#ifndef X86_64_ACCTON_AS6812_32X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as6812_32x_FREE GLOBAL_FREE - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_FREE free + #define X86_64_ACCTON_AS6812_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_FREE free #else - #error The macro x86_64_accton_as6812_32x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_MEMSET +#ifndef X86_64_ACCTON_AS6812_32X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as6812_32x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_MEMSET memset + #define X86_64_ACCTON_AS6812_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_MEMSET memset #else - #error The macro x86_64_accton_as6812_32x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_MEMCPY +#ifndef X86_64_ACCTON_AS6812_32X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as6812_32x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_MEMCPY memcpy + #define X86_64_ACCTON_AS6812_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_MEMCPY memcpy #else - #error The macro x86_64_accton_as6812_32x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_STRNCPY +#ifndef X86_64_ACCTON_AS6812_32X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as6812_32x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_STRNCPY strncpy + #define X86_64_ACCTON_AS6812_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_STRNCPY strncpy #else - #error The macro x86_64_accton_as6812_32x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_VSNPRINTF +#ifndef X86_64_ACCTON_AS6812_32X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as6812_32x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS6812_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as6812_32x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_SNPRINTF +#ifndef X86_64_ACCTON_AS6812_32X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as6812_32x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_SNPRINTF snprintf + #define X86_64_ACCTON_AS6812_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as6812_32x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as6812_32x_STRLEN +#ifndef X86_64_ACCTON_AS6812_32X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as6812_32x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as6812_32x_STRLEN strlen + #define X86_64_ACCTON_AS6812_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS6812_32X_STRLEN strlen #else - #error The macro x86_64_accton_as6812_32x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS6812_32X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_config.c index 44f1b842..75803e73 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(_x) x86_64_accton_as6812_32x_config_settings_t x86_64_accton_as6812_32x_config_settings[] = { -#ifdef x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as6812_32x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as6812_32x_CONFIG_PORTING_STDLIB(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as6812_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as6812_32x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as6812_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as6812_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as6812_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS6812_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as6812_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as6812_32x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as6812_32x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as6812_32x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as6812_32x_config_settings[i].name, setting)) { return x86_64_accton_as6812_32x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_log.c index 5c6d0a8a..29e39cae 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/x86_64_accton_as6812_32x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as6812_32x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as6812_32x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as6812_32x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS6812_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS6812_32X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as6812_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS6812_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/Makefile index 7a1303e2..1c0b82aa 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as7312_54x AUTOMODULE := x86_64_accton_as7312_54x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/auto/x86_64_accton_as7312_54x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/auto/x86_64_accton_as7312_54x.yml index 026d8f8c..a05542b8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/auto/x86_64_accton_as7312_54x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/auto/x86_64_accton_as7312_54x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB -- x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_config.h index ae2df283..7935d75a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5512_54x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_porting.h index 68ab4a21..d891e909 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/inc/x86_64_accton_as7312_54x/x86_64_accton_as7312_54x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as7312_54x_MALLOC +#ifndef X86_64_ACCTON_AS7312_54X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as7312_54x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_MALLOC malloc + #define X86_64_ACCTON_AS7312_54X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_MALLOC malloc #else - #error The macro x86_64_accton_as7312_54x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_FREE +#ifndef X86_64_ACCTON_AS7312_54X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as7312_54x_FREE GLOBAL_FREE - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_FREE free + #define X86_64_ACCTON_AS7312_54X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_FREE free #else - #error The macro x86_64_accton_as7312_54x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_MEMSET +#ifndef X86_64_ACCTON_AS7312_54X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as7312_54x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_MEMSET memset + #define X86_64_ACCTON_AS7312_54X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_MEMSET memset #else - #error The macro x86_64_accton_as7312_54x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_MEMCPY +#ifndef X86_64_ACCTON_AS7312_54X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as7312_54x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_MEMCPY memcpy + #define X86_64_ACCTON_AS7312_54X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_MEMCPY memcpy #else - #error The macro x86_64_accton_as7312_54x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_STRNCPY +#ifndef X86_64_ACCTON_AS7312_54X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as7312_54x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_STRNCPY strncpy + #define X86_64_ACCTON_AS7312_54X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_STRNCPY strncpy #else - #error The macro x86_64_accton_as7312_54x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_VSNPRINTF +#ifndef X86_64_ACCTON_AS7312_54X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as7312_54x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS7312_54X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as7312_54x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_SNPRINTF +#ifndef X86_64_ACCTON_AS7312_54X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as7312_54x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_SNPRINTF snprintf + #define X86_64_ACCTON_AS7312_54X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as7312_54x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7312_54x_STRLEN +#ifndef X86_64_ACCTON_AS7312_54X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as7312_54x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7312_54x_STRLEN strlen + #define X86_64_ACCTON_AS7312_54X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7312_54X_STRLEN strlen #else - #error The macro x86_64_accton_as7312_54x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7312_54X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_config.c index ce0556c5..6c34ea2f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(_x) x86_64_accton_as7312_54x_config_settings_t x86_64_accton_as7312_54x_config_settings[] = { -#ifdef x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as7312_54x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as7312_54x_CONFIG_PORTING_STDLIB(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as7312_54x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as7312_54x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7312_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7312_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as7312_54x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7312_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7312_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as7312_54x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as7312_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as7312_54x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as7312_54x_config_settings[i].name, setting)) { return x86_64_accton_as7312_54x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_log.c index 6d1abf11..594fb103 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/x86_64_accton_as7312_54x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as7312_54x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as7312_54x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as7312_54x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS7312_54X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7312_54X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as7312_54x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS7312_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/Makefile index 0feeb639..c7af4ea6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as7512_32x AUTOMODULE := x86_64_accton_as7512_32x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/auto/x86_64_accton_as7512_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/auto/x86_64_accton_as7512_32x.yml index ce39b017..8bc8e187 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/auto/x86_64_accton_as7512_32x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/auto/x86_64_accton_as7512_32x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB -- x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_config.h index 50021425..4e1e8972 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_porting.h index a1382c54..4c3b0fbd 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/inc/x86_64_accton_as7512_32x/x86_64_accton_as7512_32x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as7512_32x_MALLOC +#ifndef X86_64_ACCTON_AS7512_32X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as7512_32x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_MALLOC malloc + #define X86_64_ACCTON_AS7512_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_MALLOC malloc #else - #error The macro x86_64_accton_as7512_32x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_FREE +#ifndef X86_64_ACCTON_AS7512_32X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as7512_32x_FREE GLOBAL_FREE - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_FREE free + #define X86_64_ACCTON_AS7512_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_FREE free #else - #error The macro x86_64_accton_as7512_32x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_MEMSET +#ifndef X86_64_ACCTON_AS7512_32X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as7512_32x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_MEMSET memset + #define X86_64_ACCTON_AS7512_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_MEMSET memset #else - #error The macro x86_64_accton_as7512_32x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_MEMCPY +#ifndef X86_64_ACCTON_AS7512_32X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as7512_32x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_MEMCPY memcpy + #define X86_64_ACCTON_AS7512_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_MEMCPY memcpy #else - #error The macro x86_64_accton_as7512_32x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_STRNCPY +#ifndef X86_64_ACCTON_AS7512_32X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as7512_32x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_STRNCPY strncpy + #define X86_64_ACCTON_AS7512_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_STRNCPY strncpy #else - #error The macro x86_64_accton_as7512_32x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_VSNPRINTF +#ifndef X86_64_ACCTON_AS7512_32X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as7512_32x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS7512_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as7512_32x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_SNPRINTF +#ifndef X86_64_ACCTON_AS7512_32X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as7512_32x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_SNPRINTF snprintf + #define X86_64_ACCTON_AS7512_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as7512_32x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7512_32x_STRLEN +#ifndef X86_64_ACCTON_AS7512_32X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as7512_32x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7512_32x_STRLEN strlen + #define X86_64_ACCTON_AS7512_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7512_32X_STRLEN strlen #else - #error The macro x86_64_accton_as7512_32x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7512_32X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_config.c index 815faf7f..d7f0bea0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(_x) x86_64_accton_as7512_32x_config_settings_t x86_64_accton_as7512_32x_config_settings[] = { -#ifdef x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as7512_32x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as7512_32x_CONFIG_PORTING_STDLIB(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as7512_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as7512_32x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7512_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7512_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as7512_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7512_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7512_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as7512_32x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as7512_32x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as7512_32x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as7512_32x_config_settings[i].name, setting)) { return x86_64_accton_as7512_32x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_log.c index 6de85a90..4fb99733 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/x86_64_accton_as7512_32x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as7512_32x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as7512_32x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as7512_32x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS7512_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7512_32X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as7512_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS7512_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/Makefile index ad35f444..ff692a6c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as7712_32x AUTOMODULE := x86_64_accton_as7712_32x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/auto/x86_64_accton_as7712_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/auto/x86_64_accton_as7712_32x.yml index b7903852..7c68dfc2 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/auto/x86_64_accton_as7712_32x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/auto/x86_64_accton_as7712_32x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB -- x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_config.h index 5d00420d..0c517a0e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_porting.h index 67643f55..8bca8180 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/inc/x86_64_accton_as7712_32x/x86_64_accton_as7712_32x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as7712_32x_MALLOC +#ifndef X86_64_ACCTON_AS7712_32X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as7712_32x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_MALLOC malloc + #define X86_64_ACCTON_AS7712_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_MALLOC malloc #else - #error The macro x86_64_accton_as7712_32x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_FREE +#ifndef X86_64_ACCTON_AS7712_32X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as7712_32x_FREE GLOBAL_FREE - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_FREE free + #define X86_64_ACCTON_AS7712_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_FREE free #else - #error The macro x86_64_accton_as7712_32x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_MEMSET +#ifndef X86_64_ACCTON_AS7712_32X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as7712_32x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_MEMSET memset + #define X86_64_ACCTON_AS7712_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_MEMSET memset #else - #error The macro x86_64_accton_as7712_32x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_MEMCPY +#ifndef X86_64_ACCTON_AS7712_32X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as7712_32x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_MEMCPY memcpy + #define X86_64_ACCTON_AS7712_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_MEMCPY memcpy #else - #error The macro x86_64_accton_as7712_32x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_STRNCPY +#ifndef X86_64_ACCTON_AS7712_32X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as7712_32x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_STRNCPY strncpy + #define X86_64_ACCTON_AS7712_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_STRNCPY strncpy #else - #error The macro x86_64_accton_as7712_32x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_VSNPRINTF +#ifndef X86_64_ACCTON_AS7712_32X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as7712_32x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS7712_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as7712_32x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_SNPRINTF +#ifndef X86_64_ACCTON_AS7712_32X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as7712_32x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_SNPRINTF snprintf + #define X86_64_ACCTON_AS7712_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as7712_32x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7712_32x_STRLEN +#ifndef X86_64_ACCTON_AS7712_32X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as7712_32x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7712_32x_STRLEN strlen + #define X86_64_ACCTON_AS7712_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7712_32X_STRLEN strlen #else - #error The macro x86_64_accton_as7712_32x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7712_32X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_config.c index 0d16cd49..ac39fe43 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(_x) x86_64_accton_as7712_32x_config_settings_t x86_64_accton_as7712_32x_config_settings[] = { -#ifdef x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as7712_32x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as7712_32x_CONFIG_PORTING_STDLIB(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as7712_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as7712_32x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7712_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7712_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as7712_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7712_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7712_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as7712_32x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as7712_32x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as7712_32x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as7712_32x_config_settings[i].name, setting)) { return x86_64_accton_as7712_32x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_log.c index 561a442e..d53c315e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7712-32x/onlp/builds/src/module/src/x86_64_accton_as7712_32x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as7712_32x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as7712_32x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as7712_32x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS7712_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7712_32X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as7712_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS7712_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/auto/x86_64_accton_as7716_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/auto/x86_64_accton_as7716_32x.yml index 1e8810f9..79257f39 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/auto/x86_64_accton_as7716_32x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/auto/x86_64_accton_as7716_32x.yml @@ -5,28 +5,28 @@ ############################################################################### cdefs: &cdefs -- x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB -- x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI: +- X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_config.h index a988c18b..d6c5519c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_config.h @@ -20,83 +20,83 @@ /* */ #include /** - * x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING -#define x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT -#define x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB -#define x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB #endif /** - * x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI -#define x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_porting.h index 2e236174..c9035882 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/inc/x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as7716_32x_MALLOC +#ifndef X86_64_ACCTON_AS7716_32X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as7716_32x_MALLOC GLOBAL_MALLOC - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_MALLOC malloc + #define X86_64_ACCTON_AS7716_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_MALLOC malloc #else - #error The macro x86_64_accton_as7716_32x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_FREE +#ifndef X86_64_ACCTON_AS7716_32X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as7716_32x_FREE GLOBAL_FREE - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_FREE free + #define X86_64_ACCTON_AS7716_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_FREE free #else - #error The macro x86_64_accton_as7716_32x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_MEMSET +#ifndef X86_64_ACCTON_AS7716_32X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as7716_32x_MEMSET GLOBAL_MEMSET - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_MEMSET memset + #define X86_64_ACCTON_AS7716_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_MEMSET memset #else - #error The macro x86_64_accton_as7716_32x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_MEMCPY +#ifndef X86_64_ACCTON_AS7716_32X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as7716_32x_MEMCPY GLOBAL_MEMCPY - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_MEMCPY memcpy + #define X86_64_ACCTON_AS7716_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_MEMCPY memcpy #else - #error The macro x86_64_accton_as7716_32x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_STRNCPY +#ifndef X86_64_ACCTON_AS7716_32X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as7716_32x_STRNCPY GLOBAL_STRNCPY - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_STRNCPY strncpy + #define X86_64_ACCTON_AS7716_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_STRNCPY strncpy #else - #error The macro x86_64_accton_as7716_32x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_VSNPRINTF +#ifndef X86_64_ACCTON_AS7716_32X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as7716_32x_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS7716_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as7716_32x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_SNPRINTF +#ifndef X86_64_ACCTON_AS7716_32X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as7716_32x_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_SNPRINTF snprintf + #define X86_64_ACCTON_AS7716_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as7716_32x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7716_32x_STRLEN +#ifndef X86_64_ACCTON_AS7716_32X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as7716_32x_STRLEN GLOBAL_STRLEN - #elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7716_32x_STRLEN strlen + #define X86_64_ACCTON_AS7716_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7716_32X_STRLEN strlen #else - #error The macro x86_64_accton_as7716_32x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7716_32X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_config.c index cf578178..e616487e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_config.c @@ -10,45 +10,45 @@ #define __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(_x) x86_64_accton_as7716_32x_config_settings_t x86_64_accton_as7716_32x_config_settings[] = { -#ifdef x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7716_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7716_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS7716_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7716_32x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_accton_as7716_32x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as7716_32x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as7716_32x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as7716_32x_config_settings[i].name, setting)) { return x86_64_accton_as7716_32x_config_settings[i].value; } } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_log.c index ff3808ad..d31e0eec 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/onlp/builds/src/module/src/x86_64_accton_as7716_32x_log.c @@ -10,9 +10,8 @@ * x86_64_accton_as7716_32x log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS7716_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7716_32X_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS7716_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile index bb75e4bf..62cba010 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as7816_64x AUTOMODULE := x86_64_accton_as7816_64x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h index bb203a77..89f9c762 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/inc/x86_64_accton_as7816_64x/x86_64_accton_as7816_64x_porting.h @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_accton_as7816_64x_MALLOC +#ifndef X86_64_ACCTON_AS7816_64X_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as7816_64x_MALLOC GLOBAL_MALLOC + #define X86_64_ACCTON_AS7816_64X_MALLOC GLOBAL_MALLOC #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_MALLOC malloc + #define X86_64_ACCTON_AS7816_64X_MALLOC malloc #else - #error The macro x86_64_accton_as7816_64x_MALLOC is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_FREE +#ifndef X86_64_ACCTON_AS7816_64X_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as7816_64x_FREE GLOBAL_FREE + #define X86_64_ACCTON_AS7816_64X_FREE GLOBAL_FREE #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_FREE free + #define X86_64_ACCTON_AS7816_64X_FREE free #else - #error The macro x86_64_accton_as7816_64x_FREE is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_MEMSET +#ifndef X86_64_ACCTON_AS7816_64X_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as7816_64x_MEMSET GLOBAL_MEMSET + #define X86_64_ACCTON_AS7816_64X_MEMSET GLOBAL_MEMSET #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_MEMSET memset + #define X86_64_ACCTON_AS7816_64X_MEMSET memset #else - #error The macro x86_64_accton_as7816_64x_MEMSET is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_MEMCPY +#ifndef X86_64_ACCTON_AS7816_64X_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as7816_64x_MEMCPY GLOBAL_MEMCPY + #define X86_64_ACCTON_AS7816_64X_MEMCPY GLOBAL_MEMCPY #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_MEMCPY memcpy + #define X86_64_ACCTON_AS7816_64X_MEMCPY memcpy #else - #error The macro x86_64_accton_as7816_64x_MEMCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_STRNCPY +#ifndef X86_64_ACCTON_AS7816_64X_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as7816_64x_STRNCPY GLOBAL_STRNCPY + #define X86_64_ACCTON_AS7816_64X_STRNCPY GLOBAL_STRNCPY #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_STRNCPY strncpy + #define X86_64_ACCTON_AS7816_64X_STRNCPY strncpy #else - #error The macro x86_64_accton_as7816_64x_STRNCPY is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_VSNPRINTF +#ifndef X86_64_ACCTON_AS7816_64X_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as7816_64x_VSNPRINTF GLOBAL_VSNPRINTF + #define X86_64_ACCTON_AS7816_64X_VSNPRINTF GLOBAL_VSNPRINTF #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_VSNPRINTF vsnprintf + #define X86_64_ACCTON_AS7816_64X_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as7816_64x_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_SNPRINTF +#ifndef X86_64_ACCTON_AS7816_64X_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as7816_64x_SNPRINTF GLOBAL_SNPRINTF + #define X86_64_ACCTON_AS7816_64X_SNPRINTF GLOBAL_SNPRINTF #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_SNPRINTF snprintf + #define X86_64_ACCTON_AS7816_64X_SNPRINTF snprintf #else - #error The macro x86_64_accton_as7816_64x_SNPRINTF is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as7816_64x_STRLEN +#ifndef X86_64_ACCTON_AS7816_64X_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as7816_64x_STRLEN GLOBAL_STRLEN + #define X86_64_ACCTON_AS7816_64X_STRLEN GLOBAL_STRLEN #elif X86_64_ACCTON_AS7816_64X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as7816_64x_STRLEN strlen + #define X86_64_ACCTON_AS7816_64X_STRLEN strlen #else - #error The macro x86_64_accton_as7816_64x_STRLEN is required but cannot be defined. + #error The macro X86_64_ACCTON_AS7816_64X_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c index 46c2b302..2db567e4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/x86_64_accton_as7816_64x_config.c @@ -5,7 +5,7 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(_x) #_x #define __x86_64_accton_as7816_64x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7816_64x_config_STRINGIFY_NAME(_x) x86_64_accton_as7816_64x_config_settings_t x86_64_accton_as7816_64x_config_settings[] = @@ -60,7 +60,7 @@ x86_64_accton_as7816_64x_config_lookup(const char* setting) { int i; for(i = 0; x86_64_accton_as7816_64x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as7816_64x_config_settings[i].name, setting)) { + if(!strcmp(x86_64_accton_as7816_64x_config_settings[i].name, setting)) { return x86_64_accton_as7816_64x_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_accton_as7816_64x_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile index 8a3d285e..029f491d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_wedge100_32x AUTOMODULE := x86_64_accton_wedge100_32x include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h index c0a2c1ba..3f6e3d49 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_config.h @@ -18,117 +18,117 @@ #endif /* */ -#include -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_accton_wedge100_32x_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_accton_wedge100_32x_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_accton_wedge100_32x_config_settings table. */ -extern x86_64_accton_wedge100_32x_config_settings_t x86_64_accton_wedge100_32x_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_accton_wedge100_32x_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_accton_wedge100_32x_config_show(struct aim_pvs_s* pvs); - +#include +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_wedge100_32x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_wedge100_32x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_wedge100_32x_config_settings table. */ +extern x86_64_accton_wedge100_32x_config_settings_t x86_64_accton_wedge100_32x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_wedge100_32x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_wedge100_32x_config_show(struct aim_pvs_s* pvs); + /* */ #include "x86_64_accton_wedge100_32x_porting.h" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h index 7f6d1730..4b6d6ad6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/inc/x86_64_accton_wedge100_32x/x86_64_accton_wedge100_32x_porting.h @@ -12,94 +12,94 @@ /* */ -#if X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef x86_64_accton_wedge100_32x_MALLOC - #if defined(GLOBAL_MALLOC) - #define x86_64_accton_wedge100_32x_MALLOC GLOBAL_MALLOC - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_MALLOC malloc - #else - #error The macro x86_64_accton_wedge100_32x_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_FREE - #if defined(GLOBAL_FREE) - #define x86_64_accton_wedge100_32x_FREE GLOBAL_FREE - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_FREE free - #else - #error The macro x86_64_accton_wedge100_32x_FREE is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_MEMSET - #if defined(GLOBAL_MEMSET) - #define x86_64_accton_wedge100_32x_MEMSET GLOBAL_MEMSET - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_MEMSET memset - #else - #error The macro x86_64_accton_wedge100_32x_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_wedge100_32x_MEMCPY GLOBAL_MEMCPY - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_MEMCPY memcpy - #else - #error The macro x86_64_accton_wedge100_32x_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_wedge100_32x_STRNCPY GLOBAL_STRNCPY - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_STRNCPY strncpy - #else - #error The macro x86_64_accton_wedge100_32x_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_wedge100_32x_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_VSNPRINTF vsnprintf - #else - #error The macro x86_64_accton_wedge100_32x_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_wedge100_32x_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_SNPRINTF snprintf - #else - #error The macro x86_64_accton_wedge100_32x_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_accton_wedge100_32x_STRLEN - #if defined(GLOBAL_STRLEN) - #define x86_64_accton_wedge100_32x_STRLEN GLOBAL_STRLEN - #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_wedge100_32x_STRLEN strlen - #else - #error The macro x86_64_accton_wedge100_32x_STRLEN is required but cannot be defined. - #endif -#endif - +#if X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_ACCTON_WEDGE100_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_MALLOC malloc + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_FREE + #if defined(GLOBAL_FREE) + #define X86_64_ACCTON_WEDGE100_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_FREE free + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_ACCTON_WEDGE100_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_MEMSET memset + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_ACCTON_WEDGE100_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_MEMCPY memcpy + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_ACCTON_WEDGE100_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_STRNCPY strncpy + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_ACCTON_WEDGE100_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_VSNPRINTF vsnprintf + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_ACCTON_WEDGE100_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_SNPRINTF snprintf + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_WEDGE100_32X_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_ACCTON_WEDGE100_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_WEDGE100_32X_STRLEN strlen + #else + #error The macro X86_64_ACCTON_WEDGE100_32X_STRLEN is required but cannot be defined. + #endif +#endif + /* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c index ad80014f..fcf89a46 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100-32x/onlp/builds/src/module/src/x86_64_accton_wedge100_32x_config.c @@ -5,76 +5,76 @@ *****************************************************************************/ #include -/* */ -#define __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(_x) -x86_64_accton_wedge100_32x_config_settings_t x86_64_accton_wedge100_32x_config_settings[] = -{ -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE -#undef __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME - -const char* -x86_64_accton_wedge100_32x_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_accton_wedge100_32x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_wedge100_32x_config_settings[i].name, setting)) { - return x86_64_accton_wedge100_32x_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_accton_wedge100_32x_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_accton_wedge100_32x_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_accton_wedge100_32x_config_settings[i].name, x86_64_accton_wedge100_32x_config_settings[i].value); - } - return i; -} - -/* */ \ No newline at end of file +/* */ +#define __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(_x) +x86_64_accton_wedge100_32x_config_settings_t x86_64_accton_wedge100_32x_config_settings[] = +{ +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_WEDGE100_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_wedge100_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_wedge100_32x_config_STRINGIFY_VALUE +#undef __x86_64_accton_wedge100_32x_config_STRINGIFY_NAME + +const char* +x86_64_accton_wedge100_32x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_wedge100_32x_config_settings[i].name; i++) { + if(!strcmp(x86_64_accton_wedge100_32x_config_settings[i].name, setting)) { + return x86_64_accton_wedge100_32x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_wedge100_32x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_wedge100_32x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_wedge100_32x_config_settings[i].name, x86_64_accton_wedge100_32x_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/module/src/x86_64_alphanetworks_snx60a0_486f_config.c b/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/module/src/x86_64_alphanetworks_snx60a0_486f_config.c index 9f172282..904a62fb 100644 --- a/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/module/src/x86_64_alphanetworks_snx60a0_486f_config.c +++ b/packages/platforms/alphanetworks/x86-64/x86-64-alphanetworks-snx60a0-486f/onlp/builds/src/x86_64_alphanetworks_snx60a0_486f/module/src/x86_64_alphanetworks_snx60a0_486f_config.c @@ -55,7 +55,7 @@ x86_64_alphanetworks_snx60a0_486f_config_lookup(const char* setting) { int i; for(i = 0; x86_64_alphanetworks_snx60a0_486f_config_settings[i].name; i++) { - if(strcmp(x86_64_alphanetworks_snx60a0_486f_config_settings[i].name, setting)) { + if(!strcmp(x86_64_alphanetworks_snx60a0_486f_config_settings[i].name, setting)) { return x86_64_alphanetworks_snx60a0_486f_config_settings[i].value; } } diff --git a/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/module/src/x86_64_cel_redstone_xp_config.c b/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/module/src/x86_64_cel_redstone_xp_config.c index a988fcde..6e257e88 100644 --- a/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/module/src/x86_64_cel_redstone_xp_config.c +++ b/packages/platforms/celestica/x86-64/x86-64-cel-redstone-xp/onlp/builds/src/module/src/x86_64_cel_redstone_xp_config.c @@ -55,7 +55,7 @@ x86_64_cel_redstone_xp_config_lookup(const char* setting) { int i; for(i = 0; x86_64_cel_redstone_xp_config_settings[i].name; i++) { - if(strcmp(x86_64_cel_redstone_xp_config_settings[i].name, setting)) { + if(!strcmp(x86_64_cel_redstone_xp_config_settings[i].name, setting)) { return x86_64_cel_redstone_xp_config_settings[i].value; } } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/Makefile index d7cc3764..98876c68 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/Makefile +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_delta_ag5648 AUTOMODULE := x86_64_delta_ag5648 include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_config.h index dd1200bd..0041a48f 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_config.h @@ -76,7 +76,7 @@ #ifndef X86_64_DELTA_AG5648_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_DELTA_AG5648_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG5648_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_delta_ag5648_CONFIG_PORTING_STDLIB #endif /** diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_porting.h index 2512d3d7..477c4e1e 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_porting.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/inc/x86_64_delta_ag5648/x86_64_delta_ag5648_porting.h @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_delta_ag5648_MALLOC +#ifndef X86_64_DELTA_AG5648_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_delta_ag5648_MALLOC GLOBAL_MALLOC + #define X86_64_DELTA_AG5648_MALLOC GLOBAL_MALLOC #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_MALLOC malloc + #define X86_64_DELTA_AG5648_MALLOC malloc #else - #error The macro x86_64_delta_ag5648_MALLOC is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_FREE +#ifndef X86_64_DELTA_AG5648_FREE #if defined(GLOBAL_FREE) - #define x86_64_delta_ag5648_FREE GLOBAL_FREE + #define X86_64_DELTA_AG5648_FREE GLOBAL_FREE #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_FREE free + #define X86_64_DELTA_AG5648_FREE free #else - #error The macro x86_64_delta_ag5648_FREE is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_MEMSET +#ifndef X86_64_DELTA_AG5648_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_delta_ag5648_MEMSET GLOBAL_MEMSET + #define X86_64_DELTA_AG5648_MEMSET GLOBAL_MEMSET #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_MEMSET memset + #define X86_64_DELTA_AG5648_MEMSET memset #else - #error The macro x86_64_delta_ag5648_MEMSET is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_MEMCPY +#ifndef X86_64_DELTA_AG5648_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_delta_ag5648_MEMCPY GLOBAL_MEMCPY + #define X86_64_DELTA_AG5648_MEMCPY GLOBAL_MEMCPY #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_MEMCPY memcpy + #define X86_64_DELTA_AG5648_MEMCPY memcpy #else - #error The macro x86_64_delta_ag5648_MEMCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_STRNCPY +#ifndef X86_64_DELTA_AG5648_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_delta_ag5648_STRNCPY GLOBAL_STRNCPY + #define X86_64_DELTA_AG5648_STRNCPY GLOBAL_STRNCPY #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_STRNCPY strncpy + #define X86_64_DELTA_AG5648_STRNCPY strncpy #else - #error The macro x86_64_delta_ag5648_STRNCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_VSNPRINTF +#ifndef X86_64_DELTA_AG5648_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_delta_ag5648_VSNPRINTF GLOBAL_VSNPRINTF + #define X86_64_DELTA_AG5648_VSNPRINTF GLOBAL_VSNPRINTF #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_VSNPRINTF vsnprintf + #define X86_64_DELTA_AG5648_VSNPRINTF vsnprintf #else - #error The macro x86_64_delta_ag5648_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_SNPRINTF +#ifndef X86_64_DELTA_AG5648_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_delta_ag5648_SNPRINTF GLOBAL_SNPRINTF + #define X86_64_DELTA_AG5648_SNPRINTF GLOBAL_SNPRINTF #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_SNPRINTF snprintf + #define X86_64_DELTA_AG5648_SNPRINTF snprintf #else - #error The macro x86_64_delta_ag5648_SNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag5648_STRLEN +#ifndef X86_64_DELTA_AG5648_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_delta_ag5648_STRLEN GLOBAL_STRLEN + #define X86_64_DELTA_AG5648_STRLEN GLOBAL_STRLEN #elif X86_64_DELTA_AG5648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag5648_STRLEN strlen + #define X86_64_DELTA_AG5648_STRLEN strlen #else - #error The macro x86_64_delta_ag5648_STRLEN is required but cannot be defined. + #error The macro X86_64_DELTA_AG5648_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/x86_64_delta_ag5648_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/x86_64_delta_ag5648_config.c index 51a71397..390a8bc0 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/x86_64_delta_ag5648_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/x86_64_delta_ag5648_config.c @@ -60,7 +60,7 @@ x86_64_delta_ag5648_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_ag5648_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_ag5648_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_ag5648_config_settings[i].name, setting)) { return x86_64_delta_ag5648_config_settings[i].value; } } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/Makefile index d779a0df..adad174b 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/Makefile +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_delta_ag7648 AUTOMODULE := x86_64_delta_ag7648 include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/inc/x86_64_delta_ag7648/x86_64_delta_ag7648_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/inc/x86_64_delta_ag7648/x86_64_delta_ag7648_porting.h index 0ace6735..025c6102 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/inc/x86_64_delta_ag7648/x86_64_delta_ag7648_porting.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/inc/x86_64_delta_ag7648/x86_64_delta_ag7648_porting.h @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_delta_ag7648_MALLOC +#ifndef X86_64_DELTA_AG7648_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_delta_ag7648_MALLOC GLOBAL_MALLOC + #define X86_64_DELTA_AG7648_MALLOC GLOBAL_MALLOC #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_MALLOC malloc + #define X86_64_DELTA_AG7648_MALLOC malloc #else - #error The macro x86_64_delta_ag7648_MALLOC is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_FREE +#ifndef X86_64_DELTA_AG7648_FREE #if defined(GLOBAL_FREE) - #define x86_64_delta_ag7648_FREE GLOBAL_FREE + #define X86_64_DELTA_AG7648_FREE GLOBAL_FREE #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_FREE free + #define X86_64_DELTA_AG7648_FREE free #else - #error The macro x86_64_delta_ag7648_FREE is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_MEMSET +#ifndef X86_64_DELTA_AG7648_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_delta_ag7648_MEMSET GLOBAL_MEMSET + #define X86_64_DELTA_AG7648_MEMSET GLOBAL_MEMSET #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_MEMSET memset + #define X86_64_DELTA_AG7648_MEMSET memset #else - #error The macro x86_64_delta_ag7648_MEMSET is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_MEMCPY +#ifndef X86_64_DELTA_AG7648_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_delta_ag7648_MEMCPY GLOBAL_MEMCPY + #define X86_64_DELTA_AG7648_MEMCPY GLOBAL_MEMCPY #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_MEMCPY memcpy + #define X86_64_DELTA_AG7648_MEMCPY memcpy #else - #error The macro x86_64_delta_ag7648_MEMCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_STRNCPY +#ifndef X86_64_DELTA_AG7648_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_delta_ag7648_STRNCPY GLOBAL_STRNCPY + #define X86_64_DELTA_AG7648_STRNCPY GLOBAL_STRNCPY #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_STRNCPY strncpy + #define X86_64_DELTA_AG7648_STRNCPY strncpy #else - #error The macro x86_64_delta_ag7648_STRNCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_VSNPRINTF +#ifndef X86_64_DELTA_AG7648_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_delta_ag7648_VSNPRINTF GLOBAL_VSNPRINTF + #define X86_64_DELTA_AG7648_VSNPRINTF GLOBAL_VSNPRINTF #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_VSNPRINTF vsnprintf + #define X86_64_DELTA_AG7648_VSNPRINTF vsnprintf #else - #error The macro x86_64_delta_ag7648_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_SNPRINTF +#ifndef X86_64_DELTA_AG7648_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_delta_ag7648_SNPRINTF GLOBAL_SNPRINTF + #define X86_64_DELTA_AG7648_SNPRINTF GLOBAL_SNPRINTF #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_SNPRINTF snprintf + #define X86_64_DELTA_AG7648_SNPRINTF snprintf #else - #error The macro x86_64_delta_ag7648_SNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag7648_STRLEN +#ifndef X86_64_DELTA_AG7648_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_delta_ag7648_STRLEN GLOBAL_STRLEN + #define X86_64_DELTA_AG7648_STRLEN GLOBAL_STRLEN #elif X86_64_DELTA_AG7648_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag7648_STRLEN strlen + #define X86_64_DELTA_AG7648_STRLEN strlen #else - #error The macro x86_64_delta_ag7648_STRLEN is required but cannot be defined. + #error The macro X86_64_DELTA_AG7648_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/x86_64_delta_ag7648_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/x86_64_delta_ag7648_config.c index 7b2e8138..fcfad073 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/x86_64_delta_ag7648_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648/onlp/builds/src/module/src/x86_64_delta_ag7648_config.c @@ -60,7 +60,7 @@ x86_64_delta_ag7648_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_ag7648_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_ag7648_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_ag7648_config_settings[i].name, setting)) { return x86_64_delta_ag7648_config_settings[i].value; } } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/Makefile index 3a0fd16c..f49dcf3d 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/Makefile +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_delta_ag9032v1 AUTOMODULE := x86_64_delta_ag9032v1 include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_config.h index 7b9b8e5d..25224385 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_config.h @@ -76,7 +76,7 @@ #ifndef X86_64_DELTA_AG9032V1_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_DELTA_AG9032V1_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG9032V1_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_delta_ag9032v1_CONFIG_PORTING_STDLIB #endif /** diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_porting.h index 33415c46..bd149077 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_porting.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/inc/x86_64_delta_ag9032v1/x86_64_delta_ag9032v1_porting.h @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_delta_ag9032v1_MALLOC +#ifndef X86_64_DELTA_AG9032V1_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_delta_ag9032v1_MALLOC GLOBAL_MALLOC + #define X86_64_DELTA_AG9032V1_MALLOC GLOBAL_MALLOC #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_MALLOC malloc + #define X86_64_DELTA_AG9032V1_MALLOC malloc #else - #error The macro x86_64_delta_ag9032v1_MALLOC is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_FREE +#ifndef X86_64_DELTA_AG9032V1_FREE #if defined(GLOBAL_FREE) - #define x86_64_delta_ag9032v1_FREE GLOBAL_FREE + #define X86_64_DELTA_AG9032V1_FREE GLOBAL_FREE #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_FREE free + #define X86_64_DELTA_AG9032V1_FREE free #else - #error The macro x86_64_delta_ag9032v1_FREE is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_MEMSET +#ifndef X86_64_DELTA_AG9032V1_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_delta_ag9032v1_MEMSET GLOBAL_MEMSET + #define X86_64_DELTA_AG9032V1_MEMSET GLOBAL_MEMSET #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_MEMSET memset + #define X86_64_DELTA_AG9032V1_MEMSET memset #else - #error The macro x86_64_delta_ag9032v1_MEMSET is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_MEMCPY +#ifndef X86_64_DELTA_AG9032V1_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_delta_ag9032v1_MEMCPY GLOBAL_MEMCPY + #define X86_64_DELTA_AG9032V1_MEMCPY GLOBAL_MEMCPY #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_MEMCPY memcpy + #define X86_64_DELTA_AG9032V1_MEMCPY memcpy #else - #error The macro x86_64_delta_ag9032v1_MEMCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_STRNCPY +#ifndef X86_64_DELTA_AG9032V1_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_delta_ag9032v1_STRNCPY GLOBAL_STRNCPY + #define X86_64_DELTA_AG9032V1_STRNCPY GLOBAL_STRNCPY #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_STRNCPY strncpy + #define X86_64_DELTA_AG9032V1_STRNCPY strncpy #else - #error The macro x86_64_delta_ag9032v1_STRNCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_VSNPRINTF +#ifndef X86_64_DELTA_AG9032V1_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_delta_ag9032v1_VSNPRINTF GLOBAL_VSNPRINTF + #define X86_64_DELTA_AG9032V1_VSNPRINTF GLOBAL_VSNPRINTF #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_VSNPRINTF vsnprintf + #define X86_64_DELTA_AG9032V1_VSNPRINTF vsnprintf #else - #error The macro x86_64_delta_ag9032v1_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_SNPRINTF +#ifndef X86_64_DELTA_AG9032V1_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_delta_ag9032v1_SNPRINTF GLOBAL_SNPRINTF + #define X86_64_DELTA_AG9032V1_SNPRINTF GLOBAL_SNPRINTF #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_SNPRINTF snprintf + #define X86_64_DELTA_AG9032V1_SNPRINTF snprintf #else - #error The macro x86_64_delta_ag9032v1_SNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v1_STRLEN +#ifndef X86_64_DELTA_AG9032V1_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_delta_ag9032v1_STRLEN GLOBAL_STRLEN + #define X86_64_DELTA_AG9032V1_STRLEN GLOBAL_STRLEN #elif X86_64_DELTA_AG9032V1_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v1_STRLEN strlen + #define X86_64_DELTA_AG9032V1_STRLEN strlen #else - #error The macro x86_64_delta_ag9032v1_STRLEN is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V1_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/x86_64_delta_ag9032v1_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/x86_64_delta_ag9032v1_config.c index c0d9a849..96ca1ac2 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/x86_64_delta_ag9032v1_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v1/onlp/builds/src/module/src/x86_64_delta_ag9032v1_config.c @@ -60,7 +60,7 @@ x86_64_delta_ag9032v1_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_ag9032v1_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_ag9032v1_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_ag9032v1_config_settings[i].name, setting)) { return x86_64_delta_ag9032v1_config_settings[i].value; } } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml index eab5e217..a097592f 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/auto/x86_64_delta_ag9032v2.yml @@ -5,40 +5,40 @@ ############################################################################### cdefs: &cdefs -- X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_LOGGING: +- X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- X86_64_DELTA_ag9032v2_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_DELTA_ag9032v2_CONFIG_LOG_BITS_DEFAULT: +- X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- X86_64_DELTA_ag9032v2_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB: +- X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- X86_64_DELTA_ag9032v2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB -- X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_UCLI: +- X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 -- X86_64_DELTA_ag9032v2_CONFIG_SFP_COUNT: +- X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT: doc: "SFP port numbers." default: 4 -- X86_64_DELTA_ag9032v2_CONFIG_FAN_RPM_MAX: +- X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX: doc: "Max fan speed." default: 18000 definitions: cdefs: - X86_64_DELTA_ag9032v2_CONFIG_HEADER: + X86_64_DELTA_AG9032V2_CONFIG_HEADER: defs: *cdefs basename: x86_64_delta_ag9032v2_config diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h index 23042b1d..9ce882b1 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_config.h @@ -17,10 +17,10 @@ #include #endif -/* */ +/* */ #include /** - * X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_LOGGING + * X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ @@ -30,7 +30,7 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_DELTA_AG9032V2_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ @@ -40,7 +40,7 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_LOG_BITS_DEFAULT + * X86_64_DELTA_AG9032V2_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ @@ -50,7 +50,7 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_DELTA_AG9032V2_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ @@ -60,7 +60,7 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB + * X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ @@ -70,17 +70,17 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ #ifndef X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG9032V2_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_ag9032v2_CONFIG_PORTING_STDLIB #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_UCLI + * X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ @@ -90,7 +90,7 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ @@ -100,25 +100,27 @@ #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_SFP_COUNT + * X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT * * SFP port numbers. */ - - + + #ifndef X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT #define X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT 4 #endif /** - * X86_64_DELTA_ag9032v2_CONFIG_FAN_RPM_MAX + * X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX * * Max fan speed. */ - - + + #ifndef X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX #define X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX 18000 #endif + + /** * All compile time options can be queried or displayed */ @@ -147,7 +149,7 @@ const char* x86_64_delta_ag9032v2_config_lookup(const char* setting); */ int x86_64_delta_ag9032v2_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_delta_ag9032v2_porting.h" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h index 43ba283a..e792e33b 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/inc/x86_64_delta_ag9032v2/x86_64_delta_ag9032v2_porting.h @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_delta_ag9032v2_MALLOC +#ifndef X86_64_DELTA_AG9032V2_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_delta_ag9032v2_MALLOC GLOBAL_MALLOC + #define X86_64_DELTA_AG9032V2_MALLOC GLOBAL_MALLOC #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_MALLOC malloc + #define X86_64_DELTA_AG9032V2_MALLOC malloc #else - #error The macro x86_64_delta_ag9032v2_MALLOC is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_FREE +#ifndef X86_64_DELTA_AG9032V2_FREE #if defined(GLOBAL_FREE) - #define x86_64_delta_ag9032v2_FREE GLOBAL_FREE + #define X86_64_DELTA_AG9032V2_FREE GLOBAL_FREE #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_FREE free + #define X86_64_DELTA_AG9032V2_FREE free #else - #error The macro x86_64_delta_ag9032v2_FREE is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_MEMSET +#ifndef X86_64_DELTA_AG9032V2_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_delta_ag9032v2_MEMSET GLOBAL_MEMSET + #define X86_64_DELTA_AG9032V2_MEMSET GLOBAL_MEMSET #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_MEMSET memset + #define X86_64_DELTA_AG9032V2_MEMSET memset #else - #error The macro x86_64_delta_ag9032v2_MEMSET is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_MEMCPY +#ifndef X86_64_DELTA_AG9032V2_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_delta_ag9032v2_MEMCPY GLOBAL_MEMCPY + #define X86_64_DELTA_AG9032V2_MEMCPY GLOBAL_MEMCPY #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_MEMCPY memcpy + #define X86_64_DELTA_AG9032V2_MEMCPY memcpy #else - #error The macro x86_64_delta_ag9032v2_MEMCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_STRNCPY +#ifndef X86_64_DELTA_AG9032V2_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_delta_ag9032v2_STRNCPY GLOBAL_STRNCPY + #define X86_64_DELTA_AG9032V2_STRNCPY GLOBAL_STRNCPY #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_STRNCPY strncpy + #define X86_64_DELTA_AG9032V2_STRNCPY strncpy #else - #error The macro x86_64_delta_ag9032v2_STRNCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_VSNPRINTF +#ifndef X86_64_DELTA_AG9032V2_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_delta_ag9032v2_VSNPRINTF GLOBAL_VSNPRINTF + #define X86_64_DELTA_AG9032V2_VSNPRINTF GLOBAL_VSNPRINTF #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_VSNPRINTF vsnprintf + #define X86_64_DELTA_AG9032V2_VSNPRINTF vsnprintf #else - #error The macro x86_64_delta_ag9032v2_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_SNPRINTF +#ifndef X86_64_DELTA_AG9032V2_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_delta_ag9032v2_SNPRINTF GLOBAL_SNPRINTF + #define X86_64_DELTA_AG9032V2_SNPRINTF GLOBAL_SNPRINTF #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_SNPRINTF snprintf + #define X86_64_DELTA_AG9032V2_SNPRINTF snprintf #else - #error The macro x86_64_delta_ag9032v2_SNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_ag9032v2_STRLEN +#ifndef X86_64_DELTA_AG9032V2_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_delta_ag9032v2_STRLEN GLOBAL_STRLEN + #define X86_64_DELTA_AG9032V2_STRLEN GLOBAL_STRLEN #elif X86_64_DELTA_AG9032V2_CONFIG_PORTING_STDLIB == 1 - #define x86_64_delta_ag9032v2_STRLEN strlen + #define X86_64_DELTA_AG9032V2_STRLEN strlen #else - #error The macro x86_64_delta_ag9032v2_STRLEN is required but cannot be defined. + #error The macro X86_64_DELTA_AG9032V2_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c index 95a5a6d2..092d72cc 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9032v2/onlp/builds/src/module/src/x86_64_delta_ag9032v2_config.c @@ -49,6 +49,16 @@ x86_64_delta_ag9032v2_config_settings_t x86_64_delta_ag9032v2_config_settings[] { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else { X86_64_DELTA_AG9032V2_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_SFP_COUNT(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX + { __x86_64_delta_ag9032v2_config_STRINGIFY_NAME(X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX), __x86_64_delta_ag9032v2_config_STRINGIFY_VALUE(X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX) }, +#else +{ X86_64_DELTA_AG9032V2_CONFIG_FAN_RPM_MAX(__x86_64_delta_ag9032v2_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +70,7 @@ x86_64_delta_ag9032v2_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_ag9032v2_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_ag9032v2_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_ag9032v2_config_settings[i].name, setting)) { return x86_64_delta_ag9032v2_config_settings[i].value; } } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h index d05c32d5..7fabb02c 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/inc/x86_64_delta_ag9064/x86_64_delta_ag9064_config.h @@ -103,8 +103,8 @@ * X86_64_DELTA_AG9064_CONFIG_SFP_COUNT * * SFP port numbers. */ - - + + #ifndef X86_64_DELTA_AG9064_CONFIG_SFP_COUNT #define X86_64_DELTA_AG9064_CONFIG_SFP_COUNT 64 #endif @@ -113,12 +113,14 @@ * X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX * * Max fan speed. */ - - + + #ifndef X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX #define X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX 13000 #endif + + /** * All compile time options can be queried or displayed */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c index 1f528e25..1e187646 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag9064/onlp/builds/src/module/src/x86_64_delta_ag9064_config.c @@ -7,7 +7,7 @@ #include -/* */ +/* */ #define __x86_64_delta_ag9064_config_STRINGIFY_NAME(_x) #_x #define __x86_64_delta_ag9064_config_STRINGIFY_VALUE(_x) __x86_64_delta_ag9064_config_STRINGIFY_NAME(_x) x86_64_delta_ag9064_config_settings_t x86_64_delta_ag9064_config_settings[] = @@ -72,7 +72,7 @@ x86_64_delta_ag9064_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_ag9064_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_ag9064_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_ag9064_config_settings[i].name, setting)) { return x86_64_delta_ag9064_config_settings[i].value; } } @@ -89,5 +89,4 @@ x86_64_delta_ag9064_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h index 84a12c42..e66a8d9e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/inc/x86_64_delta_agc5648s/x86_64_delta_agc5648s_config.h @@ -103,22 +103,24 @@ * X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT * * SFP port numbers. */ - - + + #ifndef X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT -#define X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT 54 +#define X86_64_DELTA_AGC5648S_CONFIG_SFP_COUNT 4 #endif /** * X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX * * Max fan speed. */ - - + + #ifndef X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX -#define X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX 23000 +#define X86_64_DELTA_AGC5648S_CONFIG_FAN_RPM_MAX 18000 #endif + + /** * All compile time options can be queried or displayed */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c index 8b9a6d22..374656ff 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc5648s/onlp/builds/src/module/src/x86_64_delta_agc5648s_config.c @@ -7,7 +7,7 @@ #include -/* */ +/* */ #define __x86_64_delta_agc5648s_config_STRINGIFY_NAME(_x) #_x #define __x86_64_delta_agc5648s_config_STRINGIFY_VALUE(_x) __x86_64_delta_agc5648s_config_STRINGIFY_NAME(_x) x86_64_delta_agc5648s_config_settings_t x86_64_delta_agc5648s_config_settings[] = @@ -72,7 +72,7 @@ x86_64_delta_agc5648s_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_agc5648s_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_agc5648s_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_agc5648s_config_settings[i].name, setting)) { return x86_64_delta_agc5648s_config_settings[i].value; } } @@ -89,5 +89,4 @@ x86_64_delta_agc5648s_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/Makefile index c5a687e1..43020152 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/Makefile +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_delta_agc7648a AUTOMODULE := x86_64_delta_agc7648a include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/auto/x86_64_delta_agc7648a.yml b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/auto/x86_64_delta_agc7648a.yml index 22acd94b..1202f34a 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/auto/x86_64_delta_agc7648a.yml +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/auto/x86_64_delta_agc7648a.yml @@ -8,22 +8,22 @@ cdefs: &cdefs - X86_64_DELTA_AGC7648A_CONFIGINCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT: +- X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT: +- X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT: +- X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB: +- X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." default: X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB -- X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI: +- X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 - X86_64_DELTA_AGC7648A_CONFIGINCLUDE_DEFAULT_FAN_DIRECTION: @@ -33,7 +33,7 @@ cdefs: &cdefs definitions: cdefs: - X86_64_DELTA_AGC7648A_CONFIGHEADER: + X86_64_DELTA_AGC7648A_CONFIG_HEADER: defs: *cdefs basename: x86_64_delta_agc7648a_config diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_config.h b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_config.h index 0b9e50f0..6a0984d5 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_config.h @@ -7,8 +7,8 @@ * @{ * *****************************************************************************/ -#ifndef __X86_64_DELTA_AGC7648A_CONFIGH__ -#define __X86_64_DELTA_AGC7648A_CONFIGH__ +#ifndef __X86_64_DELTA_AGC7648A_CONFIG_H__ +#define __X86_64_DELTA_AGC7648A_CONFIG_H__ #ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG #include @@ -17,7 +17,7 @@ #include #endif -/* */ +/* */ #include /** * X86_64_DELTA_AGC7648A_CONFIGINCLUDE_LOGGING @@ -30,63 +30,63 @@ #endif /** - * X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT + * X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT -#define X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT + * X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT -#define X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT +#define X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT + * X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT -#define X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB + * X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB -#define X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB 1 +#ifndef X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB 1 #endif /** - * X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS + * X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB +#ifndef X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB #endif /** - * X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI + * X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI -#define X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI 0 +#ifndef X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI +#define X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI 0 #endif /** @@ -129,7 +129,7 @@ const char* x86_64_delta_agc7648a_config_lookup(const char* setting); */ int x86_64_delta_agc7648a_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_delta_agc7648a_porting.h" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_porting.h index 1480f866..b0219e95 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_porting.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/inc/x86_64_delta_agc7648a/x86_64_delta_agc7648a_porting.h @@ -12,7 +12,7 @@ /* */ -#if X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_delta_agc7648a_MALLOC +#ifndef X86_64_DELTA_AGC7648A_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_delta_agc7648a_MALLOC GLOBAL_MALLOC - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_MALLOC malloc + #define X86_64_DELTA_AGC7648A_MALLOC GLOBAL_MALLOC + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_MALLOC malloc #else - #error The macro x86_64_delta_agc7648a_MALLOC is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_FREE +#ifndef X86_64_DELTA_AGC7648A_FREE #if defined(GLOBAL_FREE) - #define x86_64_delta_agc7648a_FREE GLOBAL_FREE - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_FREE free + #define X86_64_DELTA_AGC7648A_FREE GLOBAL_FREE + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_FREE free #else - #error The macro x86_64_delta_agc7648a_FREE is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_MEMSET +#ifndef X86_64_DELTA_AGC7648A_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_delta_agc7648a_MEMSET GLOBAL_MEMSET - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_MEMSET memset + #define X86_64_DELTA_AGC7648A_MEMSET GLOBAL_MEMSET + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_MEMSET memset #else - #error The macro x86_64_delta_agc7648a_MEMSET is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_MEMCPY +#ifndef X86_64_DELTA_AGC7648A_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_delta_agc7648a_MEMCPY GLOBAL_MEMCPY - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_MEMCPY memcpy + #define X86_64_DELTA_AGC7648A_MEMCPY GLOBAL_MEMCPY + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_MEMCPY memcpy #else - #error The macro x86_64_delta_agc7648a_MEMCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_STRNCPY +#ifndef X86_64_DELTA_AGC7648A_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_delta_agc7648a_STRNCPY GLOBAL_STRNCPY - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_STRNCPY strncpy + #define X86_64_DELTA_AGC7648A_STRNCPY GLOBAL_STRNCPY + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_STRNCPY strncpy #else - #error The macro x86_64_delta_agc7648a_STRNCPY is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_VSNPRINTF +#ifndef X86_64_DELTA_AGC7648A_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_delta_agc7648a_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_VSNPRINTF vsnprintf + #define X86_64_DELTA_AGC7648A_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_VSNPRINTF vsnprintf #else - #error The macro x86_64_delta_agc7648a_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_SNPRINTF +#ifndef X86_64_DELTA_AGC7648A_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_delta_agc7648a_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_SNPRINTF snprintf + #define X86_64_DELTA_AGC7648A_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_SNPRINTF snprintf #else - #error The macro x86_64_delta_agc7648a_SNPRINTF is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_delta_agc7648a_STRLEN +#ifndef X86_64_DELTA_AGC7648A_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_delta_agc7648a_STRLEN GLOBAL_STRLEN - #elif X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB == 1 - #define x86_64_delta_agc7648a_STRLEN strlen + #define X86_64_DELTA_AGC7648A_STRLEN GLOBAL_STRLEN + #elif X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB == 1 + #define X86_64_DELTA_AGC7648A_STRLEN strlen #else - #error The macro x86_64_delta_agc7648a_STRLEN is required but cannot be defined. + #error The macro X86_64_DELTA_AGC7648A_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_config.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_config.c index 40f304b6..ee7743b2 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_config.c @@ -5,7 +5,7 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_delta_agc7648a_config_STRINGIFY_NAME(_x) #_x #define __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(_x) __x86_64_delta_agc7648a_config_STRINGIFY_NAME(_x) x86_64_delta_agc7648a_config_settings_t x86_64_delta_agc7648a_config_settings[] = @@ -15,35 +15,35 @@ x86_64_delta_agc7648a_config_settings_t x86_64_delta_agc7648a_config_settings[] #else { X86_64_DELTA_AGC7648A_CONFIGINCLUDE_LOGGING(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT - { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT - { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT) }, +#ifdef X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT + { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT) }, #else -{ X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT - { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB - { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB) }, +#ifdef X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB + { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB) }, #else -{ X86_64_DELTA_AGC7648A_CONFIGPORTING_STDLIB(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_DELTA_AGC7648A_CONFIG_PORTING_STDLIB(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ X86_64_DELTA_AGC7648A_CONFIGPORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_DELTA_AGC7648A_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI - { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI) }, +#ifdef X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI + { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI) }, #else -{ X86_64_DELTA_AGC7648A_CONFIGINCLUDE_UCLI(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_DELTA_AGC7648A_CONFIG_INCLUDE_UCLI(__x86_64_delta_agc7648a_config_STRINGIFY_NAME), "__undefined__" }, #endif #ifdef X86_64_DELTA_AGC7648A_CONFIGINCLUDE_DEFAULT_FAN_DIRECTION { __x86_64_delta_agc7648a_config_STRINGIFY_NAME(X86_64_DELTA_AGC7648A_CONFIGINCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_agc7648a_config_STRINGIFY_VALUE(X86_64_DELTA_AGC7648A_CONFIGINCLUDE_DEFAULT_FAN_DIRECTION) }, @@ -60,7 +60,7 @@ x86_64_delta_agc7648a_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_agc7648a_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_agc7648a_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_agc7648a_config_settings[i].name, setting)) { return x86_64_delta_agc7648a_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_delta_agc7648a_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_log.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_log.c index 6f065981..67fe29a3 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_log.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/x86_64_delta_agc7648a_log.c @@ -10,9 +10,8 @@ * x86_64_delta_agc7648a log struct. */ AIM_LOG_STRUCT_DEFINE( - X86_64_DELTA_AGC7648A_CONFIGLOG_OPTIONS_DEFAULT, - X86_64_DELTA_AGC7648A_CONFIGLOG_BITS_DEFAULT, + X86_64_DELTA_AGC7648A_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_DELTA_AGC7648A_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - X86_64_DELTA_AGC7648A_CONFIGLOG_CUSTOM_BITS_DEFAULT + X86_64_DELTA_AGC7648A_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/inc/x86_64_delta_wb2448/x86_64_delta_wb2448_config.h b/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/inc/x86_64_delta_wb2448/x86_64_delta_wb2448_config.h index 4f07a1fc..caf70da3 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/inc/x86_64_delta_wb2448/x86_64_delta_wb2448_config.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/inc/x86_64_delta_wb2448/x86_64_delta_wb2448_config.h @@ -17,7 +17,7 @@ #include #endif -/* */ +/* */ #include /** * X86_64_DELTA_WB2448_CONFIG_INCLUDE_LOGGING @@ -103,8 +103,8 @@ * X86_64_DELTA_WB2448_CONFIG_SFP_COUNT * * SFP port numbers. */ - - + + #ifndef X86_64_DELTA_WB2448_CONFIG_SFP_COUNT #define X86_64_DELTA_WB2448_CONFIG_SFP_COUNT 4 #endif @@ -113,12 +113,14 @@ * X86_64_DELTA_WB2448_CONFIG_FAN_RPM_MAX * * Max fan speed. */ - - + + #ifndef X86_64_DELTA_WB2448_CONFIG_FAN_RPM_MAX #define X86_64_DELTA_WB2448_CONFIG_FAN_RPM_MAX 18000 #endif + + /** * All compile time options can be queried or displayed */ @@ -147,7 +149,7 @@ const char* x86_64_delta_wb2448_config_lookup(const char* setting); */ int x86_64_delta_wb2448_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_delta_wb2448_porting.h" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/src/x86_64_delta_wb2448_config.c b/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/src/x86_64_delta_wb2448_config.c index e6e668f9..f8ce9125 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/src/x86_64_delta_wb2448_config.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-wb2448/onlp/builds/src/module/src/x86_64_delta_wb2448_config.c @@ -7,7 +7,7 @@ #include -/* */ +/* */ #define __x86_64_delta_wb2448_config_STRINGIFY_NAME(_x) #_x #define __x86_64_delta_wb2448_config_STRINGIFY_VALUE(_x) __x86_64_delta_wb2448_config_STRINGIFY_NAME(_x) x86_64_delta_wb2448_config_settings_t x86_64_delta_wb2448_config_settings[] = @@ -72,7 +72,7 @@ x86_64_delta_wb2448_config_lookup(const char* setting) { int i; for(i = 0; x86_64_delta_wb2448_config_settings[i].name; i++) { - if(strcmp(x86_64_delta_wb2448_config_settings[i].name, setting)) { + if(!strcmp(x86_64_delta_wb2448_config_settings[i].name, setting)) { return x86_64_delta_wb2448_config_settings[i].value; } } @@ -89,5 +89,4 @@ x86_64_delta_wb2448_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/make.mk b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/make.mk index f1a59d6e..65922393 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/make.mk +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/auto/make.mk @@ -2,6 +2,6 @@ # x86_64_ingrasys_s9100 Autogeneration # ############################################################################### -x86-64-ingrasys-s9100_AUTO_DEFS := module/auto/x86-64-ingrasys-s9100.yml -x86-64-ingrasys-s9100_AUTO_DIRS := module/inc/x86-64-ingrasys-s9100 module/src +x86_64_ingrasys_s9100_AUTO_DEFS := module/auto/x86_64_ingrasys_s9100.yml +x86_64_ingrasys_s9100_AUTO_DIRS := module/inc/x86_64_ingrasys_s9100 module/src include $(BUILDER)/auto.mk diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h index c479e961..64eaed7a 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h @@ -32,96 +32,86 @@ * @{ * *****************************************************************************/ -#ifndef __X86_64_INGRAYSYS_S9100_CONFIG_H__ -#define __X86_64_INGRAYSYS_S9100_CONFIG_H__ +#ifndef __X86_64_INGRASYS_S9100_CONFIG_H__ +#define __X86_64_INGRASYS_S9100_CONFIG_H__ #ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG #include #endif -#ifdef X86_64_INGRAYSYS_S9100_INCLUDE_CUSTOM_CONFIG +#ifdef X86_64_INGRASYS_S9100_INCLUDE_CUSTOM_CONFIG #include #endif -/* */ +/* */ #include /** - * X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING + * X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING -#define X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING +#define X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING 1 #endif /** - * X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT + * X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT +#define X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB + * X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB -#define X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB +#define X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB 1 #endif /** - * X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB +#ifndef X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB #endif /** - * X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI + * X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI -#define X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT - * - * SFP Count. */ - - -#ifndef X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT -#define X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT 0 +#ifndef X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI +#define X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI 0 #endif @@ -154,9 +144,9 @@ const char* x86_64_ingrasys_s9100_config_lookup(const char* setting); */ int x86_64_ingrasys_s9100_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_ingrasys_s9100_porting.h" -#endif /* __X86_64_INGRAYSYS_S9100_CONFIG_H__ */ +#endif /* __X86_64_INGRASYS_S9100_CONFIG_H__ */ /* @} */ diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h index fb311e97..7f956f35 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h @@ -7,11 +7,11 @@ * @{ * ***********************************************************/ -#ifndef __X86_64_INGRAYSYS_S9100_PORTING_H__ -#define __X86_64_INGRAYSYS_S9100_PORTING_H__ +#ifndef __X86_64_INGRASYS_S9100_PORTING_H__ +#define __X86_64_INGRASYS_S9100_PORTING_H__ /* */ -#if X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -19,88 +19,88 @@ #include #endif -#ifndef X86_64_INGRAYSYS_S9100_MALLOC +#ifndef X86_64_INGRASYS_S9100_MALLOC #if defined(GLOBAL_MALLOC) - #define X86_64_INGRAYSYS_S9100_MALLOC GLOBAL_MALLOC - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_MALLOC malloc + #define X86_64_INGRASYS_S9100_MALLOC GLOBAL_MALLOC + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_MALLOC malloc #else - #error The macro X86_64_INGRAYSYS_S9100_MALLOC is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_MALLOC is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_FREE +#ifndef X86_64_INGRASYS_S9100_FREE #if defined(GLOBAL_FREE) - #define X86_64_INGRAYSYS_S9100_FREE GLOBAL_FREE - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_FREE free + #define X86_64_INGRASYS_S9100_FREE GLOBAL_FREE + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_FREE free #else - #error The macro X86_64_INGRAYSYS_S9100_FREE is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_FREE is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_MEMSET +#ifndef X86_64_INGRASYS_S9100_MEMSET #if defined(GLOBAL_MEMSET) - #define X86_64_INGRAYSYS_S9100_MEMSET GLOBAL_MEMSET - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_MEMSET memset + #define X86_64_INGRASYS_S9100_MEMSET GLOBAL_MEMSET + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_MEMSET memset #else - #error The macro X86_64_INGRAYSYS_S9100_MEMSET is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_MEMSET is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_MEMCPY +#ifndef X86_64_INGRASYS_S9100_MEMCPY #if defined(GLOBAL_MEMCPY) - #define X86_64_INGRAYSYS_S9100_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_MEMCPY memcpy + #define X86_64_INGRASYS_S9100_MEMCPY GLOBAL_MEMCPY + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_MEMCPY memcpy #else - #error The macro X86_64_INGRAYSYS_S9100_MEMCPY is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_MEMCPY is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_STRNCPY +#ifndef X86_64_INGRASYS_S9100_STRNCPY #if defined(GLOBAL_STRNCPY) - #define X86_64_INGRAYSYS_S9100_STRNCPY GLOBAL_STRNCPY - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_STRNCPY strncpy + #define X86_64_INGRASYS_S9100_STRNCPY GLOBAL_STRNCPY + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_STRNCPY strncpy #else - #error The macro X86_64_INGRAYSYS_S9100_STRNCPY is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_STRNCPY is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_VSNPRINTF +#ifndef X86_64_INGRASYS_S9100_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INGRAYSYS_S9100_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_VSNPRINTF vsnprintf + #define X86_64_INGRASYS_S9100_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_VSNPRINTF vsnprintf #else - #error The macro X86_64_INGRAYSYS_S9100_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_SNPRINTF +#ifndef X86_64_INGRASYS_S9100_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define X86_64_INGRAYSYS_S9100_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_SNPRINTF snprintf + #define X86_64_INGRASYS_S9100_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_SNPRINTF snprintf #else - #error The macro X86_64_INGRAYSYS_S9100_SNPRINTF is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef X86_64_INGRAYSYS_S9100_STRLEN +#ifndef X86_64_INGRASYS_S9100_STRLEN #if defined(GLOBAL_STRLEN) - #define X86_64_INGRAYSYS_S9100_STRLEN GLOBAL_STRLEN - #elif X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRAYSYS_S9100_STRLEN strlen + #define X86_64_INGRASYS_S9100_STRLEN GLOBAL_STRLEN + #elif X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INGRASYS_S9100_STRLEN strlen #else - #error The macro X86_64_INGRAYSYS_S9100_STRLEN is required but cannot be defined. + #error The macro X86_64_INGRASYS_S9100_STRLEN is required but cannot be defined. #endif #endif /* */ -#endif /* __X86_64_INGRAYSYS_S9100_PORTING_H__ */ +#endif /* __X86_64_INGRASYS_S9100_PORTING_H__ */ /* @} */ diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c index e24562cf..79a092aa 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c @@ -25,50 +25,45 @@ #include -/* */ +/* */ #define __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(_x) #_x #define __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(_x) __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(_x) x86_64_ingrasys_s9100_config_settings_t x86_64_ingrasys_s9100_config_settings[] = { -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_LOGGING(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_PORTING_STDLIB(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI + { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI) }, #else -{ X86_64_INGRAYSYS_S9100_CONFIG_INCLUDE_UCLI(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT - { __x86_64_ingrasys_s9100_config_STRINGIFY_NAME(X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT), __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE(X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT) }, -#else -{ X86_64_INGRAYSYS_S9100_CONFIG_SFP_COUNT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -80,7 +75,7 @@ x86_64_ingrasys_s9100_config_lookup(const char* setting) { int i; for(i = 0; x86_64_ingrasys_s9100_config_settings[i].name; i++) { - if(strcmp(x86_64_ingrasys_s9100_config_settings[i].name, setting)) { + if(!strcmp(x86_64_ingrasys_s9100_config_settings[i].name, setting)) { return x86_64_ingrasys_s9100_config_settings[i].value; } } @@ -97,5 +92,5 @@ x86_64_ingrasys_s9100_config_show(struct aim_pvs_s* pvs) return i; } -/* */ +/* */ diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.c index e837eeca..da647a75 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.c @@ -30,9 +30,9 @@ * x86_64_ingrasys_s9100 log struct. */ AIM_LOG_STRUCT_DEFINE( - X86_64_INGRAYSYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INGRAYSYS_S9100_CONFIG_LOG_BITS_DEFAULT, + X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - X86_64_INGRAYSYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_module.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_module.c index 1a79380e..5711fc4a 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_module.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_module.c @@ -30,7 +30,7 @@ static int datatypes_init__(void) { -#define INGRAYSYS_S9100_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#define INGRASYS_S9100_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/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile index f3ba68e3..0a428e73 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_inventec_d7032q28b AUTOMODULE := x86_64_inventec_d7032q28b include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h index 232518dc..476cfcc9 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING + * X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING -#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING +#define X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT + * X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT -#define x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT +#define X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB + * X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB -#define x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB +#define X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB #endif /** - * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI + * X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI -#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI +#define X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_inventec_d7032q28b_config_lookup(const char* setting); */ int x86_64_inventec_d7032q28b_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_inventec_d7032q28b_porting.h" diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h index 55950ecd..9e94ec3f 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_inventec_d7032q28b_MALLOC +#ifndef X86_64_INVENTEC_D7032Q28B_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_inventec_d7032q28b_MALLOC GLOBAL_MALLOC - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_MALLOC malloc + #define X86_64_INVENTEC_D7032Q28B_MALLOC GLOBAL_MALLOC + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_MALLOC malloc #else - #error The macro x86_64_inventec_d7032q28b_MALLOC is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_FREE +#ifndef X86_64_INVENTEC_D7032Q28B_FREE #if defined(GLOBAL_FREE) - #define x86_64_inventec_d7032q28b_FREE GLOBAL_FREE - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_FREE free + #define X86_64_INVENTEC_D7032Q28B_FREE GLOBAL_FREE + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_FREE free #else - #error The macro x86_64_inventec_d7032q28b_FREE is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_MEMSET +#ifndef X86_64_INVENTEC_D7032Q28B_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_inventec_d7032q28b_MEMSET GLOBAL_MEMSET - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_MEMSET memset + #define X86_64_INVENTEC_D7032Q28B_MEMSET GLOBAL_MEMSET + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_MEMSET memset #else - #error The macro x86_64_inventec_d7032q28b_MEMSET is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_MEMCPY +#ifndef X86_64_INVENTEC_D7032Q28B_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_inventec_d7032q28b_MEMCPY GLOBAL_MEMCPY - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_MEMCPY memcpy + #define X86_64_INVENTEC_D7032Q28B_MEMCPY GLOBAL_MEMCPY + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_MEMCPY memcpy #else - #error The macro x86_64_inventec_d7032q28b_MEMCPY is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_STRNCPY +#ifndef X86_64_INVENTEC_D7032Q28B_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_inventec_d7032q28b_STRNCPY GLOBAL_STRNCPY - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_STRNCPY strncpy + #define X86_64_INVENTEC_D7032Q28B_STRNCPY GLOBAL_STRNCPY + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_STRNCPY strncpy #else - #error The macro x86_64_inventec_d7032q28b_STRNCPY is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_VSNPRINTF +#ifndef X86_64_INVENTEC_D7032Q28B_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_inventec_d7032q28b_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_VSNPRINTF vsnprintf + #define X86_64_INVENTEC_D7032Q28B_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_VSNPRINTF vsnprintf #else - #error The macro x86_64_inventec_d7032q28b_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_SNPRINTF +#ifndef X86_64_INVENTEC_D7032Q28B_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_inventec_d7032q28b_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_SNPRINTF snprintf + #define X86_64_INVENTEC_D7032Q28B_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_SNPRINTF snprintf #else - #error The macro x86_64_inventec_d7032q28b_SNPRINTF is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_inventec_d7032q28b_STRLEN +#ifndef X86_64_INVENTEC_D7032Q28B_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_inventec_d7032q28b_STRLEN GLOBAL_STRLEN - #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7032q28b_STRLEN strlen + #define X86_64_INVENTEC_D7032Q28B_STRLEN GLOBAL_STRLEN + #elif X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB == 1 + #define X86_64_INVENTEC_D7032Q28B_STRLEN strlen #else - #error The macro x86_64_inventec_d7032q28b_STRLEN is required but cannot be defined. + #error The macro X86_64_INVENTEC_D7032Q28B_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c index d75ca1b8..5b8c0235 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(_x) #_x #define __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(_x) x86_64_inventec_d7032q28b_config_settings_t x86_64_inventec_d7032q28b_config_settings[] = { -#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_inventec_d7032q28b_config_lookup(const char* setting) { int i; for(i = 0; x86_64_inventec_d7032q28b_config_settings[i].name; i++) { - if(strcmp(x86_64_inventec_d7032q28b_config_settings[i].name, setting)) { + if(!strcmp(x86_64_inventec_d7032q28b_config_settings[i].name, setting)) { return x86_64_inventec_d7032q28b_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_inventec_d7032q28b_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c index 6ab416f3..4418d93f 100644 --- a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c @@ -10,9 +10,8 @@ * x86_64_inventec_d7032q28b log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT, + X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/onlp/builds/src/x86_64_kvm_x86_64/module/src/x86_64_kvm_x86_64_config.c b/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/onlp/builds/src/x86_64_kvm_x86_64/module/src/x86_64_kvm_x86_64_config.c index 4f0b458c..cdc2dea1 100644 --- a/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/onlp/builds/src/x86_64_kvm_x86_64/module/src/x86_64_kvm_x86_64_config.c +++ b/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/onlp/builds/src/x86_64_kvm_x86_64/module/src/x86_64_kvm_x86_64_config.c @@ -80,7 +80,7 @@ x86_64_kvm_x86_64_config_lookup(const char* setting) { int i; for(i = 0; x86_64_kvm_x86_64_config_settings[i].name; i++) { - if(strcmp(x86_64_kvm_x86_64_config_settings[i].name, setting)) { + if(!strcmp(x86_64_kvm_x86_64_config_settings[i].name, setting)) { return x86_64_kvm_x86_64_config_settings[i].value; } } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/Makefile index c8d80db2..c4d830ed 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_mlnx_msn2100 AUTOMODULE := x86_64_mlnx_msn2100 include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h index 35d90487..031f245c 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING + * X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING -#define x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING +#define X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT + * X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT -#define x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT +#define X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB + * X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB -#define x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB +#define X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB +#ifndef X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB #endif /** - * x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI + * X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI -#define x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI +#define X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_mlnx_msn2100_config_lookup(const char* setting); */ int x86_64_mlnx_msn2100_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_mlnx_msn2100_porting.h" diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_porting.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_porting.h index e640eca2..5e705ce6 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_porting.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/inc/x86_64_mlnx_msn2100/x86_64_mlnx_msn2100_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_mlnx_msn2100_MALLOC +#ifndef X86_64_MLNX_MSN2100_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_mlnx_msn2100_MALLOC GLOBAL_MALLOC - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_MALLOC malloc + #define X86_64_MLNX_MSN2100_MALLOC GLOBAL_MALLOC + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_MALLOC malloc #else - #error The macro x86_64_mlnx_msn2100_MALLOC is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_FREE +#ifndef X86_64_MLNX_MSN2100_FREE #if defined(GLOBAL_FREE) - #define x86_64_mlnx_msn2100_FREE GLOBAL_FREE - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_FREE free + #define X86_64_MLNX_MSN2100_FREE GLOBAL_FREE + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_FREE free #else - #error The macro x86_64_mlnx_msn2100_FREE is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_MEMSET +#ifndef X86_64_MLNX_MSN2100_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_mlnx_msn2100_MEMSET GLOBAL_MEMSET - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_MEMSET memset + #define X86_64_MLNX_MSN2100_MEMSET GLOBAL_MEMSET + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_MEMSET memset #else - #error The macro x86_64_mlnx_msn2100_MEMSET is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_MEMCPY +#ifndef X86_64_MLNX_MSN2100_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_mlnx_msn2100_MEMCPY GLOBAL_MEMCPY - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_MEMCPY memcpy + #define X86_64_MLNX_MSN2100_MEMCPY GLOBAL_MEMCPY + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_MEMCPY memcpy #else - #error The macro x86_64_mlnx_msn2100_MEMCPY is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_STRNCPY +#ifndef X86_64_MLNX_MSN2100_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_mlnx_msn2100_STRNCPY GLOBAL_STRNCPY - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_STRNCPY strncpy + #define X86_64_MLNX_MSN2100_STRNCPY GLOBAL_STRNCPY + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_STRNCPY strncpy #else - #error The macro x86_64_mlnx_msn2100_STRNCPY is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_VSNPRINTF +#ifndef X86_64_MLNX_MSN2100_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_mlnx_msn2100_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_VSNPRINTF vsnprintf + #define X86_64_MLNX_MSN2100_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_VSNPRINTF vsnprintf #else - #error The macro x86_64_mlnx_msn2100_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_SNPRINTF +#ifndef X86_64_MLNX_MSN2100_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_mlnx_msn2100_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_SNPRINTF snprintf + #define X86_64_MLNX_MSN2100_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_SNPRINTF snprintf #else - #error The macro x86_64_mlnx_msn2100_SNPRINTF is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2100_STRLEN +#ifndef X86_64_MLNX_MSN2100_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_mlnx_msn2100_STRLEN GLOBAL_STRLEN - #elif x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2100_STRLEN strlen + #define X86_64_MLNX_MSN2100_STRLEN GLOBAL_STRLEN + #elif X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2100_STRLEN strlen #else - #error The macro x86_64_mlnx_msn2100_STRLEN is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2100_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_config.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_config.c index 131dc7af..fbf51edb 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_config.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(_x) #_x #define __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(_x) __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(_x) x86_64_mlnx_msn2100_config_settings_t x86_64_mlnx_msn2100_config_settings[] = { -#ifdef x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_mlnx_msn2100_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_mlnx_msn2100_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_mlnx_msn2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_mlnx_msn2100_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_mlnx_msn2100_config_STRINGIFY_NAME(X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2100_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_mlnx_msn2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2100_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2100_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_mlnx_msn2100_config_lookup(const char* setting) { int i; for(i = 0; x86_64_mlnx_msn2100_config_settings[i].name; i++) { - if(strcmp(x86_64_mlnx_msn2100_config_settings[i].name, setting)) { + if(!strcmp(x86_64_mlnx_msn2100_config_settings[i].name, setting)) { return x86_64_mlnx_msn2100_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_mlnx_msn2100_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_log.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_log.c index 20e39e8c..8cb343c7 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_log.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/x86_64_mlnx_msn2100_log.c @@ -10,9 +10,8 @@ * x86_64_mlnx_msn2100 log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_mlnx_msn2100_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_mlnx_msn2100_CONFIG_LOG_BITS_DEFAULT, + X86_64_MLNX_MSN2100_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_MLNX_MSN2100_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_mlnx_msn2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_MLNX_MSN2100_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/Makefile index 27e2df8d..d5a532c9 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_mlnx_msn2410 AUTOMODULE := x86_64_mlnx_msn2410 include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h index ea70773d..f9075cbe 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING + * X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING -#define x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING +#define X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT + * X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT -#define x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT +#define X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB + * X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB -#define x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB +#define X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB +#ifndef X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB #endif /** - * x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI + * X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI -#define x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI +#define X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_mlnx_msn2410_config_lookup(const char* setting); */ int x86_64_mlnx_msn2410_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_mlnx_msn2410_porting.h" diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_porting.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_porting.h index 4ff0f886..ac4414ad 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_porting.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/inc/x86_64_mlnx_msn2410/x86_64_mlnx_msn2410_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_mlnx_msn2410_MALLOC +#ifndef X86_64_MLNX_MSN2410_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_mlnx_msn2410_MALLOC GLOBAL_MALLOC - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_MALLOC malloc + #define X86_64_MLNX_MSN2410_MALLOC GLOBAL_MALLOC + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_MALLOC malloc #else - #error The macro x86_64_mlnx_msn2410_MALLOC is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_FREE +#ifndef X86_64_MLNX_MSN2410_FREE #if defined(GLOBAL_FREE) - #define x86_64_mlnx_msn2410_FREE GLOBAL_FREE - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_FREE free + #define X86_64_MLNX_MSN2410_FREE GLOBAL_FREE + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_FREE free #else - #error The macro x86_64_mlnx_msn2410_FREE is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_MEMSET +#ifndef X86_64_MLNX_MSN2410_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_mlnx_msn2410_MEMSET GLOBAL_MEMSET - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_MEMSET memset + #define X86_64_MLNX_MSN2410_MEMSET GLOBAL_MEMSET + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_MEMSET memset #else - #error The macro x86_64_mlnx_msn2410_MEMSET is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_MEMCPY +#ifndef X86_64_MLNX_MSN2410_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_mlnx_msn2410_MEMCPY GLOBAL_MEMCPY - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_MEMCPY memcpy + #define X86_64_MLNX_MSN2410_MEMCPY GLOBAL_MEMCPY + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_MEMCPY memcpy #else - #error The macro x86_64_mlnx_msn2410_MEMCPY is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_STRNCPY +#ifndef X86_64_MLNX_MSN2410_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_mlnx_msn2410_STRNCPY GLOBAL_STRNCPY - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_STRNCPY strncpy + #define X86_64_MLNX_MSN2410_STRNCPY GLOBAL_STRNCPY + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_STRNCPY strncpy #else - #error The macro x86_64_mlnx_msn2410_STRNCPY is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_VSNPRINTF +#ifndef X86_64_MLNX_MSN2410_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_mlnx_msn2410_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_VSNPRINTF vsnprintf + #define X86_64_MLNX_MSN2410_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_VSNPRINTF vsnprintf #else - #error The macro x86_64_mlnx_msn2410_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_SNPRINTF +#ifndef X86_64_MLNX_MSN2410_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_mlnx_msn2410_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_SNPRINTF snprintf + #define X86_64_MLNX_MSN2410_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_SNPRINTF snprintf #else - #error The macro x86_64_mlnx_msn2410_SNPRINTF is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2410_STRLEN +#ifndef X86_64_MLNX_MSN2410_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_mlnx_msn2410_STRLEN GLOBAL_STRLEN - #elif x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2410_STRLEN strlen + #define X86_64_MLNX_MSN2410_STRLEN GLOBAL_STRLEN + #elif X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2410_STRLEN strlen #else - #error The macro x86_64_mlnx_msn2410_STRLEN is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2410_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_config.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_config.c index 1bd4719c..cd119a3f 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_config.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(_x) #_x #define __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(_x) __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(_x) x86_64_mlnx_msn2410_config_settings_t x86_64_mlnx_msn2410_config_settings[] = { -#ifdef x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_mlnx_msn2410_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_mlnx_msn2410_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_mlnx_msn2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_mlnx_msn2410_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_mlnx_msn2410_config_STRINGIFY_NAME(X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2410_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_mlnx_msn2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2410_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2410_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_mlnx_msn2410_config_lookup(const char* setting) { int i; for(i = 0; x86_64_mlnx_msn2410_config_settings[i].name; i++) { - if(strcmp(x86_64_mlnx_msn2410_config_settings[i].name, setting)) { + if(!strcmp(x86_64_mlnx_msn2410_config_settings[i].name, setting)) { return x86_64_mlnx_msn2410_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_mlnx_msn2410_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_log.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_log.c index 613aba85..884662d1 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_log.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/x86_64_mlnx_msn2410_log.c @@ -10,9 +10,8 @@ * x86_64_mlnx_msn2410 log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_mlnx_msn2410_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_mlnx_msn2410_CONFIG_LOG_BITS_DEFAULT, + X86_64_MLNX_MSN2410_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_MLNX_MSN2410_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_mlnx_msn2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_MLNX_MSN2410_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/Makefile index c493c185..9ab0d1ff 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_mlnx_msn2700 AUTOMODULE := x86_64_mlnx_msn2700 include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_config.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_config.h index 407b34cd..fd1b96ae 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_config.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_config.h @@ -17,86 +17,86 @@ #include #endif -/* */ +/* */ #include /** - * x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING + * X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING -#define x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING +#define X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING 1 #endif /** - * x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT + * X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT -#define x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT +#define X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB + * X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB -#define x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB +#define X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB 1 #endif /** - * x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB +#ifndef X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB #endif /** - * x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI + * X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI -#define x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI +#define X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI 0 #endif /** - * x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -129,7 +129,7 @@ const char* x86_64_mlnx_msn2700_config_lookup(const char* setting); */ int x86_64_mlnx_msn2700_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ #include "x86_64_mlnx_msn2700_porting.h" diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_porting.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_porting.h index e295b799..a1235146 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_porting.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/inc/x86_64_mlnx_msn2700/x86_64_mlnx_msn2700_porting.h @@ -12,7 +12,7 @@ /* */ -#if x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,83 +20,83 @@ #include #endif -#ifndef x86_64_mlnx_msn2700_MALLOC +#ifndef X86_64_MLNX_MSN2700_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_mlnx_msn2700_MALLOC GLOBAL_MALLOC - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_MALLOC malloc + #define X86_64_MLNX_MSN2700_MALLOC GLOBAL_MALLOC + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_MALLOC malloc #else - #error The macro x86_64_mlnx_msn2700_MALLOC is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_FREE +#ifndef X86_64_MLNX_MSN2700_FREE #if defined(GLOBAL_FREE) - #define x86_64_mlnx_msn2700_FREE GLOBAL_FREE - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_FREE free + #define X86_64_MLNX_MSN2700_FREE GLOBAL_FREE + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_FREE free #else - #error The macro x86_64_mlnx_msn2700_FREE is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_MEMSET +#ifndef X86_64_MLNX_MSN2700_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_mlnx_msn2700_MEMSET GLOBAL_MEMSET - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_MEMSET memset + #define X86_64_MLNX_MSN2700_MEMSET GLOBAL_MEMSET + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_MEMSET memset #else - #error The macro x86_64_mlnx_msn2700_MEMSET is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_MEMCPY +#ifndef X86_64_MLNX_MSN2700_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_mlnx_msn2700_MEMCPY GLOBAL_MEMCPY - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_MEMCPY memcpy + #define X86_64_MLNX_MSN2700_MEMCPY GLOBAL_MEMCPY + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_MEMCPY memcpy #else - #error The macro x86_64_mlnx_msn2700_MEMCPY is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_STRNCPY +#ifndef X86_64_MLNX_MSN2700_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_mlnx_msn2700_STRNCPY GLOBAL_STRNCPY - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_STRNCPY strncpy + #define X86_64_MLNX_MSN2700_STRNCPY GLOBAL_STRNCPY + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_STRNCPY strncpy #else - #error The macro x86_64_mlnx_msn2700_STRNCPY is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_VSNPRINTF +#ifndef X86_64_MLNX_MSN2700_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_mlnx_msn2700_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_VSNPRINTF vsnprintf + #define X86_64_MLNX_MSN2700_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_VSNPRINTF vsnprintf #else - #error The macro x86_64_mlnx_msn2700_VSNPRINTF is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_SNPRINTF +#ifndef X86_64_MLNX_MSN2700_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_mlnx_msn2700_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_SNPRINTF snprintf + #define X86_64_MLNX_MSN2700_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_SNPRINTF snprintf #else - #error The macro x86_64_mlnx_msn2700_SNPRINTF is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_mlnx_msn2700_STRLEN +#ifndef X86_64_MLNX_MSN2700_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_mlnx_msn2700_STRLEN GLOBAL_STRLEN - #elif x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB == 1 - #define x86_64_mlnx_msn2700_STRLEN strlen + #define X86_64_MLNX_MSN2700_STRLEN GLOBAL_STRLEN + #elif X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2700_STRLEN strlen #else - #error The macro x86_64_mlnx_msn2700_STRLEN is required but cannot be defined. + #error The macro X86_64_MLNX_MSN2700_STRLEN is required but cannot be defined. #endif #endif diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_config.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_config.c index 1b7081f7..75683cc4 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_config.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_config.c @@ -5,50 +5,50 @@ *****************************************************************************/ #include -/* */ +/* */ #define __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(_x) #_x #define __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(_x) __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(_x) x86_64_mlnx_msn2700_config_settings_t x86_64_mlnx_msn2700_config_settings[] = { -#ifdef x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING) }, #else -{ x86_64_mlnx_msn2700_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_INCLUDE_LOGGING(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT) }, #else -{ x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB) }, #else -{ x86_64_mlnx_msn2700_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_PORTING_STDLIB(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ x86_64_mlnx_msn2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI) }, #else -{ x86_64_mlnx_msn2700_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_INCLUDE_UCLI(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_mlnx_msn2700_config_STRINGIFY_NAME(X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mlnx_msn2700_config_STRINGIFY_VALUE(X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ x86_64_mlnx_msn2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_MLNX_MSN2700_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mlnx_msn2700_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; @@ -60,7 +60,7 @@ x86_64_mlnx_msn2700_config_lookup(const char* setting) { int i; for(i = 0; x86_64_mlnx_msn2700_config_settings[i].name; i++) { - if(strcmp(x86_64_mlnx_msn2700_config_settings[i].name, setting)) { + if(!strcmp(x86_64_mlnx_msn2700_config_settings[i].name, setting)) { return x86_64_mlnx_msn2700_config_settings[i].value; } } @@ -77,5 +77,4 @@ x86_64_mlnx_msn2700_config_show(struct aim_pvs_s* pvs) return i; } -/* */ - +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_log.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_log.c index 3eef11c3..fb3e3e81 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_log.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/x86_64_mlnx_msn2700_log.c @@ -10,9 +10,8 @@ * x86_64_mlnx_msn2700 log struct. */ AIM_LOG_STRUCT_DEFINE( - x86_64_mlnx_msn2700_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_mlnx_msn2700_CONFIG_LOG_BITS_DEFAULT, + X86_64_MLNX_MSN2700_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_MLNX_MSN2700_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - x86_64_mlnx_msn2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_MLNX_MSN2700_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); - diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml index 4f35e52b..8a6de78a 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml @@ -96,11 +96,11 @@ definitions: led_id: members: - - STAT : 1 + - LED1 : 1 led_oid: members: - - STAT : ONLP_LED_ID_CREATE(1) + - LED1 : ONLP_LED_ID_CREATE(1) portingmacro: diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_config.h b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_config.h index ecd344e3..0405ba89 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_config.h +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_config.h @@ -99,6 +99,8 @@ #define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 #endif + + /** * All compile time options can be queried or displayed */ diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c index 35ca655a..00e47c5b 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c @@ -60,7 +60,7 @@ x86_64_netberg_aurora_620_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_netberg_aurora_620_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_netberg_aurora_620_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_netberg_aurora_620_rangeley_config_settings[i].name, setting)) { return x86_64_netberg_aurora_620_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h index 5b2d6901..439b7140 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-620-rangeley/onlp/builds/src/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h @@ -10,132 +10,40 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) - -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_THERMAL1 = 1, - THERMAL_ID_THERMAL2 = 2, - THERMAL_ID_THERMAL3 = 3, - THERMAL_ID_THERMAL4 = 4, - THERMAL_ID_THERMAL5 = 5, - THERMAL_ID_THERMAL6 = 6, - THERMAL_ID_THERMAL7 = 7, - THERMAL_ID_THERMAL8 = 8, - THERMAL_ID_THERMAL9 = 9, - THERMAL_ID_THERMAL10 = 10, -} thermal_id_t; - -/** Enum names. */ -const char* thermal_id_name(thermal_id_t e); - -/** Enum values. */ -int thermal_id_value(const char* str, thermal_id_t* e, int substr); - -/** Enum descriptions. */ -const char* thermal_id_desc(thermal_id_t e); - -/** Enum validator. */ -int thermal_id_valid(thermal_id_t e); - -/** validator */ -#define THERMAL_ID_VALID(_e) \ - (thermal_id_valid((_e))) - -/** thermal_id_map table. */ -extern aim_map_si_t thermal_id_map[]; -/** thermal_id_desc_map table. */ -extern aim_map_si_t thermal_id_desc_map[]; - - -/** psu_oid */ -typedef enum psu_oid_e { - PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), - PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), -} psu_oid_t; - -/** Enum names. */ -const char* psu_oid_name(psu_oid_t e); - -/** Enum values. */ -int psu_oid_value(const char* str, psu_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_oid_desc(psu_oid_t e); - -/** Enum validator. */ -int psu_oid_valid(psu_oid_t e); - -/** validator */ -#define PSU_OID_VALID(_e) \ - (psu_oid_valid((_e))) - -/** psu_oid_map table. */ -extern aim_map_si_t psu_oid_map[]; -/** psu_oid_desc_map table. */ -extern aim_map_si_t psu_oid_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; /** fan_oid */ typedef enum fan_oid_e { @@ -172,57 +80,175 @@ extern aim_map_si_t fan_oid_map[]; /** fan_oid_desc_map table. */ extern aim_map_si_t fan_oid_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** led_id */ +typedef enum led_id_e { + LED_ID_LED1 = 1, +} led_id_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* led_id_name(led_id_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int led_id_value(const char* str, led_id_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* led_id_desc(led_id_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int led_id_valid(led_id_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define LED_ID_VALID(_e) \ + (led_id_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; +/** led_id_map table. */ +extern aim_map_si_t led_id_map[]; +/** led_id_desc_map table. */ +extern aim_map_si_t led_id_desc_map[]; /** led_oid */ typedef enum led_oid_e { LED_OID_LED1 = ONLP_LED_ID_CREATE(1), - LED_OID_LED2 = ONLP_LED_ID_CREATE(2), - LED_OID_LED3 = ONLP_LED_ID_CREATE(3), - LED_OID_LED4 = ONLP_LED_ID_CREATE(4), } led_oid_t; -/** led_id */ -typedef enum led_id_e { - LED_ID_LED1 = 1, - LED_ID_LED2 = 2, - LED_ID_LED3 = 3, - LED_ID_LED4 = 4, -} led_id_t; +/** Enum names. */ +const char* led_oid_name(led_oid_t e); +/** Enum values. */ +int led_oid_value(const char* str, led_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* led_oid_desc(led_oid_t e); + +/** Enum validator. */ +int led_oid_valid(led_oid_t e); + +/** validator */ +#define LED_OID_VALID(_e) \ + (led_oid_valid((_e))) + +/** led_oid_map table. */ +extern aim_map_si_t led_oid_map[]; +/** led_oid_desc_map table. */ +extern aim_map_si_t led_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; + +/** psu_oid */ +typedef enum psu_oid_e { + PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), + PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), +} psu_oid_t; + +/** Enum names. */ +const char* psu_oid_name(psu_oid_t e); + +/** Enum values. */ +int psu_oid_value(const char* str, psu_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_oid_desc(psu_oid_t e); + +/** Enum validator. */ +int psu_oid_valid(psu_oid_t e); + +/** validator */ +#define PSU_OID_VALID(_e) \ + (psu_oid_valid((_e))) + +/** psu_oid_map table. */ +extern aim_map_si_t psu_oid_map[]; +/** psu_oid_desc_map table. */ +extern aim_map_si_t psu_oid_desc_map[]; + +/** thermal_id */ +typedef enum thermal_id_e { + THERMAL_ID_THERMAL1 = 1, + THERMAL_ID_THERMAL2 = 2, + THERMAL_ID_THERMAL3 = 3, + THERMAL_ID_THERMAL4 = 4, + THERMAL_ID_THERMAL5 = 5, + THERMAL_ID_THERMAL6 = 6, + THERMAL_ID_THERMAL7 = 7, +} thermal_id_t; + +/** Enum names. */ +const char* thermal_id_name(thermal_id_t e); + +/** Enum values. */ +int thermal_id_value(const char* str, thermal_id_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_id_desc(thermal_id_t e); + +/** Enum validator. */ +int thermal_id_valid(thermal_id_t e); + +/** validator */ +#define THERMAL_ID_VALID(_e) \ + (thermal_id_valid((_e))) + +/** thermal_id_map table. */ +extern aim_map_si_t thermal_id_map[]; +/** thermal_id_desc_map table. */ +extern aim_map_si_t thermal_id_desc_map[]; + +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), +} thermal_oid_t; + +/** Enum names. */ +const char* thermal_oid_name(thermal_oid_t e); + +/** Enum values. */ +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_oid_desc(thermal_oid_t e); + +/** Enum validator. */ +int thermal_oid_valid(thermal_oid_t e); + +/** validator */ +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) + +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml index 3d2d0957..5cccd736 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml @@ -96,11 +96,19 @@ definitions: led_id: members: - - STAT : 1 + - LED1 : 1 + - LED2 : 2 + - LED3 : 3 + - LED4 : 4 led_oid: members: - - STAT : ONLP_LED_ID_CREATE(1) + - LED1: ONLP_LED_ID_CREATE(1) + - LED2: ONLP_LED_ID_CREATE(2) + - LED3: ONLP_LED_ID_CREATE(3) + - LED4: ONLP_LED_ID_CREATE(4) + + portingmacro: diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_config.h b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_config.h index 43e806f8..0b0cdeb0 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_config.h +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_config.h @@ -99,6 +99,8 @@ #define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 #endif + + /** * All compile time options can be queried or displayed */ diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c index 9f8e2833..67664446 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c @@ -60,7 +60,7 @@ x86_64_netberg_aurora_720_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_netberg_aurora_720_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_netberg_aurora_720_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_netberg_aurora_720_rangeley_config_settings[i].name, setting)) { return x86_64_netberg_aurora_720_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h index a22db213..3a11d106 100755 --- a/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h +++ b/packages/platforms/netberg/x86-64/x86-64-netberg-aurora-720-rangeley/onlp/builds/src/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h @@ -10,132 +10,40 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) - -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_THERMAL1 = 1, - THERMAL_ID_THERMAL2 = 2, - THERMAL_ID_THERMAL3 = 3, - THERMAL_ID_THERMAL4 = 4, - THERMAL_ID_THERMAL5 = 5, - THERMAL_ID_THERMAL6 = 6, - THERMAL_ID_THERMAL7 = 7, - THERMAL_ID_THERMAL8 = 8, - THERMAL_ID_THERMAL9 = 9, - THERMAL_ID_THERMAL10 = 10, -} thermal_id_t; - -/** Enum names. */ -const char* thermal_id_name(thermal_id_t e); - -/** Enum values. */ -int thermal_id_value(const char* str, thermal_id_t* e, int substr); - -/** Enum descriptions. */ -const char* thermal_id_desc(thermal_id_t e); - -/** Enum validator. */ -int thermal_id_valid(thermal_id_t e); - -/** validator */ -#define THERMAL_ID_VALID(_e) \ - (thermal_id_valid((_e))) - -/** thermal_id_map table. */ -extern aim_map_si_t thermal_id_map[]; -/** thermal_id_desc_map table. */ -extern aim_map_si_t thermal_id_desc_map[]; - - -/** psu_oid */ -typedef enum psu_oid_e { - PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), - PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), -} psu_oid_t; - -/** Enum names. */ -const char* psu_oid_name(psu_oid_t e); - -/** Enum values. */ -int psu_oid_value(const char* str, psu_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_oid_desc(psu_oid_t e); - -/** Enum validator. */ -int psu_oid_valid(psu_oid_t e); - -/** validator */ -#define PSU_OID_VALID(_e) \ - (psu_oid_valid((_e))) - -/** psu_oid_map table. */ -extern aim_map_si_t psu_oid_map[]; -/** psu_oid_desc_map table. */ -extern aim_map_si_t psu_oid_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; /** fan_oid */ typedef enum fan_oid_e { @@ -172,40 +80,34 @@ extern aim_map_si_t fan_oid_map[]; /** fan_oid_desc_map table. */ extern aim_map_si_t fan_oid_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** led_id */ +typedef enum led_id_e { + LED_ID_LED1 = 1, + LED_ID_LED2 = 2, + LED_ID_LED3 = 3, + LED_ID_LED4 = 4, +} led_id_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* led_id_name(led_id_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int led_id_value(const char* str, led_id_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* led_id_desc(led_id_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int led_id_valid(led_id_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define LED_ID_VALID(_e) \ + (led_id_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; +/** led_id_map table. */ +extern aim_map_si_t led_id_map[]; +/** led_id_desc_map table. */ +extern aim_map_si_t led_id_desc_map[]; /** led_oid */ typedef enum led_oid_e { @@ -215,14 +117,144 @@ typedef enum led_oid_e { LED_OID_LED4 = ONLP_LED_ID_CREATE(4), } led_oid_t; -/** led_id */ -typedef enum led_id_e { - LED_ID_LED1 = 1, - LED_ID_LED2 = 2, - LED_ID_LED3 = 3, - LED_ID_LED4 = 4, -} led_id_t; +/** Enum names. */ +const char* led_oid_name(led_oid_t e); +/** Enum values. */ +int led_oid_value(const char* str, led_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* led_oid_desc(led_oid_t e); + +/** Enum validator. */ +int led_oid_valid(led_oid_t e); + +/** validator */ +#define LED_OID_VALID(_e) \ + (led_oid_valid((_e))) + +/** led_oid_map table. */ +extern aim_map_si_t led_oid_map[]; +/** led_oid_desc_map table. */ +extern aim_map_si_t led_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; + +/** psu_oid */ +typedef enum psu_oid_e { + PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), + PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), +} psu_oid_t; + +/** Enum names. */ +const char* psu_oid_name(psu_oid_t e); + +/** Enum values. */ +int psu_oid_value(const char* str, psu_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_oid_desc(psu_oid_t e); + +/** Enum validator. */ +int psu_oid_valid(psu_oid_t e); + +/** validator */ +#define PSU_OID_VALID(_e) \ + (psu_oid_valid((_e))) + +/** psu_oid_map table. */ +extern aim_map_si_t psu_oid_map[]; +/** psu_oid_desc_map table. */ +extern aim_map_si_t psu_oid_desc_map[]; + +/** thermal_id */ +typedef enum thermal_id_e { + THERMAL_ID_THERMAL1 = 1, + THERMAL_ID_THERMAL2 = 2, + THERMAL_ID_THERMAL3 = 3, + THERMAL_ID_THERMAL4 = 4, + THERMAL_ID_THERMAL5 = 5, + THERMAL_ID_THERMAL6 = 6, + THERMAL_ID_THERMAL7 = 7, +} thermal_id_t; + +/** Enum names. */ +const char* thermal_id_name(thermal_id_t e); + +/** Enum values. */ +int thermal_id_value(const char* str, thermal_id_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_id_desc(thermal_id_t e); + +/** Enum validator. */ +int thermal_id_valid(thermal_id_t e); + +/** validator */ +#define THERMAL_ID_VALID(_e) \ + (thermal_id_valid((_e))) + +/** thermal_id_map table. */ +extern aim_map_si_t thermal_id_map[]; +/** thermal_id_desc_map table. */ +extern aim_map_si_t thermal_id_desc_map[]; + +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), +} thermal_oid_t; + +/** Enum names. */ +const char* thermal_oid_name(thermal_oid_t e); + +/** Enum values. */ +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_oid_desc(thermal_oid_t e); + +/** Enum validator. */ +int thermal_oid_valid(thermal_oid_t e); + +/** validator */ +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) + +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/nxp/arm64/arm64-nxp-ls2080ardb/onlp/builds/src/arm64_nxp_ls2080ardb/module/src/arm64_nxp_ls2080ardb_config.c b/packages/platforms/nxp/arm64/arm64-nxp-ls2080ardb/onlp/builds/src/arm64_nxp_ls2080ardb/module/src/arm64_nxp_ls2080ardb_config.c index 2d09c746..55852657 100644 --- a/packages/platforms/nxp/arm64/arm64-nxp-ls2080ardb/onlp/builds/src/arm64_nxp_ls2080ardb/module/src/arm64_nxp_ls2080ardb_config.c +++ b/packages/platforms/nxp/arm64/arm64-nxp-ls2080ardb/onlp/builds/src/arm64_nxp_ls2080ardb/module/src/arm64_nxp_ls2080ardb_config.c @@ -80,7 +80,7 @@ arm64_nxp_ls2080ardb_config_lookup(const char* setting) { int i; for(i = 0; arm64_nxp_ls2080ardb_config_settings[i].name; i++) { - if(strcmp(arm64_nxp_ls2080ardb_config_settings[i].name, setting)) { + if(!strcmp(arm64_nxp_ls2080ardb_config_settings[i].name, setting)) { return arm64_nxp_ls2080ardb_config_settings[i].value; } } diff --git a/packages/platforms/qemu/arm/arm-qemu-armv7a/onlp/builds/src/arm_qemu_armv7a/module/src/arm_qemu_armv7a_config.c b/packages/platforms/qemu/arm/arm-qemu-armv7a/onlp/builds/src/arm_qemu_armv7a/module/src/arm_qemu_armv7a_config.c index c48831b9..72ffb7d4 100644 --- a/packages/platforms/qemu/arm/arm-qemu-armv7a/onlp/builds/src/arm_qemu_armv7a/module/src/arm_qemu_armv7a_config.c +++ b/packages/platforms/qemu/arm/arm-qemu-armv7a/onlp/builds/src/arm_qemu_armv7a/module/src/arm_qemu_armv7a_config.c @@ -80,7 +80,7 @@ arm_qemu_armv7a_config_lookup(const char* setting) { int i; for(i = 0; arm_qemu_armv7a_config_settings[i].name; i++) { - if(strcmp(arm_qemu_armv7a_config_settings[i].name, setting)) { + if(!strcmp(arm_qemu_armv7a_config_settings[i].name, setting)) { return arm_qemu_armv7a_config_settings[i].value; } } diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile b/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile index eeee420c..cfdd1130 100644 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile +++ b/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile @@ -3,7 +3,7 @@ # # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := quanta_sys_eeprom AUTOMODULE := quanta_sys_eeprom include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_config.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_config.c index 388154f9..517a3362 100644 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_config.c +++ b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_config.c @@ -55,7 +55,7 @@ quanta_sys_eeprom_config_lookup(const char* setting) { int i; for(i = 0; quanta_sys_eeprom_config_settings[i].name; i++) { - if(strcmp(quanta_sys_eeprom_config_settings[i].name, setting)) { + if(!strcmp(quanta_sys_eeprom_config_settings[i].name, setting)) { return quanta_sys_eeprom_config_settings[i].value; } } diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/module/src/powerpc_quanta_lb9_config.c b/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/module/src/powerpc_quanta_lb9_config.c index 125fdbf2..036385be 100644 --- a/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/module/src/powerpc_quanta_lb9_config.c +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/onlp/builds/src/module/src/powerpc_quanta_lb9_config.c @@ -75,7 +75,7 @@ powerpc_quanta_lb9_config_lookup(const char* setting) { int i; for(i = 0; powerpc_quanta_lb9_config_settings[i].name; i++) { - if(strcmp(powerpc_quanta_lb9_config_settings[i].name, setting)) { + if(!strcmp(powerpc_quanta_lb9_config_settings[i].name, setting)) { return powerpc_quanta_lb9_config_settings[i].value; } } diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_config.c b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_config.c index d1c9a6eb..0563d8d9 100644 --- a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_config.c +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_config.c @@ -75,7 +75,7 @@ powerpc_quanta_ly2_config_lookup(const char* setting) { int i; for(i = 0; powerpc_quanta_ly2_config_settings[i].name; i++) { - if(strcmp(powerpc_quanta_ly2_config_settings[i].name, setting)) { + if(!strcmp(powerpc_quanta_ly2_config_settings[i].name, setting)) { return powerpc_quanta_ly2_config_settings[i].value; } } diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_int.h b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_int.h index 3e535915..0d6a45e5 100644 --- a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_int.h +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/onlp/builds/src/module/src/powerpc_quanta_ly2_int.h @@ -9,41 +9,94 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -108,94 +161,41 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c index 303a0cce..737a2958 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ix1_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ix1_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ix1_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ix1_rangeley_config_settings[i].name, setting)) { return x86_64_quanta_ix1_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h index 4272d0f8..5b250e26 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1-rangeley/onlp/builds/src/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c index f71213bf..84409c95 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ix1b_rglbmc_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ix1b_rglbmc_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ix1b_rglbmc_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ix1b_rglbmc_config_settings[i].name, setting)) { return x86_64_quanta_ix1b_rglbmc_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h index c024d187..505d5fa7 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix1b-rglbmc/onlp/builds/src/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c index c414758b..1f9426b0 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ix2_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ix2_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ix2_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ix2_rangeley_config_settings[i].name, setting)) { return x86_64_quanta_ix2_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h index 27757bb2..0e04224c 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix2-rangeley/onlp/builds/src/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c index 2a275c76..4beb57c8 100644 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ix8_rglbmc_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ix8_rglbmc_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ix8_rglbmc_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ix8_rglbmc_config_settings[i].name, setting)) { return x86_64_quanta_ix8_rglbmc_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h index 43541398..98593b9d 100644 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ix8-rglbmc/onlp/builds/src/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c index 54df778a..835814e9 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ly4r_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ly4r_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ly4r_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ly4r_config_settings[i].name, setting)) { return x86_64_quanta_ly4r_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h index 8263e9c3..3f1b1161 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly4r/onlp/builds/src/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c index 362df388..fe180ad9 100644 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ly6_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ly6_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ly6_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ly6_rangeley_config_settings[i].name, setting)) { return x86_64_quanta_ly6_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h index 8f1c4edc..22cab4f3 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly6-rangeley/onlp/builds/src/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c index 0a811a3b..bf8c37fb 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ly7_rglbmc_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ly7_rglbmc_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ly7_rglbmc_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ly7_rglbmc_config_settings[i].name, setting)) { return x86_64_quanta_ly7_rglbmc_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h index c0d51dca..a221de61 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c index 6aeea86b..342ebb3b 100644 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ly8_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ly8_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ly8_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ly8_rangeley_config_settings[i].name, setting)) { return x86_64_quanta_ly8_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h index 53dbbd7a..006cc533 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly8-rangeley/onlp/builds/src/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c index 246a95a2..2d4829e8 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c @@ -75,7 +75,7 @@ x86_64_quanta_ly9_rangeley_config_lookup(const char* setting) { int i; for(i = 0; x86_64_quanta_ly9_rangeley_config_settings[i].name; i++) { - if(strcmp(x86_64_quanta_ly9_rangeley_config_settings[i].name, setting)) { + if(!strcmp(x86_64_quanta_ly9_rangeley_config_settings[i].name, setting)) { return x86_64_quanta_ly9_rangeley_config_settings[i].value; } } diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h index b750aae2..f6372bbe 100755 --- a/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly9-rangeley/onlp/builds/src/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h @@ -10,46 +10,102 @@ #include /* */ -/** thermal_oid */ -typedef enum thermal_oid_e { - THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; /** Enum names. */ -const char* thermal_oid_name(thermal_oid_t e); +const char* fan_id_name(fan_id_t e); /** Enum values. */ -int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); +int fan_id_value(const char* str, fan_id_t* e, int substr); /** Enum descriptions. */ -const char* thermal_oid_desc(thermal_oid_t e); +const char* fan_id_desc(fan_id_t e); /** Enum validator. */ -int thermal_oid_valid(thermal_oid_t e); +int fan_id_valid(fan_id_t e); /** validator */ -#define THERMAL_OID_VALID(_e) \ - (thermal_oid_valid((_e))) +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) -/** thermal_oid_map table. */ -extern aim_map_si_t thermal_oid_map[]; -/** thermal_oid_desc_map table. */ -extern aim_map_si_t thermal_oid_desc_map[]; +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; /** psu_oid */ typedef enum psu_oid_e { @@ -119,102 +175,46 @@ extern aim_map_si_t thermal_id_map[]; /** thermal_id_desc_map table. */ extern aim_map_si_t thermal_id_desc_map[]; -/** fan_id */ -typedef enum fan_id_e { - FAN_ID_FAN1 = 1, - FAN_ID_FAN2 = 2, - FAN_ID_FAN3 = 3, - FAN_ID_FAN4 = 4, - FAN_ID_FAN5 = 5, - FAN_ID_FAN6 = 6, - FAN_ID_FAN7 = 7, - FAN_ID_FAN8 = 8, - FAN_ID_FAN9 = 9, - FAN_ID_FAN10 = 10, -} fan_id_t; +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; /** Enum names. */ -const char* fan_id_name(fan_id_t e); +const char* thermal_oid_name(thermal_oid_t e); /** Enum values. */ -int fan_id_value(const char* str, fan_id_t* e, int substr); +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); /** Enum descriptions. */ -const char* fan_id_desc(fan_id_t e); +const char* thermal_oid_desc(thermal_oid_t e); /** Enum validator. */ -int fan_id_valid(fan_id_t e); +int thermal_oid_valid(thermal_oid_t e); /** validator */ -#define FAN_ID_VALID(_e) \ - (fan_id_valid((_e))) +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) -/** fan_id_map table. */ -extern aim_map_si_t fan_id_map[]; -/** fan_id_desc_map table. */ -extern aim_map_si_t fan_id_desc_map[]; - -/** psu_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2, -} psu_id_t; - -/** Enum names. */ -const char* psu_id_name(psu_id_t e); - -/** Enum values. */ -int psu_id_value(const char* str, psu_id_t* e, int substr); - -/** Enum descriptions. */ -const char* psu_id_desc(psu_id_t e); - -/** Enum validator. */ -int psu_id_valid(psu_id_t e); - -/** validator */ -#define PSU_ID_VALID(_e) \ - (psu_id_valid((_e))) - -/** psu_id_map table. */ -extern aim_map_si_t psu_id_map[]; -/** psu_id_desc_map table. */ -extern aim_map_si_t psu_id_desc_map[]; - -/** fan_oid */ -typedef enum fan_oid_e { - FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), - FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), - FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), - FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), - FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), - FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), - FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), - FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), - FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), - FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), -} fan_oid_t; - -/** Enum names. */ -const char* fan_oid_name(fan_oid_t e); - -/** Enum values. */ -int fan_oid_value(const char* str, fan_oid_t* e, int substr); - -/** Enum descriptions. */ -const char* fan_oid_desc(fan_oid_t e); - -/** Enum validator. */ -int fan_oid_valid(fan_oid_t e); - -/** validator */ -#define FAN_OID_VALID(_e) \ - (fan_oid_valid((_e))) - -/** fan_oid_map table. */ -extern aim_map_si_t fan_oid_map[]; -/** fan_oid_desc_map table. */ -extern aim_map_si_t fan_oid_desc_map[]; +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; /* */ /* psu info table */ From c904d3bf65b1b4048920c8b80f95f60234a0bd55 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 8 Mar 2018 20:24:13 +0000 Subject: [PATCH 171/244] Latest --- sm/infra | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/infra b/sm/infra index 34c433a3..16ce9cd7 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 34c433a353012eddcfe596347f102f47ac72593f +Subproject commit 16ce9cd77f6639aac4813d698f9dd11f3ee47e7a From b92192e7dc7a17f6923ae57f13cf9ad9c29315de Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 8 Mar 2018 20:47:23 +0000 Subject: [PATCH 172/244] Update ignore settings. --- .../armel/kernels/kernel-3.2-lts-arm-iproc-all/builds/.gitignore | 1 + packages/platforms/ingrasys/x86-64/modules/builds/.gitignore | 1 + .../x86-64/x86-64-ingrasys-s9100/onlp/builds/lib/.gitignore | 1 + .../x86-64/x86-64-inventec-d7032q28b/modules/builds/.gitignore | 1 + .../x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/.gitignore | 1 + .../x86-64-inventec-d7032q28b/onlp/builds/onlpdump/.gitignore | 1 + .../quanta/powerpc/powerpc-quanta-ly2/modules/builds/.gitignore | 1 + 7 files changed, 7 insertions(+) create mode 100644 packages/platforms/ingrasys/x86-64/modules/builds/.gitignore create mode 100644 packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/lib/.gitignore create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/.gitignore create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/.gitignore create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/.gitignore create mode 100644 packages/platforms/quanta/powerpc/powerpc-quanta-ly2/modules/builds/.gitignore diff --git a/packages/base/armel/kernels/kernel-3.2-lts-arm-iproc-all/builds/.gitignore b/packages/base/armel/kernels/kernel-3.2-lts-arm-iproc-all/builds/.gitignore index 3898a1cf..d780112f 100644 --- a/packages/base/armel/kernels/kernel-3.2-lts-arm-iproc-all/builds/.gitignore +++ b/packages/base/armel/kernels/kernel-3.2-lts-arm-iproc-all/builds/.gitignore @@ -1,2 +1,3 @@ linux-3.2* kernel-3.2* +lib/ diff --git a/packages/platforms/ingrasys/x86-64/modules/builds/.gitignore b/packages/platforms/ingrasys/x86-64/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/ingrasys/x86-64/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/lib/.gitignore b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/lib/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/lib/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/modules/builds/.gitignore b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/modules/builds/.gitignore @@ -0,0 +1 @@ +lib From 89ba156ad901674fb86ed5529f82ff9bb28c4df4 Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Fri, 9 Mar 2018 01:51:09 +0000 Subject: [PATCH 173/244] SWL-4346 change FAN RPM MAX so fan max percentage won't exceed 100% --- .../src/module/auto/powerpc_accton_as5710_54x.yml | 3 +++ .../powerpc_accton_as5710_54x_config.h | 10 ++++++++++ .../onlp/builds/src/module/src/fani.c | 3 ++- .../src/module/src/powerpc_accton_as5710_54x_config.c | 5 +++++ .../src/module/auto/x86_64_accton_as5812_54t.yml | 4 +++- .../x86_64_accton_as5812_54t_config.h | 10 ++++++++++ .../onlp/builds/src/module/src/fani.c | 3 ++- .../src/module/src/x86_64_accton_as5812_54t_config.c | 5 +++++ .../src/module/auto/x86_64_accton_as5812_54x.yml | 4 +++- .../x86_64_accton_as5812_54x_config.h | 10 ++++++++++ .../onlp/builds/src/module/src/fani.c | 3 ++- .../src/module/src/x86_64_accton_as5812_54x_config.c | 5 +++++ 12 files changed, 60 insertions(+), 5 deletions(-) diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/auto/powerpc_accton_as5710_54x.yml b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/auto/powerpc_accton_as5710_54x.yml index c9f356ab..aa4a563f 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/auto/powerpc_accton_as5710_54x.yml +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/auto/powerpc_accton_as5710_54x.yml @@ -29,6 +29,9 @@ cdefs: &cdefs - POWERPC_ACCTON_AS5710_54X_CONFIG_INCLUDE_DEBUG: doc: "Include debug tool." default: 0 +- POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX: + doc: "Maximum system fan(Front) rpm." + default: 19725 definitions: cdefs: diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/inc/powerpc_accton_as5710_54x/powerpc_accton_as5710_54x_config.h b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/inc/powerpc_accton_as5710_54x/powerpc_accton_as5710_54x_config.h index a5c4df80..f58bb3b5 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/inc/powerpc_accton_as5710_54x/powerpc_accton_as5710_54x_config.h +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/inc/powerpc_accton_as5710_54x/powerpc_accton_as5710_54x_config.h @@ -99,6 +99,16 @@ #define POWERPC_ACCTON_AS5710_54X_CONFIG_INCLUDE_DEBUG 0 #endif +/** + * POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX + * + * Maximum system fan(Front) rpm. */ + + +#ifndef POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX +#define POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX 19725 +#endif + /** diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/fani.c index 362b7b90..4590beda 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/fani.c @@ -27,6 +27,7 @@ #include #include #include "platform_lib.h" +#include "powerpc_accton_as5710_54x/powerpc_accton_as5710_54x_config.h" #define PREFIX_PATH_ON_MAIN_BROAD "/sys/class/hwmon/hwmon11/" #define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/" @@ -190,7 +191,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) info->rpm = (info->rpm + atoi(r_data))/2; /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100)/16800; + info->percentage = (info->rpm * 100)/POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX; /* check present */ if (info->rpm > 0) diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c index da550d95..79a2d008 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/onlp/builds/src/module/src/powerpc_accton_as5710_54x_config.c @@ -49,6 +49,11 @@ powerpc_accton_as5710_54x_config_settings_t powerpc_accton_as5710_54x_config_set { __powerpc_accton_as5710_54x_config_STRINGIFY_NAME(POWERPC_ACCTON_AS5710_54X_CONFIG_INCLUDE_DEBUG), __powerpc_accton_as5710_54x_config_STRINGIFY_VALUE(POWERPC_ACCTON_AS5710_54X_CONFIG_INCLUDE_DEBUG) }, #else { POWERPC_ACCTON_AS5710_54X_CONFIG_INCLUDE_DEBUG(__powerpc_accton_as5710_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX + { __powerpc_accton_as5710_54x_config_STRINGIFY_NAME(POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX), __powerpc_accton_as5710_54x_config_STRINGIFY_VALUE(POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX) }, +#else +{ POWERPC_ACCTON_AS5710_54X_CONFIG_SYS_FAN_FRONT_RPM_MAX(__powerpc_accton_as5710_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml index 6cea6947..a6146a3f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/auto/x86_64_accton_as5812_54t.yml @@ -29,7 +29,9 @@ cdefs: &cdefs - X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 - +- x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX: + doc: "Maximum system fan(Front) rpm." + default: 21500 definitions: cdefs: diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h index 2ece1c39..f30e6030 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/inc/x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h @@ -99,6 +99,16 @@ #define X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif +/** + * x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX + * + * Maximum system fan(Front) rpm. */ + + +#ifndef x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX +#define x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX 21500 +#endif + /** diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c index 4c43da33..6a0f9772 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/fani.c @@ -28,6 +28,7 @@ #include #include #include "platform_lib.h" +#include "x86_64_accton_as5812_54t/x86_64_accton_as5812_54t_config.h" #define PREFIX_PATH_ON_MAIN_BOARD "/sys/devices/platform/as5812_54t_fan/" #define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/" @@ -191,7 +192,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) info->rpm = (info->rpm + atoi(r_data))/2; /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100)/16800; + info->percentage = (info->rpm * 100)/x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX; /* check present */ if (info->rpm > 0) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c index 3b9e9acf..8cf4c7c8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/x86_64_accton_as5812_54t_config.c @@ -49,6 +49,11 @@ x86_64_accton_as5812_54t_config_settings_t x86_64_accton_as5812_54t_config_setti { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else { X86_64_ACCTON_AS5812_54T_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX + { __x86_64_accton_as5812_54t_config_STRINGIFY_NAME(x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX), __x86_64_accton_as5812_54t_config_STRINGIFY_VALUE(x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX) }, +#else +{ x86_64_accton_as5812_54t_CONFIG_SYS_FAN_FRONT_RPM_MAX(__x86_64_accton_as5812_54t_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml index 7d360ebd..b2e4345c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/auto/x86_64_accton_as5812_54x.yml @@ -29,7 +29,9 @@ cdefs: &cdefs - X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 - +- x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX: + doc: "Maximum system fan(Front) rpm." + default: 21500 definitions: cdefs: diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h index a93d2c16..7a4afd0f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/inc/x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h @@ -99,6 +99,16 @@ #define X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif +/** + * x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX + * + * Maximum system fan(Front) rpm. */ + + +#ifndef x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX +#define x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX 21500 +#endif + /** diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/fani.c index 4e76e24c..9c9200c1 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/fani.c @@ -28,6 +28,7 @@ #include #include #include "platform_lib.h" +#include "x86_64_accton_as5812_54x/x86_64_accton_as5812_54x_config.h" #define PREFIX_PATH_ON_MAIN_BOARD "/sys/devices/platform/as5812_54x_fan/" #define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/" @@ -191,7 +192,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) info->rpm = (info->rpm + atoi(r_data))/2; /* get speed percentage from rpm */ - info->percentage = (info->rpm * 100)/16800; + info->percentage = (info->rpm * 100)/x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX; /* check present */ if (info->rpm > 0) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c index c3301e27..1c91eb7b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/x86_64_accton_as5812_54x_config.c @@ -49,6 +49,11 @@ x86_64_accton_as5812_54x_config_settings_t x86_64_accton_as5812_54x_config_setti { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else { X86_64_ACCTON_AS5812_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX + { __x86_64_accton_as5812_54x_config_STRINGIFY_NAME(x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX), __x86_64_accton_as5812_54x_config_STRINGIFY_VALUE(x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX) }, +#else +{ x86_64_accton_as5812_54x_CONFIG_SYS_FAN_FRONT_RPM_MAX(__x86_64_accton_as5812_54x_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; From 8cb1b5b6303fee9bce1d7d05ade45af88e751e16 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Fri, 9 Mar 2018 10:44:08 +0800 Subject: [PATCH 174/244] 1. Rename 54x to be 54xk. 2. IDPROM changes to I2C address 0x56 instead of 0x54. Signed-off-by: roy_lee --- .../x86-64-accton-as5916-54xk/.gitignore | 2 +- .../x86-64-accton-as5916-54xk/modules/PKG.yml | 2 +- .../modules/builds/Makefile | 2 +- .../builds/x86-64-accton-as5916-54xk-fan.c | 78 ++++++------ .../builds/x86-64-accton-as5916-54xk-leds.c | 116 +++++++++--------- .../builds/x86-64-accton-as5916-54xk-psu.c | 82 ++++++------- .../builds/x86-64-accton-as5916-54xk-sfp.c | 54 ++++---- .../x86-64-accton-as5916-54xk/onlp/PKG.yml | 2 +- .../onlp/builds/lib/Makefile | 6 +- .../onlp/builds/onlpdump/Makefile | 2 +- .../onlp/builds/src/.module | 2 +- .../onlp/builds/src/Makefile | 4 +- .../onlp/builds/src/README | 2 +- .../onlp/builds/src/module/auto/make.mk | 6 +- .../module/auto/x86_64_accton_as5916_54xk.yml | 26 ++-- .../x86_64_accton_as5916_54xk.x | 2 +- .../x86_64_accton_as5916_54xk_config.h | 80 ++++++------ .../x86_64_accton_as5916_54xk_dox.h | 16 +-- .../x86_64_accton_as5916_54xk_porting.h | 92 +++++++------- .../onlp/builds/src/module/make.mk | 6 +- .../onlp/builds/src/module/src/Makefile | 2 +- .../onlp/builds/src/module/src/ledi.c | 2 +- .../onlp/builds/src/module/src/make.mk | 2 +- .../onlp/builds/src/module/src/platform_lib.h | 4 +- .../onlp/builds/src/module/src/sfpi.c | 2 +- .../onlp/builds/src/module/src/sysi.c | 6 +- .../src/x86_64_accton_as5916_54xk_config.c | 78 ++++++------ .../src/x86_64_accton_as5916_54xk_enums.c | 2 +- .../src/x86_64_accton_as5916_54xk_int.h | 10 +- .../src/x86_64_accton_as5916_54xk_log.c | 12 +- .../src/x86_64_accton_as5916_54xk_log.h | 8 +- .../src/x86_64_accton_as5916_54xk_module.c | 10 +- .../src/x86_64_accton_as5916_54xk_ucli.c | 24 ++-- .../platform-config/r1/PKG.yml | 2 +- .../src/lib/x86-64-accton-as5916-54xk-r1.yml | 2 +- .../x86_64_accton_as5916_54xk_r1/__init__.py | 22 ++-- 36 files changed, 385 insertions(+), 385 deletions(-) mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore index 2e2944b3..0e4c79d6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/.gitignore @@ -1,2 +1,2 @@ -*x86*64*accton*as5916*54x*.mk +*x86*64*accton*as5916*54xk*.mk onlpdump.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml index b6c16c5e..2506401a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/PKG.yml @@ -1 +1 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as5916-54x ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as5916-54xk ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile index 0ae14eaa..12f05c94 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/Makefile @@ -1,6 +1,6 @@ KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 KMODULES := $(wildcard *.c) VENDOR := accton -BASENAME := x86-64-accton-as5916-54x +BASENAME := x86-64-accton-as5916-54xk ARCH := x86_64 include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c index e69660e4..4eb38682 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-fan.c @@ -1,5 +1,5 @@ /* - * A hwmon driver for the Accton as5916 54x fan + * A hwmon driver for the Accton as5916 54xk fan * * Copyright (C) 2016 Accton Technology Corporation. * Brandon Chuang @@ -30,10 +30,10 @@ #include #include -#define DRVNAME "as5916_54x_fan" +#define DRVNAME "as5916_54xk_fan" #define MAX_FAN_SPEED_RPM 25500 -static struct as5916_54x_fan_data *as5916_54x_fan_update_device(struct device *dev); +static struct as5916_54xk_fan_data *as5916_54xk_fan_update_device(struct device *dev); static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); @@ -59,7 +59,7 @@ static const u8 fan_reg[] = { }; /* Each client has this additional data */ -struct as5916_54x_fan_data { +struct as5916_54xk_fan_data { struct device *hwmon_dev; struct mutex update_lock; char valid; /* != 0 if registers are valid */ @@ -171,7 +171,7 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); -static struct attribute *as5916_54x_fan_attributes[] = { +static struct attribute *as5916_54xk_fan_attributes[] = { /* fan related attributes */ DECLARE_FAN_FAULT_ATTR(1), DECLARE_FAN_FAULT_ATTR(2), @@ -206,12 +206,12 @@ static struct attribute *as5916_54x_fan_attributes[] = { #define FAN_MAX_DUTY_CYCLE 100 #define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 -static int as5916_54x_fan_read_value(struct i2c_client *client, u8 reg) +static int as5916_54xk_fan_read_value(struct i2c_client *client, u8 reg) { return i2c_smbus_read_byte_data(client, reg); } -static int as5916_54x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +static int as5916_54xk_fan_write_value(struct i2c_client *client, u8 reg, u8 value) { return i2c_smbus_write_byte_data(client, reg, value); } @@ -244,7 +244,7 @@ static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) return !(reg_val & BIT(id)); } -static u8 is_fan_fault(struct as5916_54x_fan_data *data, enum fan_id id) +static u8 is_fan_fault(struct as5916_54xk_fan_data *data, enum fan_id id) { u8 ret = 1; int front_fan_index = FAN1_FRONT_SPEED_RPM + id; @@ -273,8 +273,8 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, if (value < 0 || value > FAN_MAX_DUTY_CYCLE) return -EINVAL; - as5916_54x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ - as5916_54x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + as5916_54xk_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as5916_54xk_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); return count; } @@ -282,7 +282,7 @@ static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as5916_54x_fan_data *data = as5916_54x_fan_update_device(dev); + struct as5916_54xk_fan_data *data = as5916_54xk_fan_update_device(dev); ssize_t ret = 0; if (data->valid) { @@ -345,14 +345,14 @@ static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, return ret; } -static const struct attribute_group as5916_54x_fan_group = { - .attrs = as5916_54x_fan_attributes, +static const struct attribute_group as5916_54xk_fan_group = { + .attrs = as5916_54xk_fan_attributes, }; -static struct as5916_54x_fan_data *as5916_54x_fan_update_device(struct device *dev) +static struct as5916_54xk_fan_data *as5916_54xk_fan_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - struct as5916_54x_fan_data *data = i2c_get_clientdata(client); + struct as5916_54xk_fan_data *data = i2c_get_clientdata(client); mutex_lock(&data->update_lock); @@ -360,13 +360,13 @@ static struct as5916_54x_fan_data *as5916_54x_fan_update_device(struct device *d !data->valid) { int i; - dev_dbg(&client->dev, "Starting as5916_54x_fan update\n"); + dev_dbg(&client->dev, "Starting as5916_54xk_fan update\n"); data->valid = 0; /* Update fan data */ for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { - int status = as5916_54x_fan_read_value(client, fan_reg[i]); + int status = as5916_54xk_fan_read_value(client, fan_reg[i]); if (status < 0) { data->valid = 0; @@ -388,10 +388,10 @@ static struct as5916_54x_fan_data *as5916_54x_fan_update_device(struct device *d return data; } -static int as5916_54x_fan_probe(struct i2c_client *client, +static int as5916_54xk_fan_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { - struct as5916_54x_fan_data *data; + struct as5916_54xk_fan_data *data; int status; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -399,7 +399,7 @@ static int as5916_54x_fan_probe(struct i2c_client *client, goto exit; } - data = kzalloc(sizeof(struct as5916_54x_fan_data), GFP_KERNEL); + data = kzalloc(sizeof(struct as5916_54xk_fan_data), GFP_KERNEL); if (!data) { status = -ENOMEM; goto exit; @@ -412,7 +412,7 @@ static int as5916_54x_fan_probe(struct i2c_client *client, dev_info(&client->dev, "chip found\n"); /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5916_54x_fan_group); + status = sysfs_create_group(&client->dev.kobj, &as5916_54xk_fan_group); if (status) { goto exit_free; } @@ -429,7 +429,7 @@ static int as5916_54x_fan_probe(struct i2c_client *client, return 0; exit_remove: - sysfs_remove_group(&client->dev.kobj, &as5916_54x_fan_group); + sysfs_remove_group(&client->dev.kobj, &as5916_54xk_fan_group); exit_free: kfree(data); exit: @@ -437,11 +437,11 @@ exit: return status; } -static int as5916_54x_fan_remove(struct i2c_client *client) +static int as5916_54xk_fan_remove(struct i2c_client *client) { - struct as5916_54x_fan_data *data = i2c_get_clientdata(client); + struct as5916_54xk_fan_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as5916_54x_fan_group); + sysfs_remove_group(&client->dev.kobj, &as5916_54xk_fan_group); return 0; } @@ -449,37 +449,37 @@ static int as5916_54x_fan_remove(struct i2c_client *client) /* Addresses to scan */ static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; -static const struct i2c_device_id as5916_54x_fan_id[] = { - { "as5916_54x_fan", 0 }, +static const struct i2c_device_id as5916_54xk_fan_id[] = { + { "as5916_54xk_fan", 0 }, {} }; -MODULE_DEVICE_TABLE(i2c, as5916_54x_fan_id); +MODULE_DEVICE_TABLE(i2c, as5916_54xk_fan_id); -static struct i2c_driver as5916_54x_fan_driver = { +static struct i2c_driver as5916_54xk_fan_driver = { .class = I2C_CLASS_HWMON, .driver = { .name = DRVNAME, }, - .probe = as5916_54x_fan_probe, - .remove = as5916_54x_fan_remove, - .id_table = as5916_54x_fan_id, + .probe = as5916_54xk_fan_probe, + .remove = as5916_54xk_fan_remove, + .id_table = as5916_54xk_fan_id, .address_list = normal_i2c, }; -static int __init as5916_54x_fan_init(void) +static int __init as5916_54xk_fan_init(void) { - return i2c_add_driver(&as5916_54x_fan_driver); + return i2c_add_driver(&as5916_54xk_fan_driver); } -static void __exit as5916_54x_fan_exit(void) +static void __exit as5916_54xk_fan_exit(void) { - i2c_del_driver(&as5916_54x_fan_driver); + i2c_del_driver(&as5916_54xk_fan_driver); } -module_init(as5916_54x_fan_init); -module_exit(as5916_54x_fan_exit); +module_init(as5916_54xk_fan_init); +module_exit(as5916_54xk_fan_exit); MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as5916_54x_fan driver"); +MODULE_DESCRIPTION("as5916_54xk_fan driver"); MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c index 7f55dae7..f155e970 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-leds.c @@ -1,5 +1,5 @@ /* - * A LED driver for the accton_as5916_54x_led + * A LED driver for the accton_as5916_54xk_led * * Copyright (C) 2016 Accton Technology Corporation. * Brandon Chuang @@ -27,7 +27,7 @@ #include #include -#define DRVNAME "accton_as5916_54x_led" +#define DRVNAME "accton_as5916_54xk_led" #define DEBUG_MODE 1 @@ -41,7 +41,7 @@ extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); -struct accton_as5916_54x_led_data { +struct accton_as5916_54xk_led_data { struct platform_device *pdev; struct mutex update_lock; char valid; /* != 0 if registers are valid */ @@ -51,7 +51,7 @@ struct accton_as5916_54x_led_data { 2 ~ 4 = SYSTEM LED */ }; -static struct accton_as5916_54x_led_data *ledctl = NULL; +static struct accton_as5916_54xk_led_data *ledctl = NULL; #define LED_CNTRLER_I2C_ADDRESS (0x60) @@ -155,17 +155,17 @@ static u8 led_light_mode_to_reg_val(enum led_type type, return reg_val; } -static int accton_as5916_54x_led_read_value(u8 reg) +static int accton_as5916_54xk_led_read_value(u8 reg) { return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } -static int accton_as5916_54x_led_write_value(u8 reg, u8 value) +static int accton_as5916_54xk_led_write_value(u8 reg, u8 value) { return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } -static void accton_as5916_54x_led_update(void) +static void accton_as5916_54xk_led_update(void) { mutex_lock(&ledctl->update_lock); @@ -173,13 +173,13 @@ static void accton_as5916_54x_led_update(void) || !ledctl->valid) { int i; - dev_dbg(&ledctl->pdev->dev, "Starting accton_as5916_54x_led update\n"); + dev_dbg(&ledctl->pdev->dev, "Starting accton_as5916_54xk_led update\n"); ledctl->valid = 0; /* Update LED data */ for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { - int status = accton_as5916_54x_led_read_value(led_reg[i]); + int status = accton_as5916_54xk_led_read_value(led_reg[i]); if (status < 0) { dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); @@ -197,14 +197,14 @@ exit: mutex_unlock(&ledctl->update_lock); } -static void accton_as5916_54x_led_set(struct led_classdev *led_cdev, +static void accton_as5916_54xk_led_set(struct led_classdev *led_cdev, enum led_brightness led_light_mode, u8 reg, enum led_type type) { int reg_val; mutex_lock(&ledctl->update_lock); - reg_val = accton_as5916_54x_led_read_value(reg); + reg_val = accton_as5916_54xk_led_read_value(reg); if (reg_val < 0) { dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); @@ -212,91 +212,91 @@ static void accton_as5916_54x_led_set(struct led_classdev *led_cdev, } reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); - accton_as5916_54x_led_write_value(reg, reg_val); + accton_as5916_54xk_led_write_value(reg, reg_val); ledctl->valid = 0; exit: mutex_unlock(&ledctl->update_lock); } -static void accton_as7312_54x_led_auto_set(struct led_classdev *led_cdev, +static void accton_as7312_54xk_led_auto_set(struct led_classdev *led_cdev, enum led_brightness led_light_mode) { } -static enum led_brightness accton_as7312_54x_led_auto_get(struct led_classdev *cdev) +static enum led_brightness accton_as7312_54xk_led_auto_get(struct led_classdev *cdev) { return LED_MODE_AUTO; } -static void accton_as5916_54x_led_diag_set(struct led_classdev *led_cdev, +static void accton_as5916_54xk_led_diag_set(struct led_classdev *led_cdev, enum led_brightness led_light_mode) { - accton_as5916_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_DIAG); + accton_as5916_54xk_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_DIAG); } -static enum led_brightness accton_as5916_54x_led_diag_get(struct led_classdev *cdev) +static enum led_brightness accton_as5916_54xk_led_diag_get(struct led_classdev *cdev) { - accton_as5916_54x_led_update(); + accton_as5916_54xk_led_update(); return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); } -static enum led_brightness accton_as5916_54x_led_loc_get(struct led_classdev *cdev) +static enum led_brightness accton_as5916_54xk_led_loc_get(struct led_classdev *cdev) { - accton_as5916_54x_led_update(); + accton_as5916_54xk_led_update(); return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); } -static void accton_as5916_54x_led_loc_set(struct led_classdev *led_cdev, +static void accton_as5916_54xk_led_loc_set(struct led_classdev *led_cdev, enum led_brightness led_light_mode) { - accton_as5916_54x_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_LOC); + accton_as5916_54xk_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_LOC); } -static struct led_classdev accton_as5916_54x_leds[] = { +static struct led_classdev accton_as5916_54xk_leds[] = { [LED_TYPE_LOC] = { - .name = "accton_as5916_54x_led::loc", + .name = "accton_as5916_54xk_led::loc", .default_trigger = "unused", - .brightness_set = accton_as5916_54x_led_loc_set, - .brightness_get = accton_as5916_54x_led_loc_get, + .brightness_set = accton_as5916_54xk_led_loc_set, + .brightness_get = accton_as5916_54xk_led_loc_get, .max_brightness = LED_MODE_ORANGE, }, [LED_TYPE_DIAG] = { - .name = "accton_as5916_54x_led::diag", + .name = "accton_as5916_54xk_led::diag", .default_trigger = "unused", - .brightness_set = accton_as5916_54x_led_diag_set, - .brightness_get = accton_as5916_54x_led_diag_get, + .brightness_set = accton_as5916_54xk_led_diag_set, + .brightness_get = accton_as5916_54xk_led_diag_get, .max_brightness = LED_MODE_GREEN, }, [LED_TYPE_PSU1] = { - .name = "accton_as5916_54x_led::psu1", + .name = "accton_as5916_54xk_led::psu1", .default_trigger = "unused", - .brightness_set = accton_as7312_54x_led_auto_set, - .brightness_get = accton_as7312_54x_led_auto_get, + .brightness_set = accton_as7312_54xk_led_auto_set, + .brightness_get = accton_as7312_54xk_led_auto_get, .max_brightness = LED_MODE_AUTO, }, [LED_TYPE_PSU2] = { - .name = "accton_as5916_54x_led::psu2", + .name = "accton_as5916_54xk_led::psu2", .default_trigger = "unused", - .brightness_set = accton_as7312_54x_led_auto_set, - .brightness_get = accton_as7312_54x_led_auto_get, + .brightness_set = accton_as7312_54xk_led_auto_set, + .brightness_get = accton_as7312_54xk_led_auto_get, .max_brightness = LED_MODE_AUTO, }, [LED_TYPE_FAN] = { - .name = "accton_as5916_54x_led::fan", + .name = "accton_as5916_54xk_led::fan", .default_trigger = "unused", - .brightness_set = accton_as7312_54x_led_auto_set, - .brightness_get = accton_as7312_54x_led_auto_get, + .brightness_set = accton_as7312_54xk_led_auto_set, + .brightness_get = accton_as7312_54xk_led_auto_get, .max_brightness = LED_MODE_AUTO, }, }; -static int accton_as5916_54x_led_probe(struct platform_device *pdev) +static int accton_as5916_54xk_led_probe(struct platform_device *pdev) { int ret, i; - for (i = 0; i < ARRAY_SIZE(accton_as5916_54x_leds); i++) { - ret = led_classdev_register(&pdev->dev, &accton_as5916_54x_leds[i]); + for (i = 0; i < ARRAY_SIZE(accton_as5916_54xk_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as5916_54xk_leds[i]); if (ret < 0) { break; @@ -304,48 +304,48 @@ static int accton_as5916_54x_led_probe(struct platform_device *pdev) } /* Check if all LEDs were successfully registered */ - if (i != ARRAY_SIZE(accton_as5916_54x_leds)){ + if (i != ARRAY_SIZE(accton_as5916_54xk_leds)){ int j; /* only unregister the LEDs that were successfully registered */ for (j = 0; j < i; j++) { - led_classdev_unregister(&accton_as5916_54x_leds[i]); + led_classdev_unregister(&accton_as5916_54xk_leds[i]); } } return ret; } -static int accton_as5916_54x_led_remove(struct platform_device *pdev) +static int accton_as5916_54xk_led_remove(struct platform_device *pdev) { int i; - for (i = 0; i < ARRAY_SIZE(accton_as5916_54x_leds); i++) { - led_classdev_unregister(&accton_as5916_54x_leds[i]); + for (i = 0; i < ARRAY_SIZE(accton_as5916_54xk_leds); i++) { + led_classdev_unregister(&accton_as5916_54xk_leds[i]); } return 0; } -static struct platform_driver accton_as5916_54x_led_driver = { - .probe = accton_as5916_54x_led_probe, - .remove = accton_as5916_54x_led_remove, +static struct platform_driver accton_as5916_54xk_led_driver = { + .probe = accton_as5916_54xk_led_probe, + .remove = accton_as5916_54xk_led_remove, .driver = { .name = DRVNAME, .owner = THIS_MODULE, }, }; -static int __init accton_as5916_54x_led_init(void) +static int __init accton_as5916_54xk_led_init(void) { int ret; - ret = platform_driver_register(&accton_as5916_54x_led_driver); + ret = platform_driver_register(&accton_as5916_54xk_led_driver); if (ret < 0) { goto exit; } - ledctl = kzalloc(sizeof(struct accton_as5916_54x_led_data), GFP_KERNEL); + ledctl = kzalloc(sizeof(struct accton_as5916_54xk_led_data), GFP_KERNEL); if (!ledctl) { ret = -ENOMEM; goto exit_driver; @@ -364,23 +364,23 @@ static int __init accton_as5916_54x_led_init(void) exit_free: kfree(ledctl); exit_driver: - platform_driver_unregister(&accton_as5916_54x_led_driver); + platform_driver_unregister(&accton_as5916_54xk_led_driver); exit: return ret; } -static void __exit accton_as5916_54x_led_exit(void) +static void __exit accton_as5916_54xk_led_exit(void) { platform_device_unregister(ledctl->pdev); - platform_driver_unregister(&accton_as5916_54x_led_driver); + platform_driver_unregister(&accton_as5916_54xk_led_driver); kfree(ledctl); } -late_initcall(accton_as5916_54x_led_init); -module_exit(accton_as5916_54x_led_exit); +late_initcall(accton_as5916_54xk_led_init); +module_exit(accton_as5916_54xk_led_exit); MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton_as5916_54x_led driver"); +MODULE_DESCRIPTION("accton_as5916_54xk_led driver"); MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c index 4627df9c..a2737499 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-psu.c @@ -1,5 +1,5 @@ /* - * An hwmon driver for accton as5916_54x Power Module + * An hwmon driver for accton as5916_54xk Power Module * * Copyright (C) 2014 Accton Technology Corporation. * Brandon Chuang @@ -36,7 +36,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); -static int as5916_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +static int as5916_54xk_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned @@ -45,7 +45,7 @@ static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; /* Each client has this additional data */ -struct as5916_54x_psu_data { +struct as5916_54xk_psu_data { struct device *hwmon_dev; struct mutex update_lock; char valid; /* !=0 if registers are valid */ @@ -55,9 +55,9 @@ struct as5916_54x_psu_data { char model_name[9]; /* Model name, read from eeprom */ }; -static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *dev); +static struct as5916_54xk_psu_data *as5916_54xk_psu_update_device(struct device *dev); -enum as5916_54x_psu_sysfs_attributes { +enum as5916_54xk_psu_sysfs_attributes { PSU_PRESENT, PSU_MODEL_NAME, PSU_POWER_GOOD @@ -69,7 +69,7 @@ static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRE static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); -static struct attribute *as5916_54x_psu_attributes[] = { +static struct attribute *as5916_54xk_psu_attributes[] = { &sensor_dev_attr_psu_present.dev_attr.attr, &sensor_dev_attr_psu_model_name.dev_attr.attr, &sensor_dev_attr_psu_power_good.dev_attr.attr, @@ -80,7 +80,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as5916_54x_psu_data *data = as5916_54x_psu_update_device(dev); + struct as5916_54xk_psu_data *data = as5916_54xk_psu_update_device(dev); u8 status = 0; if (attr->index == PSU_PRESENT) { @@ -96,19 +96,19 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf) { - struct as5916_54x_psu_data *data = as5916_54x_psu_update_device(dev); + struct as5916_54xk_psu_data *data = as5916_54xk_psu_update_device(dev); return sprintf(buf, "%s\n", data->model_name); } -static const struct attribute_group as5916_54x_psu_group = { - .attrs = as5916_54x_psu_attributes, +static const struct attribute_group as5916_54xk_psu_group = { + .attrs = as5916_54xk_psu_attributes, }; -static int as5916_54x_psu_probe(struct i2c_client *client, +static int as5916_54xk_psu_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { - struct as5916_54x_psu_data *data; + struct as5916_54xk_psu_data *data; int status; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { @@ -116,7 +116,7 @@ static int as5916_54x_psu_probe(struct i2c_client *client, goto exit; } - data = kzalloc(sizeof(struct as5916_54x_psu_data), GFP_KERNEL); + data = kzalloc(sizeof(struct as5916_54xk_psu_data), GFP_KERNEL); if (!data) { status = -ENOMEM; goto exit; @@ -130,7 +130,7 @@ static int as5916_54x_psu_probe(struct i2c_client *client, dev_info(&client->dev, "chip found\n"); /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5916_54x_psu_group); + status = sysfs_create_group(&client->dev.kobj, &as5916_54xk_psu_group); if (status) { goto exit_free; } @@ -147,7 +147,7 @@ static int as5916_54x_psu_probe(struct i2c_client *client, return 0; exit_remove: - sysfs_remove_group(&client->dev.kobj, &as5916_54x_psu_group); + sysfs_remove_group(&client->dev.kobj, &as5916_54xk_psu_group); exit_free: kfree(data); exit: @@ -155,12 +155,12 @@ exit: return status; } -static int as5916_54x_psu_remove(struct i2c_client *client) +static int as5916_54xk_psu_remove(struct i2c_client *client) { - struct as5916_54x_psu_data *data = i2c_get_clientdata(client); + struct as5916_54xk_psu_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as5916_54x_psu_group); + sysfs_remove_group(&client->dev.kobj, &as5916_54xk_psu_group); kfree(data); return 0; @@ -168,29 +168,29 @@ static int as5916_54x_psu_remove(struct i2c_client *client) enum psu_index { - as5916_54x_psu1, - as5916_54x_psu2 + as5916_54xk_psu1, + as5916_54xk_psu2 }; -static const struct i2c_device_id as5916_54x_psu_id[] = { - { "as5916_54x_psu1", as5916_54x_psu1 }, - { "as5916_54x_psu2", as5916_54x_psu2 }, +static const struct i2c_device_id as5916_54xk_psu_id[] = { + { "as5916_54xk_psu1", as5916_54xk_psu1 }, + { "as5916_54xk_psu2", as5916_54xk_psu2 }, {} }; -MODULE_DEVICE_TABLE(i2c, as5916_54x_psu_id); +MODULE_DEVICE_TABLE(i2c, as5916_54xk_psu_id); -static struct i2c_driver as5916_54x_psu_driver = { +static struct i2c_driver as5916_54xk_psu_driver = { .class = I2C_CLASS_HWMON, .driver = { - .name = "as5916_54x_psu", + .name = "as5916_54xk_psu", }, - .probe = as5916_54x_psu_probe, - .remove = as5916_54x_psu_remove, - .id_table = as5916_54x_psu_id, + .probe = as5916_54xk_psu_probe, + .remove = as5916_54xk_psu_remove, + .id_table = as5916_54xk_psu_id, .address_list = normal_i2c, }; -static int as5916_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, +static int as5916_54xk_psu_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len) { int result = 0; @@ -219,10 +219,10 @@ static int as5916_54x_psu_read_block(struct i2c_client *client, u8 command, u8 * return result; } -static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *dev) +static struct as5916_54xk_psu_data *as5916_54xk_psu_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - struct as5916_54x_psu_data *data = i2c_get_clientdata(client); + struct as5916_54xk_psu_data *data = i2c_get_clientdata(client); mutex_lock(&data->update_lock); @@ -231,7 +231,7 @@ static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *d int status; int power_good = 0; - dev_dbg(&client->dev, "Starting as5916_54x update\n"); + dev_dbg(&client->dev, "Starting as5916_54xk update\n"); /* Read psu status */ status = accton_i2c_cpld_read(0x60, 0x2); @@ -248,7 +248,7 @@ static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *d power_good = data->status & BIT(3 - data->index); if (power_good) { - status = as5916_54x_psu_read_block(client, 0x20, data->model_name, + status = as5916_54xk_psu_read_block(client, 0x20, data->model_name, ARRAY_SIZE(data->model_name)-1); if (status < 0) { @@ -269,20 +269,20 @@ static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *d return data; } -static int __init as5916_54x_psu_init(void) +static int __init as5916_54xk_psu_init(void) { - return i2c_add_driver(&as5916_54x_psu_driver); + return i2c_add_driver(&as5916_54xk_psu_driver); } -static void __exit as5916_54x_psu_exit(void) +static void __exit as5916_54xk_psu_exit(void) { - i2c_del_driver(&as5916_54x_psu_driver); + i2c_del_driver(&as5916_54xk_psu_driver); } -module_init(as5916_54x_psu_init); -module_exit(as5916_54x_psu_exit); +module_init(as5916_54xk_psu_init); +module_exit(as5916_54xk_psu_exit); MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as5916_54x_psu driver"); +MODULE_DESCRIPTION("as5916_54xk_psu driver"); MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c index c924772b..c606e5c2 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/modules/builds/x86-64-accton-as5916-54xk-sfp.c @@ -1,5 +1,5 @@ /* - * SFP driver for accton as5916_54x sfp + * SFP driver for accton as5916_54xk sfp * * Copyright (C) Brandon Chuang * @@ -32,7 +32,7 @@ #include #include -#define DRIVER_NAME "as5916_54x_sfp" /* Platform dependent */ +#define DRIVER_NAME "as5916_54xk_sfp" /* Platform dependent */ #define DEBUG_MODE 0 @@ -181,30 +181,30 @@ static struct attribute *sfp_ddm_attributes[] = { #define CPLD_PORT_TO_FRONT_PORT(port) (port+1) enum port_numbers { -as5916_54x_sfp1, as5916_54x_sfp2, as5916_54x_sfp3, as5916_54x_sfp4, as5916_54x_sfp5, as5916_54x_sfp6, as5916_54x_sfp7, as5916_54x_sfp8, -as5916_54x_sfp9, as5916_54x_sfp10, as5916_54x_sfp11, as5916_54x_sfp12, as5916_54x_sfp13, as5916_54x_sfp14, as5916_54x_sfp15, as5916_54x_sfp16, -as5916_54x_sfp17, as5916_54x_sfp18, as5916_54x_sfp19, as5916_54x_sfp20, as5916_54x_sfp21, as5916_54x_sfp22, as5916_54x_sfp23, as5916_54x_sfp24, -as5916_54x_sfp25, as5916_54x_sfp26, as5916_54x_sfp27, as5916_54x_sfp28, as5916_54x_sfp29, as5916_54x_sfp30, as5916_54x_sfp31, as5916_54x_sfp32, -as5916_54x_sfp33, as5916_54x_sfp34, as5916_54x_sfp35, as5916_54x_sfp36, as5916_54x_sfp37, as5916_54x_sfp38, as5916_54x_sfp39, as5916_54x_sfp40, -as5916_54x_sfp41, as5916_54x_sfp42, as5916_54x_sfp43, as5916_54x_sfp44, as5916_54x_sfp45, as5916_54x_sfp46, as5916_54x_sfp47, as5916_54x_sfp48, -as5916_54x_sfp49, as5916_54x_sfp50, as5916_54x_sfp51, as5916_54x_sfp52, as5916_54x_sfp53, as5916_54x_sfp54 +as5916_54xk_sfp1, as5916_54xk_sfp2, as5916_54xk_sfp3, as5916_54xk_sfp4, as5916_54xk_sfp5, as5916_54xk_sfp6, as5916_54xk_sfp7, as5916_54xk_sfp8, +as5916_54xk_sfp9, as5916_54xk_sfp10, as5916_54xk_sfp11, as5916_54xk_sfp12, as5916_54xk_sfp13, as5916_54xk_sfp14, as5916_54xk_sfp15, as5916_54xk_sfp16, +as5916_54xk_sfp17, as5916_54xk_sfp18, as5916_54xk_sfp19, as5916_54xk_sfp20, as5916_54xk_sfp21, as5916_54xk_sfp22, as5916_54xk_sfp23, as5916_54xk_sfp24, +as5916_54xk_sfp25, as5916_54xk_sfp26, as5916_54xk_sfp27, as5916_54xk_sfp28, as5916_54xk_sfp29, as5916_54xk_sfp30, as5916_54xk_sfp31, as5916_54xk_sfp32, +as5916_54xk_sfp33, as5916_54xk_sfp34, as5916_54xk_sfp35, as5916_54xk_sfp36, as5916_54xk_sfp37, as5916_54xk_sfp38, as5916_54xk_sfp39, as5916_54xk_sfp40, +as5916_54xk_sfp41, as5916_54xk_sfp42, as5916_54xk_sfp43, as5916_54xk_sfp44, as5916_54xk_sfp45, as5916_54xk_sfp46, as5916_54xk_sfp47, as5916_54xk_sfp48, +as5916_54xk_sfp49, as5916_54xk_sfp50, as5916_54xk_sfp51, as5916_54xk_sfp52, as5916_54xk_sfp53, as5916_54xk_sfp54 }; static const struct i2c_device_id sfp_device_id[] = { -{ "as5916_54x_sfp1", as5916_54x_sfp1 }, { "as5916_54x_sfp2", as5916_54x_sfp2 }, { "as5916_54x_sfp3", as5916_54x_sfp3 }, { "as5916_54x_sfp4", as5916_54x_sfp4 }, -{ "as5916_54x_sfp5", as5916_54x_sfp5 }, { "as5916_54x_sfp6", as5916_54x_sfp6 }, { "as5916_54x_sfp7", as5916_54x_sfp7 }, { "as5916_54x_sfp8", as5916_54x_sfp8 }, -{ "as5916_54x_sfp9", as5916_54x_sfp9 }, { "as5916_54x_sfp10", as5916_54x_sfp10 }, { "as5916_54x_sfp11", as5916_54x_sfp11 }, { "as5916_54x_sfp12", as5916_54x_sfp12 }, -{ "as5916_54x_sfp13", as5916_54x_sfp13 }, { "as5916_54x_sfp14", as5916_54x_sfp14 }, { "as5916_54x_sfp15", as5916_54x_sfp15 }, { "as5916_54x_sfp16", as5916_54x_sfp16 }, -{ "as5916_54x_sfp17", as5916_54x_sfp17 }, { "as5916_54x_sfp18", as5916_54x_sfp18 }, { "as5916_54x_sfp19", as5916_54x_sfp19 }, { "as5916_54x_sfp20", as5916_54x_sfp20 }, -{ "as5916_54x_sfp21", as5916_54x_sfp21 }, { "as5916_54x_sfp22", as5916_54x_sfp22 }, { "as5916_54x_sfp23", as5916_54x_sfp23 }, { "as5916_54x_sfp24", as5916_54x_sfp24 }, -{ "as5916_54x_sfp25", as5916_54x_sfp25 }, { "as5916_54x_sfp26", as5916_54x_sfp26 }, { "as5916_54x_sfp27", as5916_54x_sfp27 }, { "as5916_54x_sfp28", as5916_54x_sfp28 }, -{ "as5916_54x_sfp29", as5916_54x_sfp29 }, { "as5916_54x_sfp30", as5916_54x_sfp30 }, { "as5916_54x_sfp31", as5916_54x_sfp31 }, { "as5916_54x_sfp32", as5916_54x_sfp32 }, -{ "as5916_54x_sfp33", as5916_54x_sfp33 }, { "as5916_54x_sfp34", as5916_54x_sfp34 }, { "as5916_54x_sfp35", as5916_54x_sfp35 }, { "as5916_54x_sfp36", as5916_54x_sfp36 }, -{ "as5916_54x_sfp37", as5916_54x_sfp37 }, { "as5916_54x_sfp38", as5916_54x_sfp38 }, { "as5916_54x_sfp39", as5916_54x_sfp39 }, { "as5916_54x_sfp40", as5916_54x_sfp40 }, -{ "as5916_54x_sfp41", as5916_54x_sfp41 }, { "as5916_54x_sfp42", as5916_54x_sfp42 }, { "as5916_54x_sfp43", as5916_54x_sfp43 }, { "as5916_54x_sfp44", as5916_54x_sfp44 }, -{ "as5916_54x_sfp45", as5916_54x_sfp45 }, { "as5916_54x_sfp46", as5916_54x_sfp46 }, { "as5916_54x_sfp47", as5916_54x_sfp47 }, { "as5916_54x_sfp48", as5916_54x_sfp48 }, -{ "as5916_54x_sfp49", as5916_54x_sfp49 }, { "as5916_54x_sfp50", as5916_54x_sfp50 }, { "as5916_54x_sfp51", as5916_54x_sfp51 }, { "as5916_54x_sfp52", as5916_54x_sfp52 }, -{ "as5916_54x_sfp53", as5916_54x_sfp53 }, { "as5916_54x_sfp54", as5916_54x_sfp54 }, +{ "as5916_54xk_sfp1", as5916_54xk_sfp1 }, { "as5916_54xk_sfp2", as5916_54xk_sfp2 }, { "as5916_54xk_sfp3", as5916_54xk_sfp3 }, { "as5916_54xk_sfp4", as5916_54xk_sfp4 }, +{ "as5916_54xk_sfp5", as5916_54xk_sfp5 }, { "as5916_54xk_sfp6", as5916_54xk_sfp6 }, { "as5916_54xk_sfp7", as5916_54xk_sfp7 }, { "as5916_54xk_sfp8", as5916_54xk_sfp8 }, +{ "as5916_54xk_sfp9", as5916_54xk_sfp9 }, { "as5916_54xk_sfp10", as5916_54xk_sfp10 }, { "as5916_54xk_sfp11", as5916_54xk_sfp11 }, { "as5916_54xk_sfp12", as5916_54xk_sfp12 }, +{ "as5916_54xk_sfp13", as5916_54xk_sfp13 }, { "as5916_54xk_sfp14", as5916_54xk_sfp14 }, { "as5916_54xk_sfp15", as5916_54xk_sfp15 }, { "as5916_54xk_sfp16", as5916_54xk_sfp16 }, +{ "as5916_54xk_sfp17", as5916_54xk_sfp17 }, { "as5916_54xk_sfp18", as5916_54xk_sfp18 }, { "as5916_54xk_sfp19", as5916_54xk_sfp19 }, { "as5916_54xk_sfp20", as5916_54xk_sfp20 }, +{ "as5916_54xk_sfp21", as5916_54xk_sfp21 }, { "as5916_54xk_sfp22", as5916_54xk_sfp22 }, { "as5916_54xk_sfp23", as5916_54xk_sfp23 }, { "as5916_54xk_sfp24", as5916_54xk_sfp24 }, +{ "as5916_54xk_sfp25", as5916_54xk_sfp25 }, { "as5916_54xk_sfp26", as5916_54xk_sfp26 }, { "as5916_54xk_sfp27", as5916_54xk_sfp27 }, { "as5916_54xk_sfp28", as5916_54xk_sfp28 }, +{ "as5916_54xk_sfp29", as5916_54xk_sfp29 }, { "as5916_54xk_sfp30", as5916_54xk_sfp30 }, { "as5916_54xk_sfp31", as5916_54xk_sfp31 }, { "as5916_54xk_sfp32", as5916_54xk_sfp32 }, +{ "as5916_54xk_sfp33", as5916_54xk_sfp33 }, { "as5916_54xk_sfp34", as5916_54xk_sfp34 }, { "as5916_54xk_sfp35", as5916_54xk_sfp35 }, { "as5916_54xk_sfp36", as5916_54xk_sfp36 }, +{ "as5916_54xk_sfp37", as5916_54xk_sfp37 }, { "as5916_54xk_sfp38", as5916_54xk_sfp38 }, { "as5916_54xk_sfp39", as5916_54xk_sfp39 }, { "as5916_54xk_sfp40", as5916_54xk_sfp40 }, +{ "as5916_54xk_sfp41", as5916_54xk_sfp41 }, { "as5916_54xk_sfp42", as5916_54xk_sfp42 }, { "as5916_54xk_sfp43", as5916_54xk_sfp43 }, { "as5916_54xk_sfp44", as5916_54xk_sfp44 }, +{ "as5916_54xk_sfp45", as5916_54xk_sfp45 }, { "as5916_54xk_sfp46", as5916_54xk_sfp46 }, { "as5916_54xk_sfp47", as5916_54xk_sfp47 }, { "as5916_54xk_sfp48", as5916_54xk_sfp48 }, +{ "as5916_54xk_sfp49", as5916_54xk_sfp49 }, { "as5916_54xk_sfp50", as5916_54xk_sfp50 }, { "as5916_54xk_sfp51", as5916_54xk_sfp51 }, { "as5916_54xk_sfp52", as5916_54xk_sfp52 }, +{ "as5916_54xk_sfp53", as5916_54xk_sfp53 }, { "as5916_54xk_sfp54", as5916_54xk_sfp54 }, { /* LIST END */ } }; MODULE_DEVICE_TABLE(i2c, sfp_device_id); @@ -351,7 +351,7 @@ static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) return data; } - DEBUG_PRINT("Starting as5916_54x sfp tx rx status update"); + DEBUG_PRINT("Starting as5916_54xk sfp tx rx status update"); mutex_lock(&data->update_lock); data->msa->valid = 0; memset(data->msa->status, 0, sizeof(data->msa->status)); @@ -1220,7 +1220,7 @@ static int sfp_device_probe(struct i2c_client *client, data->port = dev_id->driver_data; data->client = client; - if (dev_id->driver_data >= as5916_54x_sfp1 && dev_id->driver_data <= as5916_54x_sfp48) { + if (dev_id->driver_data >= as5916_54xk_sfp1 && dev_id->driver_data <= as5916_54xk_sfp48) { if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { data->driver_type = DRIVER_TYPE_SFP_MSA; return sfp_msa_probe(client, dev_id, &data->msa); @@ -1230,7 +1230,7 @@ static int sfp_device_probe(struct i2c_client *client, return sfp_ddm_probe(client, dev_id, &data->ddm); } } - else { /* as5916_54x_sfp49 ~ as5916_54x_sfp54 */ + else { /* as5916_54xk_sfp49 ~ as5916_54xk_sfp54 */ if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { data->driver_type = DRIVER_TYPE_QSFP; return qsfp_probe(client, dev_id, &data->qsfp); @@ -1306,7 +1306,7 @@ static void __exit sfp_exit(void) } MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5916_54x_sfp driver"); +MODULE_DESCRIPTION("accton as5916_54xk_sfp driver"); MODULE_LICENSE("GPL"); late_initcall(sfp_init); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml index ee1812ff..e9a7c297 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/PKG.yml @@ -1 +1 @@ -!include $ONL_TEMPLATES/onlp-platform-revision.yml PLATFORM=x86-64-accton-as5916-54x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu REVISION=r1 +!include $ONL_TEMPLATES/onlp-platform-revision.yml PLATFORM=x86-64-accton-as5916-54xk ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu REVISION=r1 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile index 1f155bfc..dad1416d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/lib/Makefile @@ -23,15 +23,15 @@ ############################################################ include $(ONL)/make/config.amd64.mk -MODULE := libonlp-x86-64-accton-as5916-54x +MODULE := libonlp-x86-64-accton-as5916-54xk include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF x86_64_accton_as5916_54x onlplib +DEPENDMODULES := AIM IOF x86_64_accton_as5916_54xk onlplib DEPENDMODULE_HEADERS := sff include $(BUILDER)/dependmodules.mk -SHAREDLIB := libonlp-x86-64-accton-as5916-54x.so +SHAREDLIB := libonlp-x86-64-accton-as5916-54xk.so $(SHAREDLIB)_TARGETS := $(ALL_TARGETS) include $(BUILDER)/so.mk .DEFAULT_GOAL := $(SHAREDLIB) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile index 0c41fbc0..d746bb0f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/onlpdump/Makefile @@ -29,7 +29,7 @@ include $(ONL)/make/config.amd64.mk MODULE := onlpdump include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF onlp x86_64_accton_as5916_54x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS +DEPENDMODULES := AIM IOF onlp x86_64_accton_as5916_54xk onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS include $(BUILDER)/dependmodules.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module index b7e5840e..c5e14119 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/.module @@ -1 +1 @@ -name: x86_64_accton_as5916_54x +name: x86_64_accton_as5916_54xk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile index 10f71d72..24ddaca8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/Makefile @@ -4,6 +4,6 @@ # ############################################################################### include ../../init.mk -MODULE := x86_64_accton_as5916_54x -AUTOMODULE := x86_64_accton_as5916_54x +MODULE := x86_64_accton_as5916_54xk +AUTOMODULE := x86_64_accton_as5916_54xk include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README index 64864843..10ac657c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/README @@ -1,6 +1,6 @@ ############################################################################### # -# x86_64_accton_as5916_54x README +# x86_64_accton_as5916_54xk README # ############################################################################### diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk index 9db4a259..15148435 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/make.mk @@ -1,9 +1,9 @@ ############################################################################### # -# x86_64_accton_as5916_54x Autogeneration +# x86_64_accton_as5916_54xk Autogeneration # ############################################################################### -x86_64_accton_as5916_54x_AUTO_DEFS := module/auto/x86_64_accton_as5916_54x.yml -x86_64_accton_as5916_54x_AUTO_DIRS := module/inc/x86_64_accton_as5916_54x module/src +x86_64_accton_as5916_54xk_AUTO_DEFS := module/auto/x86_64_accton_as5916_54xk.yml +x86_64_accton_as5916_54xk_AUTO_DIRS := module/inc/x86_64_accton_as5916_54xk module/src include $(BUILDER)/auto.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml index 987f682f..9efc6401 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/auto/x86_64_accton_as5916_54xk.yml @@ -1,44 +1,44 @@ ############################################################################### # -# x86_64_accton_as5916_54x Autogeneration Definitions. +# x86_64_accton_as5916_54xk Autogeneration Definitions. # ############################################################################### cdefs: &cdefs -- X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING: +- X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING: doc: "Include or exclude logging." default: 1 -- X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT: +- X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT: doc: "Default enabled log options." default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT: +- X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT: doc: "Default enabled log bits." default: AIM_LOG_BITS_DEFAULT -- X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: +- X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT: doc: "Default enabled custom log bits." default: 0 -- X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB: +- X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB: doc: "Default all porting macros to use the C standard libraries." default: 1 -- X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: +- X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: doc: "Include standard library headers for stdlib porting macros." - default: X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB -- X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI: + default: X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI: doc: "Include generic uCli support." default: 0 -- X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: +- X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: doc: "Assume chassis fan direction is the same as the PSU fan direction." default: 0 definitions: cdefs: - X86_64_ACCTON_AS5916_54X_CONFIG_HEADER: + X86_64_ACCTON_AS5916_54XK_CONFIG_HEADER: defs: *cdefs - basename: x86_64_accton_as5916_54x_config + basename: x86_64_accton_as5916_54xk_config portingmacro: - x86_64_accton_as5916_54x: + x86_64_accton_as5916_54xk: macros: - malloc - free diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x index 7776b59e..33e59762 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk.x @@ -3,7 +3,7 @@ * * *****************************************************************************/ -#include +#include /* <--auto.start.xmacro(ALL).define> */ /* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h index 43572880..427e6b26 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_config.h @@ -1,102 +1,102 @@ /**************************************************************************//** * * @file - * @brief x86_64_accton_as5916_54x Configuration Header + * @brief x86_64_accton_as5916_54xk Configuration Header * - * @addtogroup x86_64_accton_as5916_54x-config + * @addtogroup x86_64_accton_as5916_54xk-config * @{ * *****************************************************************************/ -#ifndef __X86_64_ACCTON_AS5916_54X_CONFIG_H__ -#define __X86_64_ACCTON_AS5916_54X_CONFIG_H__ +#ifndef __X86_64_ACCTON_AS5916_54XK_CONFIG_H__ +#define __X86_64_ACCTON_AS5916_54XK_CONFIG_H__ #ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG #include #endif -#ifdef X86_64_ACCTON_AS5916_54X_INCLUDE_CUSTOM_CONFIG -#include +#ifdef X86_64_ACCTON_AS5916_54XK_INCLUDE_CUSTOM_CONFIG +#include #endif -/* */ +/* */ #include /** - * X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING + * X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING * * Include or exclude logging. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING -#define X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING 1 +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING 1 #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT + * X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT * * Default enabled log options. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT + * X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT * * Default enabled log bits. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT -#define X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT * * Default enabled custom log bits. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB + * X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB * * Default all porting macros to use the C standard libraries. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB -#define X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB 1 +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB 1 #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS * * Include standard library headers for stdlib porting macros. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI + * X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI * * Include generic uCli support. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI -#define X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI 0 +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI 0 #endif /** - * X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION * * Assume chassis fan direction is the same as the PSU fan direction. */ -#ifndef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#ifndef X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 #endif @@ -106,32 +106,32 @@ */ /** Configuration settings structure. */ -typedef struct x86_64_accton_as5916_54x_config_settings_s { +typedef struct x86_64_accton_as5916_54xk_config_settings_s { /** name */ const char* name; /** value */ const char* value; -} x86_64_accton_as5916_54x_config_settings_t; +} x86_64_accton_as5916_54xk_config_settings_t; /** Configuration settings table. */ -/** x86_64_accton_as5916_54x_config_settings table. */ -extern x86_64_accton_as5916_54x_config_settings_t x86_64_accton_as5916_54x_config_settings[]; +/** x86_64_accton_as5916_54xk_config_settings table. */ +extern x86_64_accton_as5916_54xk_config_settings_t x86_64_accton_as5916_54xk_config_settings[]; /** * @brief Lookup a configuration setting. * @param setting The name of the configuration option to lookup. */ -const char* x86_64_accton_as5916_54x_config_lookup(const char* setting); +const char* x86_64_accton_as5916_54xk_config_lookup(const char* setting); /** * @brief Show the compile-time configuration. * @param pvs The output stream. */ -int x86_64_accton_as5916_54x_config_show(struct aim_pvs_s* pvs); +int x86_64_accton_as5916_54xk_config_show(struct aim_pvs_s* pvs); -/* */ +/* */ -#include "x86_64_accton_as5916_54x_porting.h" +#include "x86_64_accton_as5916_54xk_porting.h" -#endif /* __X86_64_ACCTON_AS5916_54X_CONFIG_H__ */ +#endif /* __X86_64_ACCTON_AS5916_54XK_CONFIG_H__ */ /* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h index 67e69645..af4fa451 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_dox.h @@ -1,13 +1,13 @@ /**************************************************************************//** * - * x86_64_accton_as5916_54x Doxygen Header + * x86_64_accton_as5916_54xk Doxygen Header * *****************************************************************************/ -#ifndef __X86_64_ACCTON_AS5916_54X_DOX_H__ -#define __X86_64_ACCTON_AS5916_54X_DOX_H__ +#ifndef __X86_64_ACCTON_AS5916_54XK_DOX_H__ +#define __X86_64_ACCTON_AS5916_54XK_DOX_H__ /** - * @defgroup x86_64_accton_as5916_54x x86_64_accton_as5916_54x - x86_64_accton_as5916_54x Description + * @defgroup x86_64_accton_as5916_54xk x86_64_accton_as5916_54xk - x86_64_accton_as5916_54xk Description * The documentation overview for this module should go here. @@ -15,12 +15,12 @@ The documentation overview for this module should go here. * * @{ * - * @defgroup x86_64_accton_as5916_54x-x86_64_accton_as5916_54x Public Interface - * @defgroup x86_64_accton_as5916_54x-config Compile Time Configuration - * @defgroup x86_64_accton_as5916_54x-porting Porting Macros + * @defgroup x86_64_accton_as5916_54xk-x86_64_accton_as5916_54xk Public Interface + * @defgroup x86_64_accton_as5916_54xk-config Compile Time Configuration + * @defgroup x86_64_accton_as5916_54xk-porting Porting Macros * * @} * */ -#endif /* __X86_64_ACCTON_AS5916_54X_DOX_H__ */ +#endif /* __X86_64_ACCTON_AS5916_54XK_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h index e7dcddc8..bcfbee39 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/inc/x86_64_accton_as5916_54xk/x86_64_accton_as5916_54xk_porting.h @@ -1,18 +1,18 @@ /**************************************************************************//** * * @file - * @brief x86_64_accton_as5916_54x Porting Macros. + * @brief x86_64_accton_as5916_54xk Porting Macros. * - * @addtogroup x86_64_accton_as5916_54x-porting + * @addtogroup x86_64_accton_as5916_54xk-porting * @{ * *****************************************************************************/ -#ifndef __X86_64_ACCTON_AS5916_54X_PORTING_H__ -#define __X86_64_ACCTON_AS5916_54X_PORTING_H__ +#ifndef __X86_64_ACCTON_AS5916_54XK_PORTING_H__ +#define __X86_64_ACCTON_AS5916_54XK_PORTING_H__ /* */ -#if X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#if X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 #include #include #include @@ -20,88 +20,88 @@ #include #endif -#ifndef x86_64_accton_as5916_54x_MALLOC +#ifndef x86_64_accton_as5916_54xk_MALLOC #if defined(GLOBAL_MALLOC) - #define x86_64_accton_as5916_54x_MALLOC GLOBAL_MALLOC - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_MALLOC malloc + #define x86_64_accton_as5916_54xk_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_MALLOC malloc #else - #error The macro x86_64_accton_as5916_54x_MALLOC is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_MALLOC is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_FREE +#ifndef x86_64_accton_as5916_54xk_FREE #if defined(GLOBAL_FREE) - #define x86_64_accton_as5916_54x_FREE GLOBAL_FREE - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_FREE free + #define x86_64_accton_as5916_54xk_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_FREE free #else - #error The macro x86_64_accton_as5916_54x_FREE is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_FREE is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_MEMSET +#ifndef x86_64_accton_as5916_54xk_MEMSET #if defined(GLOBAL_MEMSET) - #define x86_64_accton_as5916_54x_MEMSET GLOBAL_MEMSET - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_MEMSET memset + #define x86_64_accton_as5916_54xk_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_MEMSET memset #else - #error The macro x86_64_accton_as5916_54x_MEMSET is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_MEMSET is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_MEMCPY +#ifndef x86_64_accton_as5916_54xk_MEMCPY #if defined(GLOBAL_MEMCPY) - #define x86_64_accton_as5916_54x_MEMCPY GLOBAL_MEMCPY - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_MEMCPY memcpy + #define x86_64_accton_as5916_54xk_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_MEMCPY memcpy #else - #error The macro x86_64_accton_as5916_54x_MEMCPY is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_MEMCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_STRNCPY +#ifndef x86_64_accton_as5916_54xk_STRNCPY #if defined(GLOBAL_STRNCPY) - #define x86_64_accton_as5916_54x_STRNCPY GLOBAL_STRNCPY - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_STRNCPY strncpy + #define x86_64_accton_as5916_54xk_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_STRNCPY strncpy #else - #error The macro x86_64_accton_as5916_54x_STRNCPY is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_STRNCPY is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_VSNPRINTF +#ifndef x86_64_accton_as5916_54xk_VSNPRINTF #if defined(GLOBAL_VSNPRINTF) - #define x86_64_accton_as5916_54x_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_VSNPRINTF vsnprintf + #define x86_64_accton_as5916_54xk_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_VSNPRINTF vsnprintf #else - #error The macro x86_64_accton_as5916_54x_VSNPRINTF is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_VSNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_SNPRINTF +#ifndef x86_64_accton_as5916_54xk_SNPRINTF #if defined(GLOBAL_SNPRINTF) - #define x86_64_accton_as5916_54x_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_SNPRINTF snprintf + #define x86_64_accton_as5916_54xk_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_SNPRINTF snprintf #else - #error The macro x86_64_accton_as5916_54x_SNPRINTF is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_SNPRINTF is required but cannot be defined. #endif #endif -#ifndef x86_64_accton_as5916_54x_STRLEN +#ifndef x86_64_accton_as5916_54xk_STRLEN #if defined(GLOBAL_STRLEN) - #define x86_64_accton_as5916_54x_STRLEN GLOBAL_STRLEN - #elif X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB == 1 - #define x86_64_accton_as5916_54x_STRLEN strlen + #define x86_64_accton_as5916_54xk_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as5916_54xk_STRLEN strlen #else - #error The macro x86_64_accton_as5916_54x_STRLEN is required but cannot be defined. + #error The macro x86_64_accton_as5916_54xk_STRLEN is required but cannot be defined. #endif #endif /* */ -#endif /* __X86_64_ACCTON_AS5916_54X_PORTING_H__ */ +#endif /* __X86_64_ACCTON_AS5916_54XK_PORTING_H__ */ /* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk index 568066a4..da8a50de 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/make.mk @@ -4,7 +4,7 @@ # ############################################################################### THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_accton_as5916_54x_INCLUDES := -I $(THIS_DIR)inc -x86_64_accton_as5916_54x_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_accton_as5916_54x_DEPENDMODULE_ENTRIES := init:x86_64_accton_as5916_54x ucli:x86_64_accton_as5916_54x +x86_64_accton_as5916_54xk_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as5916_54xk_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as5916_54xk_DEPENDMODULE_ENTRIES := init:x86_64_accton_as5916_54xk ucli:x86_64_accton_as5916_54xk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile index 04d2f92b..86833365 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/Makefile @@ -5,5 +5,5 @@ ############################################################################### ucli: - @../../../../tools/uclihandlers.py x86_64_accton_as5916_54x_ucli.c + @../../../../tools/uclihandlers.py x86_64_accton_as5916_54xk_ucli.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c index 4cb41893..26e36736 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/ledi.c @@ -27,7 +27,7 @@ #include #include "platform_lib.h" -#define LED_FORMAT "/sys/class/leds/accton_as5916_54x_led::%s/brightness" +#define LED_FORMAT "/sys/class/leds/accton_as5916_54xk_led::%s/brightness" #define VALIDATE(_id) \ do { \ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk index b3aafcb3..79448f2c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/make.mk @@ -4,6 +4,6 @@ # ############################################################################### -LIBRARY := x86_64_accton_as5916_54x +LIBRARY := x86_64_accton_as5916_54xk $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h old mode 100644 new mode 100755 index f00d5d41..bd8a6ea5 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/platform_lib.h @@ -26,7 +26,7 @@ #ifndef __PLATFORM_LIB_H__ #define __PLATFORM_LIB_H__ -#include "x86_64_accton_as5916_54x_log.h" +#include "x86_64_accton_as5916_54xk_log.h" #define CHASSIS_FAN_COUNT 6 #define CHASSIS_THERMAL_COUNT 5 @@ -51,7 +51,7 @@ #define FAN_BOARD_PATH "/sys/bus/i2c/devices/9-0066/" #define FAN_NODE(node) FAN_BOARD_PATH#node -#define IDPROM_PATH "/sys/bus/i2c/devices/0-0054/eeprom" +#define IDPROM_PATH "/sys/bus/i2c/devices/0-0056/eeprom" enum onlp_thermal_id { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c index d1606f47..f4d29904 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sfpi.c @@ -27,7 +27,7 @@ #include #include "platform_lib.h" -#include "x86_64_accton_as5916_54x_log.h" +#include "x86_64_accton_as5916_54xk_log.h" #define NUM_OF_SFP_PORT 54 #define MAX_PORT_PATH 64 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c index 44bf47a1..0b55c57a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/sysi.c @@ -34,8 +34,8 @@ #include #include "platform_lib.h" -#include "x86_64_accton_as5916_54x_int.h" -#include "x86_64_accton_as5916_54x_log.h" +#include "x86_64_accton_as5916_54xk_int.h" +#include "x86_64_accton_as5916_54xk_log.h" #define CPLD_VERSION_FORMAT "/sys/bus/i2c/devices/%s/version" #define NUM_OF_CPLD 2 @@ -49,7 +49,7 @@ static char* cpld_path[NUM_OF_CPLD] = const char* onlp_sysi_platform_get(void) { - return "x86-64-accton-as5916-54x-r1"; + return "x86-64-accton-as5916-54xk-r1"; } int diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c index 3579a89f..6596013d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_config.c @@ -3,78 +3,78 @@ * * *****************************************************************************/ -#include +#include -/* */ -#define __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(_x) -x86_64_accton_as5916_54x_config_settings_t x86_64_accton_as5916_54x_config_settings[] = +/* */ +#define __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(_x) +x86_64_accton_as5916_54xk_config_settings_t x86_64_accton_as5916_54xk_config_settings[] = { -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif -#ifdef X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as5916_54x_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#ifdef X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, #else -{ X86_64_ACCTON_AS5916_54X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_54x_config_STRINGIFY_NAME), "__undefined__" }, +{ X86_64_ACCTON_AS5916_54XK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_54xk_config_STRINGIFY_NAME), "__undefined__" }, #endif { NULL, NULL } }; -#undef __x86_64_accton_as5916_54x_config_STRINGIFY_VALUE -#undef __x86_64_accton_as5916_54x_config_STRINGIFY_NAME +#undef __x86_64_accton_as5916_54xk_config_STRINGIFY_VALUE +#undef __x86_64_accton_as5916_54xk_config_STRINGIFY_NAME const char* -x86_64_accton_as5916_54x_config_lookup(const char* setting) +x86_64_accton_as5916_54xk_config_lookup(const char* setting) { int i; - for(i = 0; x86_64_accton_as5916_54x_config_settings[i].name; i++) { - if(strcmp(x86_64_accton_as5916_54x_config_settings[i].name, setting)) { - return x86_64_accton_as5916_54x_config_settings[i].value; + for(i = 0; x86_64_accton_as5916_54xk_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_as5916_54xk_config_settings[i].name, setting)) { + return x86_64_accton_as5916_54xk_config_settings[i].value; } } return NULL; } int -x86_64_accton_as5916_54x_config_show(struct aim_pvs_s* pvs) +x86_64_accton_as5916_54xk_config_show(struct aim_pvs_s* pvs) { int i; - for(i = 0; x86_64_accton_as5916_54x_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_accton_as5916_54x_config_settings[i].name, x86_64_accton_as5916_54x_config_settings[i].value); + for(i = 0; x86_64_accton_as5916_54xk_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as5916_54xk_config_settings[i].name, x86_64_accton_as5916_54xk_config_settings[i].value); } return i; } -/* */ \ No newline at end of file +/* */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c index b2b98d07..7c1101b0 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_enums.c @@ -3,7 +3,7 @@ * * *****************************************************************************/ -#include +#include /* <--auto.start.enum(ALL).source> */ /* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h index 4543ef58..811a0b8b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_int.h @@ -1,12 +1,12 @@ /**************************************************************************//** * - * x86_64_accton_as5916_54x Internal Header + * x86_64_accton_as5916_54xk Internal Header * *****************************************************************************/ -#ifndef __x86_64_accton_as5916_54x_INT_H__ -#define __x86_64_accton_as5916_54x_INT_H__ +#ifndef __x86_64_accton_as5916_54xk_INT_H__ +#define __x86_64_accton_as5916_54xk_INT_H__ -#include +#include -#endif /* __x86_64_accton_as5916_54x_INT_H__ */ \ No newline at end of file +#endif /* __x86_64_accton_as5916_54xk_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c index 1537e358..465717fc 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.c @@ -3,16 +3,16 @@ * * *****************************************************************************/ -#include +#include -#include "x86_64_accton_as5916_54x_log.h" +#include "x86_64_accton_as5916_54xk_log.h" /* - * x86_64_accton_as5916_54x log struct. + * x86_64_accton_as5916_54xk log struct. */ AIM_LOG_STRUCT_DEFINE( - X86_64_ACCTON_AS5916_54X_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_ACCTON_AS5916_54X_CONFIG_LOG_BITS_DEFAULT, + X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_BITS_DEFAULT, NULL, /* Custom log map */ - X86_64_ACCTON_AS5916_54X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + X86_64_ACCTON_AS5916_54XK_CONFIG_LOG_CUSTOM_BITS_DEFAULT ); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h index 5e6ad4d0..8ccc0eb4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_log.h @@ -3,10 +3,10 @@ * * *****************************************************************************/ -#ifndef __x86_64_accton_as5916_54x_LOG_H__ -#define __x86_64_accton_as5916_54x_LOG_H__ +#ifndef __x86_64_accton_as5916_54xk_LOG_H__ +#define __x86_64_accton_as5916_54xk_LOG_H__ -#define AIM_LOG_MODULE_NAME x86_64_accton_as5916_54x +#define AIM_LOG_MODULE_NAME x86_64_accton_as5916_54xk #include -#endif /* __x86_64_accton_as5916_54x_LOG_H__ */ \ No newline at end of file +#endif /* __x86_64_accton_as5916_54xk_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c index efd313db..f29eef98 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_module.c @@ -3,19 +3,19 @@ * * *****************************************************************************/ -#include +#include -#include "x86_64_accton_as5916_54x_log.h" +#include "x86_64_accton_as5916_54xk_log.h" static int datatypes_init__(void) { -#define x86_64_accton_as5916_54x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include +#define x86_64_accton_as5916_54xk_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include return 0; } -void __x86_64_accton_as5916_54x_module_init__(void) +void __x86_64_accton_as5916_54xk_module_init__(void) { AIM_LOG_STRUCT_REGISTER(); datatypes_init__(); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c index fe6e423f..22ed3740 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/onlp/builds/src/module/src/x86_64_accton_as5916_54xk_ucli.c @@ -3,46 +3,46 @@ * * *****************************************************************************/ -#include +#include -#if x86_64_accton_as5916_54x_CONFIG_INCLUDE_UCLI == 1 +#if x86_64_accton_as5916_54xk_CONFIG_INCLUDE_UCLI == 1 #include #include #include static ucli_status_t -x86_64_accton_as5916_54x_ucli_ucli__config__(ucli_context_t* uc) +x86_64_accton_as5916_54xk_ucli_ucli__config__(ucli_context_t* uc) { - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as5916_54x) + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as5916_54xk) } /* */ /* */ static ucli_module_t -x86_64_accton_as5916_54x_ucli_module__ = +x86_64_accton_as5916_54xk_ucli_module__ = { - "x86_64_accton_as5916_54x_ucli", + "x86_64_accton_as5916_54xk_ucli", NULL, - x86_64_accton_as5916_54x_ucli_ucli_handlers__, + x86_64_accton_as5916_54xk_ucli_ucli_handlers__, NULL, NULL, }; ucli_node_t* -x86_64_accton_as5916_54x_ucli_node_create(void) +x86_64_accton_as5916_54xk_ucli_node_create(void) { ucli_node_t* n; - ucli_module_init(&x86_64_accton_as5916_54x_ucli_module__); - n = ucli_node_create("x86_64_accton_as5916_54x", NULL, &x86_64_accton_as5916_54x_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as5916_54x")); + ucli_module_init(&x86_64_accton_as5916_54xk_ucli_module__); + n = ucli_node_create("x86_64_accton_as5916_54xk", NULL, &x86_64_accton_as5916_54xk_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as5916_54xk")); return n; } #else void* -x86_64_accton_as5916_54x_ucli_node_create(void) +x86_64_accton_as5916_54xk_ucli_node_create(void) { return NULL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml index caedb664..e153db0f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/PKG.yml @@ -1 +1 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as5916-54x REVISION=r1 +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as5916-54xk REVISION=r1 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml index 42278b23..40659850 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/lib/x86-64-accton-as5916-54xk-r1.yml @@ -6,7 +6,7 @@ # ###################################################################### -x86-64-accton-as5916-54x-r1: +x86-64-accton-as5916-54xk-r1: grub: diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py old mode 100644 new mode 100755 index 171b3c20..da17b4ea --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xk/platform-config/r1/src/python/x86_64_accton_as5916_54xk_r1/__init__.py @@ -1,17 +1,17 @@ from onl.platform.base import * from onl.platform.accton import * -class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, +class OnlPlatform_x86_64_accton_as5916_54xk_r1(OnlPlatformAccton, OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-accton-as5916-54x-r1' - MODEL="AS5916-54X" + PLATFORM='x86-64-accton-as5916-54xk-r1' + MODEL="AS5916-54XK" SYS_OBJECT_ID=".5916.54" def baseconfig(self): self.insmod("accton_i2c_cpld") self.insmod("ym2651y") for m in [ "sfp", "psu", "fan", "leds" ]: - self.insmod("x86-64-accton-as5916-54x-%s" % m) + self.insmod("x86-64-accton-as5916-54xk-%s" % m) ########### initialize I2C bus 0 ########### self.new_i2c_devices( @@ -21,7 +21,7 @@ class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, ('pca9548', 0x76, 1), # initiate chassis fan - ('as5916_54x_fan', 0x66, 9), + ('as5916_54xk_fan', 0x66, 9), # inititate LM75 ('lm75', 0x48, 10), @@ -37,11 +37,11 @@ class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, ('pca9548', 0x74, 2), # initiate PSU-1 AC Power - ('as5916_54x_psu1', 0x53, 18), + ('as5916_54xk_psu1', 0x53, 18), ('ym2651', 0x5b, 18), # initiate PSU-2 AC Power - ('as5916_54x_psu2', 0x50, 17), + ('as5916_54xk_psu2', 0x50, 17), ('ym2651', 0x58, 17), # initialize multiplexer (PCA9548) @@ -55,18 +55,18 @@ class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, ('pca9548', 0x75, 31), # initiate IDPROM - ('24c02', 0x54, 0), + ('24c02', 0x56, 0), ] ) # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5916_54x_sfp%d' % port, 0x50, port+32) - self.new_i2c_device('as5916_54x_sfp%d' % port, 0x51, port+32) + self.new_i2c_device('as5916_54xk_sfp%d' % port, 0x50, port+32) + self.new_i2c_device('as5916_54xk_sfp%d' % port, 0x51, port+32) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5916_54x_sfp%d' % port, 0x50, port+32) + self.new_i2c_device('as5916_54xk_sfp%d' % port, 0x50, port+32) return True From b7212258a42b02ef74b4a837610574acac26c5c8 Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Fri, 9 Mar 2018 16:43:47 +0800 Subject: [PATCH 175/244] Added support for as7312_54xs with 54 network ports --- .../x86-64-accton-as7312-54xs/.gitignore | 3 + .../x86-64/x86-64-accton-as7312-54xs/Makefile | 1 + .../modules/Makefile | 1 + .../x86-64-accton-as7312-54xs/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as7312-54xs-cpld.c | 1133 +++++++++++++++++ .../builds/x86-64-accton-as7312-54xs-fan.c | 473 +++++++ .../builds/x86-64-accton-as7312-54xs-leds.c | 438 +++++++ .../builds/x86-64-accton-as7312-54xs-psu.c | 277 ++++ .../x86-64-accton-as7312-54xs/onlp/Makefile | 1 + .../x86-64-accton-as7312-54xs/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../module/auto/x86_64_accton_as7312_54xs.yml | 50 + .../x86_64_accton_as7312_54xs.x | 14 + .../x86_64_accton_as7312_54xs_config.h | 137 ++ .../x86_64_accton_as7312_54xs_dox.h | 26 + .../x86_64_accton_as7312_54xs_porting.h | 107 ++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 367 ++++++ .../onlp/builds/src/module/src/ledi.c | 261 ++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 175 +++ .../onlp/builds/src/module/src/platform_lib.h | 85 ++ .../onlp/builds/src/module/src/psui.c | 186 +++ .../onlp/builds/src/module/src/sfpi.c | 383 ++++++ .../onlp/builds/src/module/src/sysi.c | 490 +++++++ .../onlp/builds/src/module/src/thermali.c | 169 +++ .../src/x86_64_accton_as7312_54xs_config.c | 81 ++ .../src/x86_64_accton_as7312_54xs_enums.c | 10 + .../src/x86_64_accton_as7312_54xs_int.h | 12 + .../src/x86_64_accton_as7312_54xs_log.c | 20 + .../src/x86_64_accton_as7312_54xs_log.h | 12 + .../src/x86_64_accton_as7312_54xs_module.c | 24 + .../src/x86_64_accton_as7312_54xs_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-as7312-54xs-r0.yml | 31 + .../x86_64_accton_as7312_54xs_r0/__init__.py | 81 ++ 47 files changed, 5256 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-cpld.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-fan.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-leds.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-psu.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/x86_64_accton_as7312_54xs.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/lib/x86-64-accton-as7312-54xs-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/python/x86_64_accton_as7312_54xs_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/.gitignore new file mode 100644 index 00000000..f8bc5a4d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*as7312*54x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/PKG.yml new file mode 100644 index 00000000..b2d923c5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as7312-54xs ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/Makefile new file mode 100644 index 00000000..3c970440 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as7312-54xs +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-cpld.c new file mode 100644 index 00000000..8b79eb1b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-cpld.c @@ -0,0 +1,1133 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as7312_54xs CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as7312_54xs_cpld1, + as7312_54xs_cpld2, + as7312_54xs_cpld3 +}; + +struct as7312_54xs_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as7312_54xs_cpld_id[] = { + { "as7312_54xs_cpld1", as7312_54xs_cpld1 }, + { "as7312_54xs_cpld2", as7312_54xs_cpld2 }, + { "as7312_54xs_cpld3", as7312_54xs_cpld3 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as7312_54xs_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as7312_54xs_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7312_54xs_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7312_54xs_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as7312_54xs_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7312_54xs_cpld1_group = { + .attrs = as7312_54xs_cpld1_attributes, +}; + +static struct attribute *as7312_54xs_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as7312_54xs_cpld2_group = { + .attrs = as7312_54xs_cpld2_attributes, +}; + +static struct attribute *as7312_54xs_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as7312_54xs_cpld3_group = { + .attrs = as7312_54xs_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x9, 0xA, 0xB, 0x18}; + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54xs_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7312_54xs_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 54 in order */ + if (data->type == as7312_54xs_cpld2) { + values[3] &= 0xF; + } + else { /* as7312_54xs_cpld3 */ + values[3] &= 0x3; + } + + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x12, 0x13, 0x14}; + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54xs_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7312_54xs_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as7312_54xs_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49: + reg = 0x18; + mask = 0x1; + break; + case MODULE_PRESENT_50: + reg = 0x18; + mask = 0x2; + break; + case MODULE_PRESENT_51: + reg = 0x18; + mask = 0x4; + break; + case MODULE_PRESENT_52: + reg = 0x18; + mask = 0x8; + break; + case MODULE_PRESENT_53: + reg = 0x18; + mask = 0x1; + break; + case MODULE_PRESENT_54: + reg = 0x18; + mask = 0x2; + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x13; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x13; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as7312_54xs_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54xs_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as7312_54xs_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as7312_54xs_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54xs_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7312_54xs_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as7312_54xs_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7312_54xs_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as7312_54xs_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as7312_54xs_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as7312_54xs_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as7312_54xs_cpld1: + group = &as7312_54xs_cpld1_group; + break; + case as7312_54xs_cpld2: + group = &as7312_54xs_cpld2_group; + break; + case as7312_54xs_cpld3: + group = &as7312_54xs_cpld3_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as7312_54xs_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as7312_54xs_cpld_remove(struct i2c_client *client) +{ + struct as7312_54xs_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as7312_54xs_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as7312_54xs_cpld1: + group = &as7312_54xs_cpld1_group; + break; + case as7312_54xs_cpld2: + group = &as7312_54xs_cpld2_group; + break; + case as7312_54xs_cpld3: + group = &as7312_54xs_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as7312_54xs_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7312_54xs_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as7312_54xs_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7312_54xs_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7312_54xs_cpld_read); + +int as7312_54xs_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7312_54xs_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7312_54xs_cpld_write); + +static struct i2c_driver as7312_54xs_cpld_driver = { + .driver = { + .name = "as7312_54xs_cpld", + .owner = THIS_MODULE, + }, + .probe = as7312_54xs_cpld_probe, + .remove = as7312_54xs_cpld_remove, + .id_table = as7312_54xs_cpld_id, +}; + +static int __init as7312_54xs_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7312_54xs_cpld_driver); +} + +static void __exit as7312_54xs_cpld_exit(void) +{ + i2c_del_driver(&as7312_54xs_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as7312_54xs_cpld_init); +module_exit(as7312_54xs_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-fan.c new file mode 100644 index 00000000..5db32577 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-fan.c @@ -0,0 +1,473 @@ +/* + * A hwmon driver for the Accton as7312 54x fan + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as7312_54xs_fan" + +static struct as7312_54xs_fan_data *as7312_54xs_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x0F, /* fan 1-6 present status */ + 0x10, /* fan 1-6 direction(0:F2B 1:B2F) */ + 0x11, /* fan PWM(for all fan) */ + 0x12, /* front fan 1 speed(rpm) */ + 0x13, /* front fan 2 speed(rpm) */ + 0x14, /* front fan 3 speed(rpm) */ + 0x15, /* front fan 4 speed(rpm) */ + 0x16, /* front fan 5 speed(rpm) */ + 0x17, /* front fan 6 speed(rpm) */ + 0x22, /* rear fan 1 speed(rpm) */ + 0x23, /* rear fan 2 speed(rpm) */ + 0x24, /* rear fan 3 speed(rpm) */ + 0x25, /* rear fan 4 speed(rpm) */ + 0x26, /* rear fan 5 speed(rpm) */ + 0x27, /* rear fan 6 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as7312_54xs_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID, + FAN5_ID, + FAN6_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DIRECTION_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN5_FRONT_SPEED_RPM, + FAN6_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN5_REAR_SPEED_RPM, + FAN6_REAR_SPEED_RPM, + FAN1_DIRECTION, + FAN2_DIRECTION, + FAN3_DIRECTION, + FAN4_DIRECTION, + FAN5_DIRECTION, + FAN6_DIRECTION, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN6_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT, + FAN5_FAULT, + FAN6_FAULT +}; + +/* Define attributes + */ +#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 + +#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); +/* 6 fan direction attribute in this platform */ +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); + +static struct attribute *as7312_54xs_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_FAULT_ATTR(4), + DECLARE_FAN_FAULT_ATTR(5), + DECLARE_FAN_FAULT_ATTR(6), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(4), + DECLARE_FAN_SPEED_RPM_ATTR(5), + DECLARE_FAN_SPEED_RPM_ATTR(6), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(5), + DECLARE_FAN_PRESENT_ATTR(6), + DECLARE_FAN_DIRECTION_ATTR(1), + DECLARE_FAN_DIRECTION_ATTR(2), + DECLARE_FAN_DIRECTION_ATTR(3), + DECLARE_FAN_DIRECTION_ATTR(4), + DECLARE_FAN_DIRECTION_ATTR(5), + DECLARE_FAN_DIRECTION_ATTR(6), + DECLARE_FAN_DUTY_CYCLE_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as7312_54xs_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as7312_54xs_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val+1) * 625 + 75)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + return ((u32)duty_cycle * 100 / 625) - 1; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 1 : 0; +} +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 0 : 1; +} + +static u8 is_fan_fault(struct as7312_54xs_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as7312_54xs_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as7312_54xs_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7312_54xs_fan_data *data = as7312_54xs_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN5_FRONT_SPEED_RPM: + case FAN6_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + case FAN5_REAR_SPEED_RPM: + case FAN6_REAR_SPEED_RPM: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + case FAN6_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + case FAN5_FAULT: + case FAN6_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIRECTION: + case FAN2_DIRECTION: + case FAN3_DIRECTION: + case FAN4_DIRECTION: + case FAN5_DIRECTION: + case FAN6_DIRECTION: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], + attr->index - FAN1_DIRECTION)); + break; + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as7312_54xs_fan_group = { + .attrs = as7312_54xs_fan_attributes, +}; + +static struct as7312_54xs_fan_data *as7312_54xs_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54xs_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as7312_54xs_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as7312_54xs_fan_read_value(client, fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as7312_54xs_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7312_54xs_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7312_54xs_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7312_54xs_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7312_54xs_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7312_54xs_fan_remove(struct i2c_client *client) +{ + struct as7312_54xs_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7312_54xs_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; + +static const struct i2c_device_id as7312_54xs_fan_id[] = { + { "as7312_54xs_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7312_54xs_fan_id); + +static struct i2c_driver as7312_54xs_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as7312_54xs_fan_probe, + .remove = as7312_54xs_fan_remove, + .id_table = as7312_54xs_fan_id, + .address_list = normal_i2c, +}; + +module_i2c_driver(as7312_54xs_fan_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7312_54xs_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-leds.c new file mode 100644 index 00000000..31f39f9f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-leds.c @@ -0,0 +1,438 @@ +/* + * A LED driver for the accton_as7312_54xs_led + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*#define DEBUG*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int as7312_54xs_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7312_54xs_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +extern void led_classdev_unregister(struct led_classdev *led_cdev); +extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); +extern void led_classdev_resume(struct led_classdev *led_cdev); +extern void led_classdev_suspend(struct led_classdev *led_cdev); + +#define DRVNAME "accton_as7312_54xs_led" + +struct accton_as7312_54xs_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[1]; /* only 1 register*/ +}; + +static struct accton_as7312_54xs_led_data *ledctl = NULL; + +/* LED related data + */ + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x3) +#define LED_MODE_DIAG_GREEN_VALUE (0x02) +#define LED_MODE_DIAG_RED_VALUE (0x01) +#define LED_MODE_DIAG_AMBER_VALUE (0x00) /*It's yellow actually. Green+Red=Yellow*/ +#define LED_MODE_DIAG_OFF_VALUE (0x03) + + +#define LED_TYPE_LOC_REG_MASK (0x80) +#define LED_MODE_LOC_ON_VALUE (0) +#define LED_MODE_LOC_OFF_VALUE (0x80) + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +struct led_reg { + u32 types; + u8 reg_addr; +}; + +static const struct led_reg led_reg_map[] = { + {(1<update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as7312_54xs_led update\n"); + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as7312_54xs_led_read_value(led_reg_map[i].reg_addr); + + if (status < 0) { + ledctl->valid = 0; + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); + goto exit; + } + else + { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as7312_54xs_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + enum led_type type) +{ + int reg_val; + u8 reg ; + mutex_lock(&ledctl->update_lock); + + if( !accton_getLedReg(type, ®)) + { + dev_dbg(&ledctl->pdev->dev, "Not match item for %d.\n", type); + } + + reg_val = accton_as7312_54xs_led_read_value(reg); + + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + accton_as7312_54xs_led_write_value(reg, reg_val); + + /* to prevent the slow-update issue */ + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + + +static void accton_as7312_54xs_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7312_54xs_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); +} + +static enum led_brightness accton_as7312_54xs_led_diag_get(struct led_classdev *cdev) +{ + accton_as7312_54xs_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static void accton_as7312_54xs_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7312_54xs_led_set(led_cdev, led_light_mode, LED_TYPE_LOC); +} + +static enum led_brightness accton_as7312_54xs_led_loc_get(struct led_classdev *cdev) +{ + accton_as7312_54xs_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void accton_as7312_54xs_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness accton_as7312_54xs_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static struct led_classdev accton_as7312_54xs_leds[] = { + [LED_TYPE_DIAG] = { + .name = "accton_as7312_54xs_led::diag", + .default_trigger = "unused", + .brightness_set = accton_as7312_54xs_led_diag_set, + .brightness_get = accton_as7312_54xs_led_diag_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_RED, + }, + [LED_TYPE_LOC] = { + .name = "accton_as7312_54xs_led::loc", + .default_trigger = "unused", + .brightness_set = accton_as7312_54xs_led_loc_set, + .brightness_get = accton_as7312_54xs_led_loc_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_BLUE, + }, + [LED_TYPE_FAN] = { + .name = "accton_as7312_54xs_led::fan", + .default_trigger = "unused", + .brightness_set = accton_as7312_54xs_led_auto_set, + .brightness_get = accton_as7312_54xs_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU1] = { + .name = "accton_as7312_54xs_led::psu1", + .default_trigger = "unused", + .brightness_set = accton_as7312_54xs_led_auto_set, + .brightness_get = accton_as7312_54xs_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "accton_as7312_54xs_led::psu2", + .default_trigger = "unused", + .brightness_set = accton_as7312_54xs_led_auto_set, + .brightness_get = accton_as7312_54xs_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as7312_54xs_led_suspend(struct platform_device *dev, + pm_message_t state) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7312_54xs_leds); i++) { + led_classdev_suspend(&accton_as7312_54xs_leds[i]); + } + + return 0; +} + +static int accton_as7312_54xs_led_resume(struct platform_device *dev) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7312_54xs_leds); i++) { + led_classdev_resume(&accton_as7312_54xs_leds[i]); + } + + return 0; +} + +static int accton_as7312_54xs_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as7312_54xs_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as7312_54xs_leds[i]); + + if (ret < 0) + break; + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as7312_54xs_leds)) { + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as7312_54xs_leds[i]); + } + } + + return ret; +} + +static int accton_as7312_54xs_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as7312_54xs_leds); i++) { + led_classdev_unregister(&accton_as7312_54xs_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as7312_54xs_led_driver = { + .probe = accton_as7312_54xs_led_probe, + .remove = accton_as7312_54xs_led_remove, + .suspend = accton_as7312_54xs_led_suspend, + .resume = accton_as7312_54xs_led_resume, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as7312_54xs_led_init(void) +{ + int ret; + + ret = platform_driver_register(&accton_as7312_54xs_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as7312_54xs_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + platform_driver_unregister(&accton_as7312_54xs_led_driver); + goto exit; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + platform_driver_unregister(&accton_as7312_54xs_led_driver); + kfree(ledctl); + goto exit; + } + +exit: + return ret; +} + +static void __exit accton_as7312_54xs_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as7312_54xs_led_driver); + kfree(ledctl); +} + +module_init(accton_as7312_54xs_led_init); +module_exit(accton_as7312_54xs_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as7312_54xs_led driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-psu.c new file mode 100644 index 00000000..00ce9f7c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/modules/builds/x86-64-accton-as7312-54xs-psu.c @@ -0,0 +1,277 @@ +/* + * An hwmon driver for accton as7312_54xs Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static int as7312_54xs_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int as7312_54xs_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x50, 0x53, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as7312_54xs_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[9]; /* Model name, read from eeprom */ +}; + +static struct as7312_54xs_psu_data *as7312_54xs_psu_update_device(struct device *dev); + +enum as7312_54xs_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as7312_54xs_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7312_54xs_psu_data *data = as7312_54xs_psu_update_device(dev); + u8 status = 0; + + if (attr->index == PSU_PRESENT) { + status = !(data->status >> (1-data->index) & 0x1); + } + else { /* PSU_POWER_GOOD */ + status = (data->status >> (3-data->index) & 0x1); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as7312_54xs_psu_data *data = as7312_54xs_psu_update_device(dev); + + return sprintf(buf, "%s\n", data->model_name); +} + +static const struct attribute_group as7312_54xs_psu_group = { + .attrs = as7312_54xs_psu_attributes, +}; + +static int as7312_54xs_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7312_54xs_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7312_54xs_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7312_54xs_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7312_54xs_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7312_54xs_psu_remove(struct i2c_client *client) +{ + struct as7312_54xs_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7312_54xs_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as7312_54xs_psu1, + as7312_54xs_psu2 +}; + +static const struct i2c_device_id as7312_54xs_psu_id[] = { + { "as7312_54xs_psu1", as7312_54xs_psu1 }, + { "as7312_54xs_psu2", as7312_54xs_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7312_54xs_psu_id); + +static struct i2c_driver as7312_54xs_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7312_54xs_psu", + }, + .probe = as7312_54xs_psu_probe, + .remove = as7312_54xs_psu_remove, + .id_table = as7312_54xs_psu_id, + .address_list = normal_i2c, +}; + +static int as7312_54xs_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as7312_54xs_psu_data *as7312_54xs_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7312_54xs_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as7312_54xs update\n"); + + /* Read psu status */ + status = as7312_54xs_cpld_read(0x60, 0x2); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + power_good = (data->status >> (3-data->index) & 0x1); + + if (power_good) { + status = as7312_54xs_psu_read_block(client, 0x20, data->model_name, + ARRAY_SIZE(data->model_name)-1); + + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +module_i2c_driver(as7312_54xs_psu_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7312_54xs_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/PKG.yml new file mode 100644 index 00000000..8973609f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7312-54xs ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/lib/Makefile new file mode 100644 index 00000000..6fbac51c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as7312-54xs +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as7312_54xs onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as7312-54xs.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..712819b6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as7312_54xs onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/.module new file mode 100644 index 00000000..3d86fd72 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as7312_54xs diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/Makefile new file mode 100644 index 00000000..2b8bd61d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_as7312_54xs +AUTOMODULE := x86_64_accton_as7312_54xs +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/README new file mode 100644 index 00000000..853d0600 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as7312_54xs README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..737acbd7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_as7312_54xs Autogeneration +# +############################################################################### +x86_64_accton_as7312_54xs_AUTO_DEFS := module/auto/x86_64_accton_as7312_54xs.yml +x86_64_accton_as7312_54xs_AUTO_DIRS := module/inc/x86_64_accton_as7312_54xs module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/x86_64_accton_as7312_54xs.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/x86_64_accton_as7312_54xs.yml new file mode 100644 index 00000000..5a36f036 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/auto/x86_64_accton_as7312_54xs.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# X86_64_ACCTON_AS7312_54XS Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_AS7312_54XS_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as7312_54xs_config + + portingmacro: + X86_64_ACCTON_AS7312_54XS: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs.x b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs.x new file mode 100644 index 00000000..3a104754 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_config.h new file mode 100644 index 00000000..71ca3baf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7312_54xs Configuration Header + * + * @addtogroup x86_64_accton_as7312_54xs-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7312_54XS_CONFIG_H__ +#define __X86_64_ACCTON_AS7312_54XS_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as7312_54xs_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as7312_54xs_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as7312_54xs_config_settings table. */ +extern x86_64_accton_as7312_54xs_config_settings_t x86_64_accton_as7312_54xs_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as7312_54xs_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as7312_54xs_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as7312_54xs_porting.h" + +#endif /* __X86_64_ACCTON_AS7312_54XS_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_dox.h new file mode 100644 index 00000000..ed6c2486 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as7312_54xs Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7312_54XS_DOX_H__ +#define __X86_64_ACCTON_AS7312_54XS_DOX_H__ + +/** + * @defgroup x86_64_accton_as7312_54xs x86_64_accton_as7312_54xs - x86_64_accton_as7312_54xs Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as7312_54xs-x86_64_accton_as7312_54xs Public Interface + * @defgroup x86_64_accton_as7312_54xs-config Compile Time Configuration + * @defgroup x86_64_accton_as7312_54xs-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_AS7312_54XS_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_porting.h new file mode 100644 index 00000000..e95b63da --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/inc/x86_64_accton_as7312_54xs/x86_64_accton_as7312_54xs_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7312_54xs Porting Macros. + * + * @addtogroup x86_64_accton_as7312_54xs-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7312_54XS_PORTING_H__ +#define __X86_64_ACCTON_AS7312_54XS_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_as7312_54xs_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_as7312_54xs_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_MALLOC malloc + #else + #error The macro x86_64_accton_as7312_54xs_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_as7312_54xs_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_FREE free + #else + #error The macro x86_64_accton_as7312_54xs_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_as7312_54xs_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_MEMSET memset + #else + #error The macro x86_64_accton_as7312_54xs_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_as7312_54xs_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_MEMCPY memcpy + #else + #error The macro x86_64_accton_as7312_54xs_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_as7312_54xs_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_STRNCPY strncpy + #else + #error The macro x86_64_accton_as7312_54xs_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_as7312_54xs_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_as7312_54xs_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_as7312_54xs_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_SNPRINTF snprintf + #else + #error The macro x86_64_accton_as7312_54xs_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7312_54xs_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_as7312_54xs_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7312_54xs_STRLEN strlen + #else + #error The macro x86_64_accton_as7312_54xs_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_AS7312_54XS_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..bc09d89b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as7312_54xs_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as7312_54xs_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as7312_54xs_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7312_54xs ucli:x86_64_accton_as7312_54xs + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..74ac9fde --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as7312_54xs_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..e82f8a77 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/fani.c @@ -0,0 +1,367 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#define PSU_PREFIX_PATH "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + CHASSIS_FAN_INFO(6), + PSU_FAN_INFO(1,1), + PSU_FAN_INFO(2,1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value; + char path[64] = {0}; + + /* get fan present status + */ + sprintf(path, "%s""fan%d_present", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), present path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + sprintf(path, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), fault path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + sprintf(path, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), direction path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; + + + /* get front fan speed + */ + sprintf(path, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), front speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + sprintf(path, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), rear speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan fault status + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + DEBUG_PRINT("Fan path = (%s)", path); + + if (onlp_file_write_integer(path, p) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..a2ac4451 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,261 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/accton_as7312_54xs_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..fc7f3294 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as7312_54xs +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..9e2c0143 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,175 @@ +#include +#include +#include "platform_lib.h" +#include +#include "x86_64_accton_as7312_54xs_log.h" + + +static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { + return -1; + } + + if ((len = write(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_write_integer(char *filename, int value) +{ + char buf[8] = {0}; + sprintf(buf, "%d", value); + + return _onlp_file_write(filename, buf, (int)strlen(buf), 0); +} + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_RDONLY)) == -1) { + return -1; + } + + if ((len = read(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 9 +#define I2C_PSU_FAN_DIR_LEN 3 + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model); + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (modelname) { + strncpy(modelname, model_name, modelname_len-1); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_integer(path, value) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..98e9d7f8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,85 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include +#include "x86_64_accton_as7312_54xs_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 +#define CHASSIS_PSU_COUNT 2 +#define CHASSIS_LED_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/11-0059/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/10-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/11-0051/" +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/10-0050/" + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/2-0066/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom" + +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); + + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); + +//#define DEBUG_MODE 1 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..77074bb8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/psui.c @@ -0,0 +1,186 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +//#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + + + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..a864f6b6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,383 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "x86_64_accton_as7312_54xs_int.h" +#include "x86_64_accton_as7312_54xs_log.h" + +#define PORT_BUS_INDEX(port) (port+18) + +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/5-0062/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/6-0064/module_rx_los_all" + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 54} + */ + int p; + + for(p = 0; p < 54; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus, addr; + + addr = (port < 24 || (port >= 48 && port <= 51)) ? 62 : 64; + bus = (addr == 62) ? 5 : 6; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[8], *ptr = NULL; + FILE* fp; + int addr; + + ptr = bytes; + + for (addr = 62; addr <= 64; addr+=2) { + /* Read present status of port 0~53 */ + char file[64] = {0}; + int bus = (addr == 62) ? 5 : 6; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; + } + + /* Mask out non-existant QSFP ports */ + bytes[3] &= 0xF; + bytes[7] &= 0x3; + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t presence_all = 0 ; + presence_all |= bytes[7]; + presence_all <<= 4; + presence_all |= bytes[3]; + + for(i = 6; i >= 4; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + for(i = 2; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[6]; + uint32_t *ptr = bytes; + FILE* fp; + + /* Read present status of port 0~23 */ + int addr, i = 0; + + for (addr = 62; addr <= 64; addr+=2) { + if (addr == 62) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; + } + + /* Convert to 64 bit integer in port order */ + i = 0; + uint64_t rx_los_all = 0 ; + for(i = 5; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 62 : 64; + int bus = (addr == 62) ? 5 : 6; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 62 : 64; + int bus = (addr == 62) ? 5 : 6; + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..7a2b697c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,490 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_accton_as7312_54xs_int.h" +#include "x86_64_accton_as7312_54xs_log.h" + + +#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" +#define NUM_OF_CPLD 3 +#define FAN_DUTY_CYCLE_MAX (100) +#define FAN_DUTY_CYCLE_DEFAULT (32) +#define FAN_DUTY_PLUS_FOR_DIR (13) +/* Note, all chassis fans share 1 single duty setting. + * Here use fan 1 to represent global fan duty value.*/ +#define FAN_ID_FOR_SET_FAN_DUTY (1) +#define CELSIUS_RECORD_NUMBER (2) /*Must >= 2*/ + +typedef struct fan_ctrl_policy { + int duty_cycle; /* In percetage */ + int step_up_thermal; /* In mini-Celsius */ + int step_dn_thermal; /* In mini-Celsius */ +} fan_ctrl_policy_t; + +static char arr_cplddev_name[NUM_OF_CPLD][10] = +{ + "4-0060", + "5-0062", + "6-0064" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as7312-54xs-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 5 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +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); +} + +/* Thermal plan: + * $TMP = (CPU_core + LM75_1+ LM75_2 + LM75_3 + LM75_4)/5 + * 1. If any FAN failed, set all the other fans as full speed, 100%. + * 2. If any sensor is high than 45 degrees, set fan speed to duty 62.5%. + * 3. If any sensor is high than 50 degrees, set fan speed to duty 100%. + * 4. When $TMP >= 40 C, set fan speed to duty 62.5%. + * 5. When $TMP >= 45 C, set fan speed to duty 100%. + * 6. When $TMP < 35 C, set fan speed to duty 31.25%. + * 7. Direction factor, when B2F, duty + 12.5%. + * + * Note, all chassis fans share 1 single duty setting. + */ +fan_ctrl_policy_t fan_ctrl_policy_avg[] = { +{FAN_DUTY_CYCLE_MAX , 45000, INT_MIN}, +{63 , 40000, INT_MIN}, +{32 , INT_MAX, 35000}, +}; + +fan_ctrl_policy_t fan_ctrl_policy_single[] = { +{FAN_DUTY_CYCLE_MAX , 50000, INT_MIN}, +{63 , 45000, INT_MIN}, +}; + +struct fan_control_data_s { + int duty_cycle; + int dir_plus; + int mc_avg_pre[CELSIUS_RECORD_NUMBER]; + int mc_high_pre[CELSIUS_RECORD_NUMBER]; + +} fan_control_data_pre = +{ + .duty_cycle = FAN_DUTY_CYCLE_DEFAULT, + .dir_plus = 0, + .mc_avg_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + .mc_high_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + +}; + +static int +sysi_check_fan(uint32_t *fan_dir){ + int i, present; + + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + present = fan_info.status & ONLP_FAN_STATUS_PRESENT; + if ((fan_info.status & ONLP_FAN_STATUS_FAILED) || !present) { + AIM_LOG_WARN("Fan(%d) is not working, set the other fans as full speed\r\n", i); + int ret = onlp_fani_percentage_set( + ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY), FAN_DUTY_CYCLE_MAX); + if (ret != ONLP_STATUS_OK) + return ret; + else + return ONLP_STATUS_E_MISSING; + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + *fan_dir = fan_info.status & (ONLP_FAN_STATUS_F2B|ONLP_FAN_STATUS_B2F); + } + } + + return ONLP_STATUS_OK; +} + +static int +sysi_get_fan_duty(int *cur_duty_cycle){ + int fd, len; + char buf[10] = {0}; + char *node = FAN_NODE(fan_duty_cycle_percentage); + + /* Get current fan duty*/ + fd = open(node, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + *cur_duty_cycle = atoi(buf); + + return ONLP_STATUS_OK; +} + +static int +sysi_get_thermal_sum(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i; + + *mcelsius = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + *mcelsius += thermal_info.mcelsius; + + DEBUG_PRINT("Thermal %d: %d \n ", i, thermal_info.mcelsius); + + } + + return ONLP_STATUS_OK; + +} + +static int +sysi_get_highest_thermal(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i, highest; + + highest = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + highest = (thermal_info.mcelsius > highest)? + thermal_info.mcelsius : highest; + } + *mcelsius = highest; + return ONLP_STATUS_OK; +} + +/* Anaylze thermal changing history to judge if the change is a stable trend. */ +static int _is_thermal_a_trend(int *mc_history){ + int i, trend, trended; + + if (mc_history == NULL) { + AIM_LOG_ERROR("Unable to get history of thermal\n"); + return 0; + } + + /* Get heat up/down trend. */ + trend = 0; + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + if (( mc_history[i+1] < mc_history[i])){ + trend++; + }else if (( mc_history[i+1] > mc_history[i])){ + trend--; + } + } + + trended = (abs(trend) >= ((CELSIUS_RECORD_NUMBER+1)/2))? 1:0; +#if (DEBUG_MODE == 1) + DEBUG_PRINT("[INFO]%s#%d, trended: %d, UP/DW: %d mcelsius:", + __func__, __LINE__, trended, trend ); + for (i = 0; i <= CELSIUS_RECORD_NUMBER; i++) { + DEBUG_PRINT(" %d =>", mc_history[i]); + } + DEBUG_PRINT("%c\n", ' '); +#endif + + /*For more than half changes are same direction, it's a firm trend.*/ + return trended; +} + + +/* Decide duty by highest value of thermal sensors.*/ +static int +sysi_get_duty_by_highest(int *duty_cycle){ + int i, ret, maxtrix_len; + int new_duty_cycle = 0 ; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + ret = sysi_get_highest_thermal(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_high_pre, + sizeof(fan_control_data_pre.mc_high_pre)); + + DEBUG_PRINT("[INFO]%s#%d, highest mcelsius:%d!\n", + __func__, __LINE__, *mcelsius_now_p); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_high_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_single); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((*mcelsius_now_p > fan_ctrl_policy_single[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_single[i].duty_cycle; + matched = !matched; + break; + } + } +/* if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, *mcelsius_now_p); + } */ + } + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +/* Decide duty by average value of thermal sensors.*/ +static int +sysi_get_duty_by_average(int *duty_cycle){ + int i, mcelsius_avg, ret, maxtrix_len; + int new_duty_cycle=0; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + *mcelsius_now_p = 0; + ret = sysi_get_thermal_sum(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + mcelsius_avg = (*mcelsius_now_p)/CHASSIS_THERMAL_COUNT; + + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_avg_pre, + sizeof(fan_control_data_pre.mc_avg_pre)); + + DEBUG_PRINT("[INFO]%s#%d, mcelsius:%d!\n", __func__, __LINE__, mcelsius_avg); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_avg_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_avg); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((mcelsius_avg >= fan_ctrl_policy_avg[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + for (i = maxtrix_len-1; i>=0; i--) { + if ((mcelsius_avg < fan_ctrl_policy_avg[i].step_dn_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + /*if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, mcelsius_avg); + } */ + } + + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_fans(void) +{ + uint32_t fan_dir; + int ret; + int cur_duty_cycle, new_duty_cycle, tmp; + int direct_addon = 0; + onlp_oid_t fan_duty_oid = ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY); + + /********************************************************** + * Decision 1: Set fan as full speed if any fan is failed. + **********************************************************/ + ret = sysi_check_fan(&fan_dir); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + if (fan_dir & ONLP_FAN_STATUS_B2F) { + direct_addon = FAN_DUTY_PLUS_FOR_DIR; + } + + /********************************************************** + * Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + **********************************************************/ + ret = sysi_get_fan_duty(&cur_duty_cycle); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + /********************************************************** + * Decision 3: Decide new fan speed depend on fan direction and temperature + **********************************************************/ + ret = sysi_get_duty_by_average(&new_duty_cycle); + if (ONLP_STATUS_OK != ret){ + return ret; + } + ret = sysi_get_duty_by_highest(&tmp); + if (ONLP_STATUS_OK != ret){ + return ret; + } + + new_duty_cycle = (tmp > new_duty_cycle)? tmp : new_duty_cycle; + if (new_duty_cycle == 0) + { + new_duty_cycle = fan_control_data_pre.duty_cycle; + } else { + fan_control_data_pre.duty_cycle = new_duty_cycle; + } + fan_control_data_pre.dir_plus = direct_addon; + DEBUG_PRINT("[INFO]%s#%d, new duty: %d = %d + %d (%d)!\n", __func__, __LINE__, + new_duty_cycle + direct_addon, new_duty_cycle, direct_addon, cur_duty_cycle); + + new_duty_cycle += direct_addon; + new_duty_cycle = (new_duty_cycle > FAN_DUTY_CYCLE_MAX)? + FAN_DUTY_CYCLE_MAX : new_duty_cycle; + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(fan_duty_oid, new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..d4267596 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,169 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +//#include +#include +#include +#include "platform_lib.h" + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*temp1_input" +#define PSU_THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*psu_temp1_input" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "3-0048", + "3-0049", + "3-004a", + "3-004b", + "11-0059", + "10-0058", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-4-4B", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char *format = NULL; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if(tid == THERMAL_CPU_CORE) { + return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + } + + switch (tid) { + case THERMAL_1_ON_MAIN_BROAD: + case THERMAL_2_ON_MAIN_BROAD: + case THERMAL_3_ON_MAIN_BROAD: + case THERMAL_4_ON_MAIN_BROAD: + format = THERMAL_PATH_FORMAT; + break; + case THERMAL_1_ON_PSU1: + case THERMAL_1_ON_PSU2: + format = PSU_THERMAL_PATH_FORMAT; + break; + default: + return ONLP_STATUS_E_INVALID; + }; + + /* get path */ + sprintf(path, format, directory[tid], tid); + + if (onlp_file_read_int(&info->mcelsius, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_config.c new file mode 100644 index 00000000..8d380535 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(_x) +x86_64_accton_as7312_54xs_config_settings_t x86_64_accton_as7312_54xs_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_STDLIB(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME(X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_AS7312_54XS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7312_54xs_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as7312_54xs_config_STRINGIFY_VALUE +#undef __x86_64_accton_as7312_54xs_config_STRINGIFY_NAME + +const char* +x86_64_accton_as7312_54xs_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as7312_54xs_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_as7312_54xs_config_settings[i].name, setting)) { + return x86_64_accton_as7312_54xs_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as7312_54xs_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as7312_54xs_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as7312_54xs_config_settings[i].name, x86_64_accton_as7312_54xs_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_enums.c new file mode 100644 index 00000000..73b7162e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_int.h new file mode 100644 index 00000000..44526e27 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as7312_54xs Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7312_54xs_INT_H__ +#define __x86_64_accton_as7312_54xs_INT_H__ + +#include + + +#endif /* __x86_64_accton_as7312_54xs_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.c new file mode 100644 index 00000000..1a3d668e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.c @@ -0,0 +1,20 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7312_54xs_log.h" +/* + * x86_64_accton_as7312_54xs log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS7312_54XS_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + + + \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.h new file mode 100644 index 00000000..169e765e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7312_54xs_LOG_H__ +#define __x86_64_accton_as7312_54xs_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as7312_54xs +#include + +#endif /* __x86_64_accton_as7312_54xs_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_module.c new file mode 100644 index 00000000..da136b5d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7312_54xs_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as7312_54xs_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as7312_54xs_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_ucli.c new file mode 100644 index 00000000..3e1ac081 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/x86_64_accton_as7312_54xs_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as7312_54xs_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as7312_54xs_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7312_54xs) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as7312_54xs_ucli_module__ = + { + "x86_64_accton_as7312_54xs_ucli", + NULL, + x86_64_accton_as7312_54xs_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as7312_54xs_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as7312_54xs_ucli_module__); + n = ucli_node_create("x86_64_accton_as7312_54xs", NULL, &x86_64_accton_as7312_54xs_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7312_54xs")); + return n; +} + +#else +void* +x86_64_accton_as7312_54xs_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/PKG.yml new file mode 100644 index 00000000..9b73e6f2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as7312-54xs REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/lib/x86-64-accton-as7312-54xs-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/lib/x86-64-accton-as7312-54xs-r0.yml new file mode 100644 index 00000000..7a12006c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/lib/x86-64-accton-as7312-54xs-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for AS7312 +# +###################################################################### + +x86-64-accton-as7312-54xs-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS1,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/python/x86_64_accton_as7312_54xs_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/python/x86_64_accton_as7312_54xs_r0/__init__.py new file mode 100644 index 00000000..ae110dc6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/platform-config/r0/src/python/x86_64_accton_as7312_54xs_r0/__init__.py @@ -0,0 +1,81 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as7312_54xs_r0(OnlPlatformAccton, + OnlPlatformPortConfig_48x25_6x100): + + PLATFORM='x86-64-accton-as7312-54xs-r0' + MODEL="AS7312-54XS" + SYS_OBJECT_ID=".7312.54.1" + + def baseconfig(self): + self.insmod('optoe') + self.insmod('ym2651y') + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + self.insmod("x86-64-accton-as7312-54xs-%s.ko" % m) + + ########### initialize I2C bus 0 ########### + # initialize multiplexer (PCA9548) + self.new_i2c_device('pca9548', 0x76, 0) + + self.new_i2c_devices([ + # initiate chassis fan + ('as7312_54xs_fan', 0x66, 2), + + # inititate LM75 + ('lm75', 0x48, 3), + ('lm75', 0x49, 3), + ('lm75', 0x4a, 3), + ('lm75', 0x4b, 3), + ]) + + + self.new_i2c_devices([ + # initialize CPLD + ('as7312_54xs_cpld1', 0x60, 4), + ('as7312_54xs_cpld2', 0x62, 5), + ('as7312_54xs_cpld3', 0x64, 6), + ]) + + self.new_i2c_device('pca9548', 0x71, 0) + + self.new_i2c_devices([ + # initiate PSU-1 + ('as7312_54xs_psu1', 0x51, 11), + ('ym2651', 0x59, 11), + + # initiate PSU-2 + ('as7312_54xs_psu2', 0x50, 10), + ('ym2651', 0x58, 10), + ]) + + + + ########### initialize I2C bus 1 ########### + + # initiate multiplexer (PCA9548) + self.new_i2c_devices( + [ + # initiate multiplexer (PCA9548) + ('pca9548', 0x72, 1), + ('pca9548', 0x73, 1), + ('pca9548', 0x74, 1), + ('pca9548', 0x75, 1), + ('pca9548', 0x76, 1), + ('pca9548', 0x71, 1), + ('pca9548', 0x70, 1), + ] + ) + + # initialize QSFP port 1~54 + for port in range(1, 49): + self.new_i2c_device('optoe2', 0x50, port+17) + + for port in range(49, 55): + self.new_i2c_device('optoe1', 0x50, port+17) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+17), shell=True) + + self.new_i2c_device('24c02', 0x57, 1) + return True From 6a680ec9c5c5ae851c00c0ce85b3671ea7b87c15 Mon Sep 17 00:00:00 2001 From: Michael Shych Date: Mon, 12 Mar 2018 20:04:57 +0000 Subject: [PATCH 176/244] Configure ISMT and AT24 drivers as modules. AT24 module can be loaded with different max buffer size. ISMT driver interfere with MLNX I2C controller. ISMT as module can be placed in blacklist on Mlnx platforms. Signed-off-by: Michael Shych --- .../any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index 70ad5059..b25358ec 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -1223,7 +1223,7 @@ CONFIG_VIRTIO_BLK=y # # EEPROM support # -CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_AT24=m CONFIG_EEPROM_AT25=y CONFIG_EEPROM_LEGACY=y # CONFIG_EEPROM_MAX6875 is not set @@ -2170,7 +2170,7 @@ CONFIG_I2C_ALGOBIT=y # CONFIG_I2C_AMD8111 is not set CONFIG_I2C_I801=y CONFIG_I2C_ISCH=y -CONFIG_I2C_ISMT=y +CONFIG_I2C_ISMT=m # CONFIG_I2C_PIIX4 is not set # CONFIG_I2C_NFORCE2 is not set # CONFIG_I2C_SIS5595 is not set From 0b6da573ab5fc7deef3b451d65d57fcf6cb998cd Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 14 Mar 2018 16:14:12 +0000 Subject: [PATCH 177/244] Update default versioning scheme for development and release builds. - Development builds will be marked with the branch and build id. - Release builds will contain the specific release name and a simplified system issue string. --- tools/onlvi.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tools/onlvi.py b/tools/onlvi.py index 6bee3bbe..e1331c60 100644 --- a/tools/onlvi.py +++ b/tools/onlvi.py @@ -1,12 +1,24 @@ +import subprocess + class OnlVersionImplementation(object): PRODUCTS = [ { "id" : "ONL", - "version": "2.0.0" - } - ] +# "version": "20YY-MM" + } + ] + def __init__(self): + if 'version' in self.PRODUCTS[0]: + # Release builds have a specific version. + self.release = True + else: + # The current branch is used as the release version. + self.release = False + cmd = ('git', 'rev-parse', '--abbrev-ref', 'HEAD') + branch = subprocess.check_output(cmd).strip() + self.PRODUCTS[0]['version'] = branch def V_OS_NAME(self, data): return "Open Network Linux OS" @@ -55,3 +67,9 @@ class OnlVersionImplementation(object): def V_SYSTEM_COMPATIBILITY_VERSION(self, data): return "2" + + def V_ISSUE(self, data): + if self.release: + return "%s %s" % (self.V_OS_NAME(data), self.V_VERSION_ID(data)) + else: + return self.V_VERSION_STRING(data) From 65f0a361102d2204c40504c06250486330658a83 Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Wed, 14 Mar 2018 14:06:38 -0700 Subject: [PATCH 178/244] bug fix --- .../modules/builds/x86-64-accton-as6712-32x-fan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c index 1e980efe..40e91349 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c @@ -270,7 +270,6 @@ static void accton_as6712_32x_fan_update_device(struct device *dev) { int speed, r_speed, fault, r_fault, direction, ctrl_speed; int i; - int retry_count = 5; mutex_lock(&fan_data->update_lock); @@ -300,6 +299,8 @@ static void accton_as6712_32x_fan_update_device(struct device *dev) for (i = 0; i < FAN_MAX_NUMBER; i++) { + int retry_count = 5; + /* Update fan data */ From 66fafe748b3ae36e4a6d06ba8585cbf9aebc7935 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Thu, 15 Mar 2018 17:07:13 +0800 Subject: [PATCH 179/244] Add suport read PSU serial number --- .../builds/x86-64-accton-as5812-54x-fan.c | 7 +- .../builds/x86-64-accton-as5812-54x-leds.c | 6 +- .../builds/x86-64-accton-as5812-54x-psu.c | 91 +++++++++++++++++-- .../onlp/builds/src/module/src/platform_lib.c | 28 ++++++ .../onlp/builds/src/module/src/platform_lib.h | 1 + .../onlp/builds/src/module/src/psui.c | 3 + 6 files changed, 116 insertions(+), 20 deletions(-) mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.c mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.h mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/psui.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c old mode 100644 new mode 100755 index 3e25db1e..4c3cdeab --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c @@ -393,12 +393,7 @@ static struct platform_driver accton_as5812_54x_fan_driver = { static int __init accton_as5812_54x_fan_init(void) { int ret; - - extern int platform_accton_as5812_54x(void); - if(!platform_accton_as5812_54x()) { - return -ENODEV; - } - + ret = platform_driver_register(&accton_as5812_54x_fan_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c old mode 100644 new mode 100755 index b7018683..f196f22c --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c @@ -551,11 +551,7 @@ static struct platform_driver accton_as5812_54x_led_driver = { static int __init accton_as5812_54x_led_init(void) { int ret; - - extern int platform_accton_as5812_54x(void); - if(!platform_accton_as5812_54x()) { - return -ENODEV; - } + ret = platform_driver_register(&accton_as5812_54x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c old mode 100644 new mode 100755 index d4c44779..2703897f --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c @@ -42,9 +42,10 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_serial_number(struct device *dev, struct device_attribute *da,char *buf); static int as5812_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -static int as5812_54x_psu_model_name_get(struct device *dev); +static int as5812_54x_psu_model_name_get(struct device *dev , int get_serial); /* Addresses scanned */ @@ -60,6 +61,7 @@ struct as5812_54x_psu_data { u8 index; /* PSU index */ u8 status; /* Status(present/power_good) register read from CPLD */ char model_name[14]; /* Model name, read from eeprom */ + char serial[16]; /* Model name, read from eeprom */ }; static struct as5812_54x_psu_data *as5812_54x_psu_update_device(struct device *dev); @@ -68,7 +70,8 @@ enum as5812_54x_psu_sysfs_attributes { PSU_INDEX, PSU_PRESENT, PSU_MODEL_NAME, - PSU_POWER_GOOD + PSU_POWER_GOOD, + PSU_SERIAL_NUMBER }; /* sysfs attributes for hwmon @@ -76,12 +79,14 @@ enum as5812_54x_psu_sysfs_attributes { static SENSOR_DEVICE_ATTR(psu_index, S_IRUGO, show_index, NULL, PSU_INDEX); static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_serial, S_IRUGO, show_serial_number, NULL, PSU_SERIAL_NUMBER); static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); static struct attribute *as5812_54x_psu_attributes[] = { &sensor_dev_attr_psu_index.dev_attr.attr, &sensor_dev_attr_psu_present.dev_attr.attr, &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_serial.dev_attr.attr, &sensor_dev_attr_psu_power_good.dev_attr.attr, NULL }; @@ -116,6 +121,25 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", status); } +static ssize_t show_serial_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as5812_54x_psu_data *data = as5812_54x_psu_update_device(dev); + + if (!data->valid) { + return 0; + } + + if (!IS_PRESENT(data->index, data->status)) { + return 0; + } + + if (as5812_54x_psu_model_name_get(dev, 1) < 0) { + return -ENXIO; + } + return sprintf(buf, "%s\n", data->serial); +} + static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf) { @@ -129,7 +153,7 @@ static ssize_t show_model_name(struct device *dev, struct device_attribute *da, return 0; } - if (as5812_54x_psu_model_name_get(dev) < 0) { + if (as5812_54x_psu_model_name_get(dev, 0) < 0) { return -ENXIO; } @@ -254,6 +278,59 @@ enum psu_type { PSU_UM400D01_01G /* DC48V - B2F */ }; +struct serial_number_info { + enum psu_type type; + u8 offset; + u8 length; +}; + +struct serial_number_info serials[] = { +{PSU_YM_2401_JCR, 0x20, 11}, +{PSU_YM_2401_JDR, 0x20, 11}, +{PSU_CPR_4011_4M11, 0x47, 15}, +{PSU_CPR_4011_4M21, 0x47, 15}, +{PSU_CPR_6011_2M11, 0x46, 15}, +{PSU_CPR_6011_2M21, 0x46, 15}, +{PSU_UM400D_01G, 0x50, 9}, +{PSU_UM400D01_01G, 0x50, 12}, +}; + +static int as5812_54x_psu_serial_number_get(struct device *dev, enum psu_type type) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_psu_data *data = i2c_get_clientdata(client); + int i, status; + + switch (type) { + case PSU_CPR_4011_4M11: + case PSU_CPR_4011_4M21: + case PSU_CPR_6011_2M11: + case PSU_CPR_6011_2M21: + { + if(type >= sizeof(serials)/sizeof(struct serial_number_info)) + return -EINVAL; + status = as5812_54x_psu_read_block(client, serials[type].offset, + data->serial, serials[type].length); + if (status < 0) { + data->serial[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial number from (0x%x) offset(0x%x)\n", + client->addr, serials[type].offset); + return status; + } + else { + data->serial[serials[type].length] = '\0'; + return 0; + } + } + break; + default: + break; + } + + return -ENODATA; +} + + struct model_name_info { enum psu_type type; u8 offset; @@ -272,7 +349,7 @@ struct model_name_info models[] = { {PSU_UM400D01_01G, 0x50, 12, "um400d01-01G"}, }; -static int as5812_54x_psu_model_name_get(struct device *dev) +static int as5812_54x_psu_model_name_get(struct device *dev , int get_serial) { struct i2c_client *client = to_i2c_client(dev); struct as5812_54x_psu_data *data = i2c_get_clientdata(client); @@ -303,7 +380,7 @@ static int as5812_54x_psu_model_name_get(struct device *dev) /* Determine if the model name is known, if not, read next index */ if (strncmp(data->model_name, models[i].model_name, models[i].length) == 0) { - return 0; + return get_serial ? as5812_54x_psu_serial_number_get(dev, i) : 0; } else { data->model_name[0] = '\0'; @@ -351,10 +428,6 @@ exit: static int __init as5812_54x_psu_init(void) { - extern int platform_accton_as5812_54x(void); - if(!platform_accton_as5812_54x()) { - return -ENODEV; - } return i2c_add_driver(&as5812_54x_psu_driver); } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.c old mode 100644 new mode 100755 index 75526b5f..2a62f3fe --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.c @@ -23,6 +23,8 @@ * * ***********************************************************/ +#include +#include #include #include #include @@ -249,3 +251,29 @@ int psu_ym2401_pmbus_info_set(int id, char *node, int value) return ONLP_STATUS_OK; } +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, int is_ac, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + memset((void *)serial, 0x0, serial_len); + if(is_ac) + prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; + else + prefix = (id == PSU1_ID) ? PSU1_DC_EEPROM_PREFIX : PSU2_DC_EEPROM_PREFIX; + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.h old mode 100644 new mode 100755 index f49973e6..61be2f90 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/platform_lib.h @@ -71,6 +71,7 @@ typedef enum psu_type { } psu_type_t; psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, int is_ac, char *serial, int serial_len); int psu_ym2401_pmbus_info_get(int id, char *node, int *value); int psu_ym2401_pmbus_info_set(int id, char *node, int value); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/psui.c old mode 100644 new mode 100755 index 7a14c060..bc753041 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/psui.c @@ -225,6 +225,7 @@ 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); + int is_ac=1; psu_type_t psu_type; VALIDATE(id); @@ -270,12 +271,14 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) break; case PSU_TYPE_DC_48V_F2B: case PSU_TYPE_DC_48V_B2F: + is_ac=0; ret = psu_um400d_info_get(info); break; default: ret = ONLP_STATUS_E_UNSUPPORTED; break; } + psu_serial_number_get(index, is_ac, info->serial, sizeof(info->serial)); return ret; } From 0dfee26e04a7c7fba828bfe9f5bde0b290099346 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Thu, 15 Mar 2018 17:29:07 +0800 Subject: [PATCH 180/244] Fix to use correct offset to read psu serial --- .../modules/builds/x86-64-accton-as6812-32x-psu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c index 7a96c931..a782870e 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c @@ -297,8 +297,8 @@ struct serial_number_info { struct serial_number_info serials[] = { {PSU_YM_2401_JCR, 0x20, 11}, {PSU_YM_2401_JDR, 0x20, 11}, -{PSU_CPR_4011_4M11, 0x46, 15}, -{PSU_CPR_4011_4M21, 0x46, 15}, +{PSU_CPR_4011_4M11, 0x47, 15}, +{PSU_CPR_4011_4M21, 0x47, 15}, {PSU_CPR_6011_2M11, 0x46, 15}, {PSU_CPR_6011_2M21, 0x46, 15}, {PSU_UM400D_01G, 0x50, 9}, @@ -317,16 +317,18 @@ static int as6812_32x_psu_serial_number_get(struct device *dev, enum psu_type ty case PSU_CPR_6011_2M11: case PSU_CPR_6011_2M21: { - status = as6812_32x_psu_read_block(client, serials[i].offset, - data->serial, serials[i].length); + if(type >= sizeof(serials)/sizeof(struct serial_number_info)) + return -EINVAL; + status = as6812_32x_psu_read_block(client, serials[type].offset, + data->serial, serials[type].length); if (status < 0) { data->serial[0] = '\0'; dev_dbg(&client->dev, "unable to read serial number from (0x%x) offset(0x%x)\n", - client->addr, serials[i].offset); + client->addr, serials[type].offset); return status; } else { - data->serial[serials[i].length] = '\0'; + data->serial[serials[type].length] = '\0'; return 0; } } From e8b177c1df2edf4f13c699a1175cf410808ed0b1 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 15 Mar 2018 17:39:35 +0800 Subject: [PATCH 181/244] [as5912-54xk] Add support for OOM driver --- .../builds/x86-64-accton-as5912-54xk-cpld.c | 1098 ++++++++++++++ .../builds/x86-64-accton-as5912-54xk-leds.c | 8 +- .../builds/x86-64-accton-as5912-54xk-psu.c | 4 +- .../builds/x86-64-accton-as5912-54xk-sfp.c | 1315 ----------------- .../onlp/builds/src/module/src/sfpi.c | 240 +-- .../x86_64_accton_as5912_54xk_r0/__init__.py | 16 +- 6 files changed, 1268 insertions(+), 1413 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-cpld.c new file mode 100644 index 00000000..aba70271 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-cpld.c @@ -0,0 +1,1098 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5912_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as5912_54xk_cpld1, + as5912_54xk_cpld2 +}; + +struct as5912_54xk_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as5912_54xk_cpld_id[] = { + { "as5912_54xk_cpld1", as5912_54xk_cpld1 }, + { "as5912_54xk_cpld2", as5912_54xk_cpld2 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as5912_54xk_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5912_54xk_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5912_54xk_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5912_54xk_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5912_54xk_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5912_54xk_cpld1_group = { + .attrs = as5912_54xk_cpld1_attributes, +}; + +static struct attribute *as5912_54xk_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5912_54xk_cpld2_group = { + .attrs = as5912_54xk_cpld2_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x10, 0x11, 0x12, 0x52}; + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54xk_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5912_54xk_cpld1) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5912_54xk_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + if (data->type == as5912_54xk_cpld1) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5912_54xk_cpld2 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x30, 0x32, 0x34}; + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54xk_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5912_54xk_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5912_54xk_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x52; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5912_54xk_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54xk_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5912_54xk_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5912_54xk_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5912_54xk_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5912_54xk_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as5912_54xk_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5912_54xk_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as5912_54xk_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as5912_54xk_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as5912_54xk_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as5912_54xk_cpld1: + group = &as5912_54xk_cpld1_group; + break; + case as5912_54xk_cpld2: + group = &as5912_54xk_cpld2_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as5912_54xk_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as5912_54xk_cpld_remove(struct i2c_client *client) +{ + struct as5912_54xk_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as5912_54xk_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5912_54xk_cpld1: + group = &as5912_54xk_cpld1_group; + break; + case as5912_54xk_cpld2: + group = &as5912_54xk_cpld2_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as5912_54xk_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5912_54xk_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5912_54xk_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5912_54xk_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5912_54xk_cpld_read); + +int as5912_54xk_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5912_54xk_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5912_54xk_cpld_write); + +static struct i2c_driver as5912_54xk_cpld_driver = { + .driver = { + .name = "as5912_54xk_cpld", + .owner = THIS_MODULE, + }, + .probe = as5912_54xk_cpld_probe, + .remove = as5912_54xk_cpld_remove, + .id_table = as5912_54xk_cpld_id, +}; + +static int __init as5912_54xk_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5912_54xk_cpld_driver); +} + +static void __exit as5912_54xk_cpld_exit(void) +{ + i2c_del_driver(&as5912_54xk_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as5912_54xk_cpld_init); +module_exit(as5912_54xk_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-leds.c index b81cef4d..f7b3ca43 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-leds.c @@ -38,8 +38,8 @@ #define DEBUG_PRINT(fmt, args...) #endif -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5912_54xk_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5912_54xk_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); struct accton_as5912_54xk_led_data { struct platform_device *pdev; @@ -157,12 +157,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5912_54xk_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as5912_54xk_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as5912_54xk_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as5912_54xk_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as5912_54xk_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-psu.c index da4ea68b..964838a6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-psu.c @@ -37,7 +37,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5912_54xk_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5912_54xk_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -234,7 +234,7 @@ static struct as5912_54xk_psu_data *as5912_54xk_psu_update_device(struct device dev_dbg(&client->dev, "Starting as5912_54xk update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as5912_54xk_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-sfp.c deleted file mode 100644 index 14771b1b..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/modules/builds/x86-64-accton-as5912-54xk-sfp.c +++ /dev/null @@ -1,1315 +0,0 @@ -/* - * SFP driver for accton as5912_54xk sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5912_54xk_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -/* Platform dependent +++ */ -#define I2C_ADDR_CPLD1 0x60 -#define I2C_ADDR_CPLD2 0x62 -/* Platform dependent --- */ - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as5912_54xk_sfp1, as5912_54xk_sfp2, as5912_54xk_sfp3, as5912_54xk_sfp4, as5912_54xk_sfp5, as5912_54xk_sfp6, as5912_54xk_sfp7, as5912_54xk_sfp8, -as5912_54xk_sfp9, as5912_54xk_sfp10, as5912_54xk_sfp11, as5912_54xk_sfp12, as5912_54xk_sfp13, as5912_54xk_sfp14, as5912_54xk_sfp15, as5912_54xk_sfp16, -as5912_54xk_sfp17, as5912_54xk_sfp18, as5912_54xk_sfp19, as5912_54xk_sfp20, as5912_54xk_sfp21, as5912_54xk_sfp22, as5912_54xk_sfp23, as5912_54xk_sfp24, -as5912_54xk_sfp25, as5912_54xk_sfp26, as5912_54xk_sfp27, as5912_54xk_sfp28, as5912_54xk_sfp29, as5912_54xk_sfp30, as5912_54xk_sfp31, as5912_54xk_sfp32, -as5912_54xk_sfp33, as5912_54xk_sfp34, as5912_54xk_sfp35, as5912_54xk_sfp36, as5912_54xk_sfp37, as5912_54xk_sfp38, as5912_54xk_sfp39, as5912_54xk_sfp40, -as5912_54xk_sfp41, as5912_54xk_sfp42, as5912_54xk_sfp43, as5912_54xk_sfp44, as5912_54xk_sfp45, as5912_54xk_sfp46, as5912_54xk_sfp47, as5912_54xk_sfp48, -as5912_54xk_sfp49, as5912_54xk_sfp50, as5912_54xk_sfp51, as5912_54xk_sfp52, as5912_54xk_sfp53, as5912_54xk_sfp54 -}; - -static const struct i2c_device_id sfp_device_id[] = { -{ "as5912_54xk_sfp1", as5912_54xk_sfp1 }, { "as5912_54xk_sfp2", as5912_54xk_sfp2 }, { "as5912_54xk_sfp3", as5912_54xk_sfp3 }, { "as5912_54xk_sfp4", as5912_54xk_sfp4 }, -{ "as5912_54xk_sfp5", as5912_54xk_sfp5 }, { "as5912_54xk_sfp6", as5912_54xk_sfp6 }, { "as5912_54xk_sfp7", as5912_54xk_sfp7 }, { "as5912_54xk_sfp8", as5912_54xk_sfp8 }, -{ "as5912_54xk_sfp9", as5912_54xk_sfp9 }, { "as5912_54xk_sfp10", as5912_54xk_sfp10 }, { "as5912_54xk_sfp11", as5912_54xk_sfp11 }, { "as5912_54xk_sfp12", as5912_54xk_sfp12 }, -{ "as5912_54xk_sfp13", as5912_54xk_sfp13 }, { "as5912_54xk_sfp14", as5912_54xk_sfp14 }, { "as5912_54xk_sfp15", as5912_54xk_sfp15 }, { "as5912_54xk_sfp16", as5912_54xk_sfp16 }, -{ "as5912_54xk_sfp17", as5912_54xk_sfp17 }, { "as5912_54xk_sfp18", as5912_54xk_sfp18 }, { "as5912_54xk_sfp19", as5912_54xk_sfp19 }, { "as5912_54xk_sfp20", as5912_54xk_sfp20 }, -{ "as5912_54xk_sfp21", as5912_54xk_sfp21 }, { "as5912_54xk_sfp22", as5912_54xk_sfp22 }, { "as5912_54xk_sfp23", as5912_54xk_sfp23 }, { "as5912_54xk_sfp24", as5912_54xk_sfp24 }, -{ "as5912_54xk_sfp25", as5912_54xk_sfp25 }, { "as5912_54xk_sfp26", as5912_54xk_sfp26 }, { "as5912_54xk_sfp27", as5912_54xk_sfp27 }, { "as5912_54xk_sfp28", as5912_54xk_sfp28 }, -{ "as5912_54xk_sfp29", as5912_54xk_sfp29 }, { "as5912_54xk_sfp30", as5912_54xk_sfp30 }, { "as5912_54xk_sfp31", as5912_54xk_sfp31 }, { "as5912_54xk_sfp32", as5912_54xk_sfp32 }, -{ "as5912_54xk_sfp33", as5912_54xk_sfp33 }, { "as5912_54xk_sfp34", as5912_54xk_sfp34 }, { "as5912_54xk_sfp35", as5912_54xk_sfp35 }, { "as5912_54xk_sfp36", as5912_54xk_sfp36 }, -{ "as5912_54xk_sfp37", as5912_54xk_sfp37 }, { "as5912_54xk_sfp38", as5912_54xk_sfp38 }, { "as5912_54xk_sfp39", as5912_54xk_sfp39 }, { "as5912_54xk_sfp40", as5912_54xk_sfp40 }, -{ "as5912_54xk_sfp41", as5912_54xk_sfp41 }, { "as5912_54xk_sfp42", as5912_54xk_sfp42 }, { "as5912_54xk_sfp43", as5912_54xk_sfp43 }, { "as5912_54xk_sfp44", as5912_54xk_sfp44 }, -{ "as5912_54xk_sfp45", as5912_54xk_sfp45 }, { "as5912_54xk_sfp46", as5912_54xk_sfp46 }, { "as5912_54xk_sfp47", as5912_54xk_sfp47 }, { "as5912_54xk_sfp48", as5912_54xk_sfp48 }, -{ "as5912_54xk_sfp49", as5912_54xk_sfp49 }, { "as5912_54xk_sfp50", as5912_54xk_sfp50 }, { "as5912_54xk_sfp51", as5912_54xk_sfp51 }, { "as5912_54xk_sfp52", as5912_54xk_sfp52 }, -{ "as5912_54xk_sfp53", as5912_54xk_sfp53 }, { "as5912_54xk_sfp54", as5912_54xk_sfp54 }, -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = I2C_ADDR_CPLD1 + i*2; - reg = 0x10+j; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-52(QSFP port) */ - cpld_addr = I2C_ADDR_CPLD2; - reg = 0x52; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)(status & 0x3F) << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - u8 tx_rx_regs[] = {0x14, 0x16, 0x18, 0x20, 0x22, 0x24, 0x30, 0x32, 0x34}; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as5912_54xk sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < ARRAY_SIZE(tx_rx_regs); j++) { - unsigned short cpld_addr = I2C_ADDR_CPLD1 + i*2; - - status = accton_i2c_cpld_read(cpld_addr, tx_rx_regs[j]); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, tx_rx_regs[i], status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - u8 tx_disable_regs[] = {0x20, 0x22, 0x24}; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = I2C_ADDR_CPLD1; - cpld_reg = tx_disable_regs[data->port / 8]; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = I2C_ADDR_CPLD2; - cpld_reg = tx_disable_regs[(data->port - 24) / 8]; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = accton_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - accton_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as5912_54xk_sfp1 && dev_id->driver_data <= as5912_54xk_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* as5912_54xk_sfp49 ~ as5912_54xk_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5912_54xk_sfp driver"); -MODULE_LICENSE("GPL"); - -late_initcall(sfp_init); -module_exit(sfp_exit); - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/sfpi.c index a24a5b96..51b5fbfc 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/onlp/builds/src/module/src/sfpi.c @@ -24,17 +24,21 @@ * ***********************************************************/ #include +#include #include -#include "platform_lib.h" - +#include "x86_64_accton_as5912_54xk_int.h" #include "x86_64_accton_as5912_54xk_log.h" -#define NUM_OF_SFP_PORT 54 -#define MAX_PORT_PATH 64 +#define PORT_BUS_INDEX(port) (port+26) -#define SFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" -#define SFP_PORT_DOM_FORMAT "/sys/bus/i2c/devices/%d-0051/%s" -#define SFP_BUS_INDEX(port) (port+26) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD1 "/sys/bus/i2c/devices/4-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/5-0062/module_rx_los_all" /************************************************************ * @@ -55,8 +59,8 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) * Ports {0, 54} */ int p; - - for(p = 0; p < NUM_OF_SFP_PORT; p++) { + + for(p = 0; p < 54; p++) { AIM_BITMAP_SET(bmap, p); } @@ -72,7 +76,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - if (onlp_file_read_int(&present, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_is_present") < 0) { + int bus, addr; + + addr = (port < 24) ? 60 : 62; + bus = (addr == 60) ? 4 : 5; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -83,31 +92,45 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char path[MAX_PORT_PATH] = {0}; + uint32_t bytes[7], *ptr = NULL; FILE* fp; + int addr; - sprintf(path, SFP_PORT_FORMAT, SFP_BUS_INDEX(0), "sfp_is_present_all"); - fp = fopen(path, "r"); + ptr = bytes; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 60; addr <= 62; addr+=2) { + /* Read present status of port 0~53 */ + int count = 0; + char file[64] = {0}; + int bus = (addr == 60) ? 4 : 5; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + + if (addr == 60) { /* CPLD1 */ + count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + else { /* CPLD2 */ + count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + + ptr += count; } /* Mask out non-existant QSFP ports */ @@ -130,64 +153,44 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_OK; } -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int size = 0; - if(onlp_file_read(data, 256, &size, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { - if(size == 256) { - return ONLP_STATUS_OK; - } - } - - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - int size = 0; - if(onlp_file_read(data, 256, &size, SFP_PORT_DOM_FORMAT, SFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { - if(size == 256) { - return ONLP_STATUS_OK; - } - } - - return ONLP_STATUS_E_INTERNAL; -} - int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[6]; - char path[MAX_PORT_PATH] = {0}; + uint32_t *ptr = bytes; FILE* fp; - sprintf(path, SFP_PORT_FORMAT, SFP_BUS_INDEX(0), "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 60; addr <= 62; addr+=2) { + if (addr == 60) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; - for(i = 5; i >= 0; i--) { + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } @@ -201,16 +204,77 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_OK; } +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 4 : 5; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_write_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_disable") != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -233,12 +297,19 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 4 : 5; + switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_rx_los") < 0) { - AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } else { @@ -249,7 +320,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_fault") < 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -261,7 +332,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_disable") < 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -278,7 +349,6 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) return rv; } - int onlp_sfpi_denit(void) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/platform-config/r0/src/python/x86_64_accton_as5912_54xk_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/platform-config/r0/src/python/x86_64_accton_as5912_54xk_r0/__init__.py index 9922d621..dfbb7551 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/platform-config/r0/src/python/x86_64_accton_as5912_54xk_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5912-54xk/platform-config/r0/src/python/x86_64_accton_as5912_54xk_r0/__init__.py @@ -8,9 +8,9 @@ class OnlPlatform_x86_64_accton_as5912_54xk_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5912.54" def baseconfig(self): - self.insmod("accton_i2c_cpld") + self.insmod('optoe') self.insmod("ym2651y") - for m in [ "sfp", "psu", "fan", "leds" ]: + for m in [ "cpld", "psu", "fan", "leds" ]: self.insmod("x86-64-accton-as5912-54xk-%s" % m) ########### initialize I2C bus 0 ########### @@ -29,8 +29,8 @@ class OnlPlatform_x86_64_accton_as5912_54xk_r0(OnlPlatformAccton, ('lm75', 0x4b, 3), # initialize CPLDs - ('accton_i2c_cpld', 0x60, 4), - ('accton_i2c_cpld', 0x62, 5), + ('as5912_54xk_cpld1', 0x60, 4), + ('as5912_54xk_cpld2', 0x62, 5), ] ) @@ -69,12 +69,14 @@ class OnlPlatform_x86_64_accton_as5912_54xk_r0(OnlPlatformAccton, # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5912_54xk_sfp%d' % port, 0x50, port+25) - self.new_i2c_device('as5912_54xk_sfp%d' % port, 0x51, port+25) + self.new_i2c_device('optoe2', 0x50, port+25) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5912_54xk_sfp%d' % port, 0x50, port+25) + self.new_i2c_device('optoe1', 0x50, port+25) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+25), shell=True) return True From aaf6bab186926e113e9b9dcadafe84bd12111b64 Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Thu, 15 Mar 2018 10:51:24 -0700 Subject: [PATCH 182/244] minor change --- .../modules/builds/x86-64-accton-as6712-32x-fan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c index 40e91349..1fc18f35 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6712-32x/modules/builds/x86-64-accton-as6712-32x-fan.c @@ -269,7 +269,7 @@ static int accton_as6712_32x_fan_write_value(u8 reg, u8 value) static void accton_as6712_32x_fan_update_device(struct device *dev) { int speed, r_speed, fault, r_fault, direction, ctrl_speed; - int i; + int i, retry_count; mutex_lock(&fan_data->update_lock); @@ -299,7 +299,7 @@ static void accton_as6712_32x_fan_update_device(struct device *dev) for (i = 0; i < FAN_MAX_NUMBER; i++) { - int retry_count = 5; + retry_count = 5; /* Update fan data */ From c207b7d7bb4a35b34dbfb8c3dc0d612bbe14fe11 Mon Sep 17 00:00:00 2001 From: Wilson Ng Date: Thu, 15 Mar 2018 18:04:59 -0700 Subject: [PATCH 183/244] Update bigcode. --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index 6a3c9705..081f26bb 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 6a3c9705a418c419dbea2dc46c46fa2f00dcd6b2 +Subproject commit 081f26bb5be40d51a8551d35395f06be137349cb From 21d00075c456c8d96e3248dc49a64abaef4da265 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 16 Mar 2018 09:06:56 -0700 Subject: [PATCH 184/244] Rudimentary profiling and color enhancements. --- tools/onlu.py | 82 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 12 deletions(-) diff --git a/tools/onlu.py b/tools/onlu.py index 19e4abd1..f5f1f46c 100644 --- a/tools/onlu.py +++ b/tools/onlu.py @@ -12,15 +12,48 @@ import os import fcntl import glob from string import Template +import time logger = None -# Cheap colored terminal logging. Fixme. -def color_logging(): - if sys.stderr.isatty(): - logging.addLevelName( logging.WARNING, "\033[1;31m%s\033[1;0m" % logging.getLevelName(logging.WARNING)) - logging.addLevelName( logging.ERROR, "\033[1;41m%s\033[1;0m" % logging.getLevelName(logging.ERROR)) +class colors(object): + RED=31 + GREEN=32 + YELLOW=33 + BLUE=34 + PURPLE=35 + CYAN=36 + REDB=41 + GREENB=42 + YELLOWB=43 + BLUEB=44 + PURPLEB=45 + CYANB=46 + + @staticmethod + def color(string, color): + if sys.stderr.isatty(): + return "\033[1;%sm%s\033[1;0m" % (color, string) + else: + return string + +# Adds a method for each color to the colors class +for attr in dir(colors): + def colormethod(attr): + def f(klass, string): + return colors.color(string, getattr(colors, attr)) + return classmethod(f) + + if attr.isupper(): + setattr(colors, attr.lower(), colormethod(attr)) + + + + +def color_logging(): + logging.addLevelName( logging.WARNING, colors.red(logging.getLevelName(logging.WARNING))) + logging.addLevelName( logging.ERROR, colors.redb(logging.getLevelName(logging.ERROR))) def init_logging(name, lvl=logging.DEBUG): global logger @@ -31,6 +64,27 @@ def init_logging(name, lvl=logging.DEBUG): return logger +class Profiler(object): + + ENABLED=True + LOGFILE='plog' + + def __enter__(self): + self.start = time.time() + return self + + def __exit__(self, *exc): + self.end = time.time() + self.duration = self.end - self.start + + def log(self, operation, prefix=''): + msg = "[profiler] %s%s : %s seconds (%s minutes)" % (prefix, operation, self.duration, self.duration / 60.0) + if self.ENABLED: + logger.info(colors.cyan(msg)) + if self.LOGFILE: + with open(self.LOGFILE, "a") as f: + f.write(msg + "\n") + ############################################################ # # Log and execute system commands @@ -62,13 +116,17 @@ def execute(args, sudo=False, chroot=None, ex=None): logger.debug("Executing:%s", args) - try: - subprocess.check_call(args, shell=shell) - return 0 - except subprocess.CalledProcessError, e: - if ex: - raise ex - return e.returncode + rv = 0 + with Profiler() as profiler: + try: + subprocess.check_call(args, shell=shell) + rv = 0 + except subprocess.CalledProcessError, e: + if ex: + raise ex + rv = e.returncode + profiler.log(args) + return rv # Flatten lists if string lists From 04cc75fc762cca0c39c67ecd512dccc0df4fc01a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 16 Mar 2018 09:08:21 -0700 Subject: [PATCH 185/244] Add profiling for ASR generation. --- tools/onlpm.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index deaad7c7..4402aa75 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -432,13 +432,14 @@ class OnlPackage(object): command = command + "--after-remove %s " % OnlPackageAfterRemoveScript(self.pkg['init'], dir=workdir).name if self.pkg.get('asr', True): - # Generate the ASR documentation for this package. - sys.path.append("%s/sm/infra/tools" % os.getenv('ONL')) - import asr - asro = asr.AimSyslogReference() - asro.extract(workdir) - asro.format(os.path.join(docpath, asr.AimSyslogReference.ASR_NAME), 'json') - + with onlu.Profiler() as profiler: + # Generate the ASR documentation for this package. + sys.path.append("%s/sm/infra/tools" % os.getenv('ONL')) + import asr + asro = asr.AimSyslogReference() + asro.extract(workdir) + asro.format(os.path.join(docpath, asr.AimSyslogReference.ASR_NAME), 'json') + profiler.log("ASR generation for %(name)s" % self.pkg) ############################################################ if logger.level < logging.INFO: @@ -1234,14 +1235,15 @@ if __name__ == '__main__': if ops.list_all: print pm + if ops.pmake: + pm.pmake() + + pm.filter(subdir = ops.subdir, arches=ops.arches) if ops.list: print pm - if ops.pmake: - pm.pmake() - if ops.pkg_info: print pm.pkg_info() From b042476061a7e572613f1e0e809ccb781dfbf150 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 16 Mar 2018 09:12:41 -0700 Subject: [PATCH 186/244] Use a better default value for parallel jobs. --- setup.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.env b/setup.env index 667ba08f..63f5fa1d 100755 --- a/setup.env +++ b/setup.env @@ -23,7 +23,7 @@ export PATH="$ONL/tools/scripts:$ONL/tools:$PATH" # Parallel Make Jobs # Default parallel build settings -export ONL_MAKE_PARALLEL=-j16 +export ONL_MAKE_PARALLEL=-j$(echo "$(nproc) * 2" | bc) # Version files $ONL/tools/make-versions.py --import-file=$ONL/tools/onlvi --class-name=OnlVersionImplementation --output-dir $ONL/make/versions From e37acae2f7a271730c927b75d80c660c7124ab6c Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 18 Mar 2018 16:03:46 +0000 Subject: [PATCH 187/244] Disable logfile.: --- tools/onlu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/onlu.py b/tools/onlu.py index f5f1f46c..240bc5c0 100644 --- a/tools/onlu.py +++ b/tools/onlu.py @@ -67,7 +67,7 @@ def init_logging(name, lvl=logging.DEBUG): class Profiler(object): ENABLED=True - LOGFILE='plog' + LOGFILE=None def __enter__(self): self.start = time.time() From ac99793c451404e61815e7caf1128a990e2fee4d Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Mon, 19 Mar 2018 11:28:59 +0800 Subject: [PATCH 188/244] [as7816-64x] Fix PSU serial number inconrrect issue --- .../onlp/builds/src/module/src/platform_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c index 015bf647..d589fa93 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c @@ -30,7 +30,7 @@ #include "platform_lib.h" #define PSU_MODEL_NAME_LEN 8 -#define PSU_SERIAL_NUMBER_LEN 14 +#define PSU_SERIAL_NUMBER_LEN 18 #define PSU_NODE_MAX_PATH_LEN 64 int psu_serial_number_get(int id, char *serial, int serial_len) From ae59d5cf5cf8a3695d4a0541445f03cb115b57f3 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 20 Mar 2018 11:27:15 +0800 Subject: [PATCH 189/244] [as5812-54x] Add support for OOM --- .../builds/x86-64-accton-as5812-54x-cpld.c | 1089 +++++++++++++++-- .../builds/x86-64-accton-as5812-54x-fan.c | 10 +- .../builds/x86-64-accton-as5812-54x-leds.c | 8 +- .../builds/x86-64-accton-as5812-54x-psu.c | 17 +- .../builds/x86-64-accton-as5812-54x-sfp.c | 508 -------- .../onlp/builds/src/module/src/sfpi.c | 214 ++-- .../x86_64_accton_as5812_54x_r0/__init__.py | 21 +- 7 files changed, 1111 insertions(+), 756 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c index 14e1d860..5b9a5582 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c @@ -33,31 +33,13 @@ #include #include #include -#include #include +#include +#include +#include -static struct dmi_system_id as5812_54x_dmi_table[] = { - { - .ident = "Accton AS5812-54X", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS5812-54X"), - }, - }, - { - .ident = "Accton AS5812-54X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS5812-54X"), - }, - }, -}; - -int platform_accton_as5812_54x(void) -{ - return dmi_check_system(as5812_54x_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as5812_54x); +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x18 @@ -81,10 +63,13 @@ enum cpld_mux_type { as5812_54x_cpld1 }; -struct accton_i2c_cpld_mux { +struct as5812_54x_cpld_data { enum cpld_mux_type type; struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; u8 last_chan; /* last register value */ + + struct device *hwmon_dev; + struct mutex update_lock; }; struct chip_desc { @@ -108,17 +93,833 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { +static const struct i2c_device_id as5812_54x_cpld_mux_id[] = { { "as5812_54x_cpld1", as5812_54x_cpld1 }, { "as5812_54x_cpld2", as5812_54x_cpld2 }, { "as5812_54x_cpld3", as5812_54x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); +MODULE_DEVICE_TABLE(i2c, as5812_54x_cpld_mux_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5812_54x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5812_54x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5812_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5812_54x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5812_54x_cpld1_group = { + .attrs = as5812_54x_cpld1_attributes, +}; + +static struct attribute *as5812_54x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5812_54x_cpld2_group = { + .attrs = as5812_54x_cpld2_attributes, +}; + +static struct attribute *as5812_54x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5812_54x_cpld3_group = { + .attrs = as5812_54x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x6, 0x7, 0x8, 0x14}; + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5812_54x_cpld2) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5812_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 54 in order */ + if (data->type == as5812_54x_cpld2) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5812_54x_cpld3 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0xF, 0x10, 0x11}; + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5812_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5812_54x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49: + reg = 0x14; + mask = 0x1; + break; + case MODULE_PRESENT_50: + reg = 0x14; + mask = 0x4; + break; + case MODULE_PRESENT_51: + reg = 0x14; + mask = 0x10; + break; + case MODULE_PRESENT_52: + reg = 0x14; + mask = 0x2; + break; + case MODULE_PRESENT_53: + reg = 0x14; + mask = 0x8; + break; + case MODULE_PRESENT_54: + reg = 0x14; + mask = 0x20; + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5812_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5812_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5812_54x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5812_54x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, +static int as5812_54x_cpld_mux_reg_write(struct i2c_adapter *adap, struct i2c_client *client, u8 val) { unsigned long orig_jiffies; @@ -149,35 +950,35 @@ static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, return res; } -static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, +static int as5812_54x_cpld_mux_select_chan(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); u8 regval; int ret = 0; regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); + ret = as5812_54x_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int as5812_54x_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); + return as5812_54x_cpld_mux_reg_write(adap, client, data->last_chan); } -static void accton_i2c_cpld_add_client(struct i2c_client *client) +static void as5812_54x_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -193,7 +994,7 @@ static void accton_i2c_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void accton_i2c_cpld_remove_client(struct i2c_client *client) +static void as5812_54x_cpld_remove_client(struct i2c_client *client) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -219,107 +1020,178 @@ static void accton_i2c_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) { - u8 reg = 0x1; - struct i2c_client *client; - int len; + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); - client = to_i2c_client(dev); - len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); - - return len; + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); } -static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); - /* * I2C init/probing/exit functions */ -static int accton_i2c_cpld_mux_probe(struct i2c_client *client, +static int as5812_54x_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct accton_i2c_cpld_mux *data; + struct as5812_54x_cpld_data *data; int ret = -ENODEV; + const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; + goto exit; - data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); + data = kzalloc(sizeof(struct as5812_54x_cpld_data), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto err; + goto exit; } i2c_set_clientdata(client, data); - + mutex_init(&data->update_lock); data->type = id->driver_data; if (data->type == as5812_54x_cpld2 || data->type == as5812_54x_cpld3) { data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ - for (chan = 0; chan < chips[data->type].nchans; chan++) { - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) - I2C_CLASS_HWMON | I2C_CLASS_SPD, -#endif - accton_i2c_cpld_mux_select_chan, - accton_i2c_cpld_mux_deselect_mux); + /* Now create an adapter for each channel */ + for (chan = 0; chan < chips[data->type].nchans; chan++) { + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, + as5812_54x_cpld_mux_select_chan, + as5812_54x_cpld_mux_deselect_mux); - if (data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto virt_reg_failed; + if (data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); + goto exit_mux_register; + } + } + + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); + } + + /* Register sysfs hooks */ + switch (data->type) { + case as5812_54x_cpld1: + group = &as5812_54x_cpld1_group; + break; + case as5812_54x_cpld2: + group = &as5812_54x_cpld2_group; + break; + case as5812_54x_cpld3: + group = &as5812_54x_cpld3_group; + break; + default: + break; + } + + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_mux_register; } } - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); - } - - accton_i2c_cpld_add_client(client); - - ret = sysfs_create_file(&client->dev.kobj, &ver.attr); - if (ret) - goto virt_reg_failed; + as5812_54x_cpld_add_client(client); return 0; -virt_reg_failed: +exit_mux_register: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); } - - kfree(data); -err: + kfree(data); +exit: return ret; } -static int accton_i2c_cpld_mux_remove(struct i2c_client *client) +static int as5812_54x_cpld_mux_remove(struct i2c_client *client) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); const struct chip_desc *chip = &chips[data->type]; int chan; + const struct attribute_group *group = NULL; - sysfs_remove_file(&client->dev.kobj, &ver.attr); + as5812_54x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5812_54x_cpld1: + group = &as5812_54x_cpld1_group; + break; + case as5812_54x_cpld2: + group = &as5812_54x_cpld2_group; + break; + case as5812_54x_cpld3: + group = &as5812_54x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } for (chan = 0; chan < chip->nchans; ++chan) { - if (data->virt_adaps[chan]) { - i2c_del_mux_adapter(data->virt_adaps[chan]); - data->virt_adaps[chan] = NULL; - } + if (data->virt_adaps[chan]) { + i2c_del_mux_adapter(data->virt_adaps[chan]); + data->virt_adaps[chan] = NULL; + } } kfree(data); - accton_i2c_cpld_remove_client(client); return 0; } -int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) +static int as5812_54x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5812_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -329,21 +1201,21 @@ int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = as5812_54x_cpld_read_internal(cpld_node->client, reg); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5812_54x_i2c_cpld_read); +EXPORT_SYMBOL(as5812_54x_cpld_read); -int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -353,44 +1225,45 @@ int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = as5812_54x_cpld_write_internal(cpld_node->client, reg, value); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5812_54x_i2c_cpld_write); +EXPORT_SYMBOL(as5812_54x_cpld_write); -static struct i2c_driver accton_i2c_cpld_mux_driver = { +static struct i2c_driver as5812_54x_cpld_mux_driver = { .driver = { .name = "as5812_54x_cpld", .owner = THIS_MODULE, }, - .probe = accton_i2c_cpld_mux_probe, - .remove = accton_i2c_cpld_mux_remove, - .id_table = accton_i2c_cpld_mux_id, + .probe = as5812_54x_cpld_mux_probe, + .remove = as5812_54x_cpld_mux_remove, + .id_table = as5812_54x_cpld_mux_id, }; -static int __init accton_i2c_cpld_mux_init(void) +static int __init as5812_54x_cpld_mux_init(void) { mutex_init(&list_lock); - return i2c_add_driver(&accton_i2c_cpld_mux_driver); + return i2c_add_driver(&as5812_54x_cpld_mux_driver); } -static void __exit accton_i2c_cpld_mux_exit(void) +static void __exit as5812_54x_cpld_mux_exit(void) { - i2c_del_driver(&accton_i2c_cpld_mux_driver); + i2c_del_driver(&as5812_54x_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(accton_i2c_cpld_mux_init); -module_exit(accton_i2c_cpld_mux_exit); +module_init(as5812_54x_cpld_mux_init); +module_exit(as5812_54x_cpld_mux_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c index 4c3cdeab..2521a469 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c @@ -131,8 +131,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as5812_54x_fan_group = { static int accton_as5812_54x_fan_read_value(u8 reg) { - return as5812_54x_i2c_cpld_read(0x60, reg); + return as5812_54x_cpld_read(0x60, reg); } static int accton_as5812_54x_fan_write_value(u8 reg, u8 value) { - return as5812_54x_i2c_cpld_write(0x60, reg, value); + return as5812_54x_cpld_write(0x60, reg, value); } static void accton_as5812_54x_fan_update_device(struct device *dev) @@ -393,7 +393,7 @@ static struct platform_driver accton_as5812_54x_fan_driver = { static int __init accton_as5812_54x_fan_init(void) { int ret; - + ret = platform_driver_register(&accton_as5812_54x_fan_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c index f196f22c..0b8e46c4 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as5812_54x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5812_54x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -220,12 +220,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5812_54x_led_read_value(u8 reg) { - return as5812_54x_i2c_cpld_read(0x60, reg); + return as5812_54x_cpld_read(0x60, reg); } static int accton_as5812_54x_led_write_value(u8 reg, u8 value) { - return as5812_54x_i2c_cpld_write(0x60, reg, value); + return as5812_54x_cpld_write(0x60, reg, value); } static void accton_as5812_54x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c index 2703897f..9d52e544 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c @@ -44,7 +44,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_serial_number(struct device *dev, struct device_attribute *da,char *buf); static int as5812_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg); static int as5812_54x_psu_model_name_get(struct device *dev , int get_serial); /* Addresses scanned @@ -406,7 +406,7 @@ static struct as5812_54x_psu_data *as5812_54x_psu_update_device(struct device *d /* Read psu status */ - status = as5812_54x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as5812_54x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -426,20 +426,9 @@ exit: return data; } -static int __init as5812_54x_psu_init(void) -{ - return i2c_add_driver(&as5812_54x_psu_driver); -} - -static void __exit as5812_54x_psu_exit(void) -{ - i2c_del_driver(&as5812_54x_psu_driver); -} +module_i2c_driver(as5812_54x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5812_54x_psu driver"); MODULE_LICENSE("GPL"); -module_init(as5812_54x_psu_init); -module_exit(as5812_54x_psu_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c deleted file mode 100644 index 44727e22..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c +++ /dev/null @@ -1,508 +0,0 @@ -/* - * An hwmon driver for accton as5812_54x sfp - * - * Copyright (C) 2015 Accton Technology Corporation. - * Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_OF_SFP_PORT 54 -#define BIT_INDEX(i) (1ULL << (i)) - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* Each client has this additional data - */ -struct as5812_54x_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u64 status[4]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => is_present - 1 => tx_fail - 2 => tx_disable - 3 => rx_loss */ -}; - -/* The table maps active port to cpld port. - * Array index 0 is for active port 1, - * index 1 for active port 2, and so on. - * The array content implies cpld port index. - */ -static const u8 cpld_to_front_port_table[] = -{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 52, 50, 53, 51, 54}; - -#define CPLD_PORT_TO_FRONT_PORT(port) (cpld_to_front_port_table[port]) - -static struct as5812_54x_sfp_data *as5812_54x_sfp_update_device(struct device *dev, int update_eeprom); -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum as5812_54x_sfp_sysfs_attributes { - SFP_IS_PRESENT, - SFP_TX_FAULT, - SFP_TX_DISABLE, - SFP_RX_LOSS, - SFP_PORT_NUMBER, - SFP_EEPROM, - SFP_RX_LOS_ALL, - SFP_IS_PRESENT_ALL, -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_status, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, show_status, NULL, SFP_TX_FAULT); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, show_status, set_tx_disable, SFP_TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_rx_loss, S_IRUGO, show_status,NULL, SFP_RX_LOSS); -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, show_status,NULL, SFP_RX_LOS_ALL); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_status,NULL, SFP_IS_PRESENT_ALL); - -static struct attribute *as5812_54x_sfp_attributes[] = { - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - NULL -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as5812_54x_sfp_data *data; - u8 val; - int values[7]; - - /* Error-check the CPLD read results. */ -#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ - do { \ - _rv = (_read_expr); \ - if(_rv < 0) { \ - return sprintf(_buf, "READ ERROR\n"); \ - } \ - if(_invert) { \ - _rv = ~_rv; \ - } \ - _rv &= 0xFF; \ - } while(0) - - if(attr->index == SFP_RX_LOS_ALL) { - /* - * Report the RX_LOS status for all ports. - * This does not depend on the currently active SFP selector. - */ - - /* RX_LOS Ports 1-8 */ - VALIDATED_READ(buf, values[0], as5812_54x_i2c_cpld_read(0x61, 0x0F), 0); - /* RX_LOS Ports 9-16 */ - VALIDATED_READ(buf, values[1], as5812_54x_i2c_cpld_read(0x61, 0x10), 0); - /* RX_LOS Ports 17-24 */ - VALIDATED_READ(buf, values[2], as5812_54x_i2c_cpld_read(0x61, 0x11), 0); - /* RX_LOS Ports 25-32 */ - VALIDATED_READ(buf, values[3], as5812_54x_i2c_cpld_read(0x62, 0x0F), 0); - /* RX_LOS Ports 33-40 */ - VALIDATED_READ(buf, values[4], as5812_54x_i2c_cpld_read(0x62, 0x10), 0); - /* RX_LOS Ports 41-48 */ - VALIDATED_READ(buf, values[5], as5812_54x_i2c_cpld_read(0x62, 0x11), 0); - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - if(attr->index == SFP_IS_PRESENT_ALL) { - /* - * Report the SFP_PRESENCE status for all ports. - * This does not depend on the currently active SFP selector. - */ - - /* SFP_PRESENT Ports 1-8 */ - VALIDATED_READ(buf, values[0], as5812_54x_i2c_cpld_read(0x61, 0x6), 1); - /* SFP_PRESENT Ports 9-16 */ - VALIDATED_READ(buf, values[1], as5812_54x_i2c_cpld_read(0x61, 0x7), 1); - /* SFP_PRESENT Ports 17-24 */ - VALIDATED_READ(buf, values[2], as5812_54x_i2c_cpld_read(0x61, 0x8), 1); - /* SFP_PRESENT Ports 25-32 */ - VALIDATED_READ(buf, values[3], as5812_54x_i2c_cpld_read(0x62, 0x6), 1); - /* SFP_PRESENT Ports 33-40 */ - VALIDATED_READ(buf, values[4], as5812_54x_i2c_cpld_read(0x62, 0x7), 1); - /* SFP_PRESENT Ports 41-48 */ - VALIDATED_READ(buf, values[5], as5812_54x_i2c_cpld_read(0x62, 0x8), 1); - /* QSFP_PRESENT Ports 49-54 */ - VALIDATED_READ(buf, values[6], as5812_54x_i2c_cpld_read(0x62, 0x14), 1); - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - /* - * The remaining attributes are gathered on a per-selected-sfp basis. - */ - data = as5812_54x_sfp_update_device(dev, 0); - if (attr->index == SFP_IS_PRESENT) { - val = (data->status[attr->index] & BIT_INDEX(data->port)) ? 0 : 1; - } - else { - val = (data->status[attr->index] & BIT_INDEX(data->port)) ? 1 : 0; - } - - return sprintf(buf, "%d", val); -} - -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - - /* Tx disable is not supported for QSFP ports(49-54) */ - if (data->port >= 48) { - return -EINVAL; - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = 0x61; - cpld_reg = 0xC + data->port / 8; - cpld_bit = 1 << (data->port % 8); - } - else { - cpld_addr = 0x62; - cpld_reg = 0xC + (data->port - 24) / 8; - cpld_bit = 1 << (data->port % 8); - } - - cpld_val = as5812_54x_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->status[SFP_TX_DISABLE] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->status[SFP_TX_DISABLE] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - as5812_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct as5812_54x_sfp_data *data = as5812_54x_sfp_update_device(dev, 1); - - if (!data->valid) { - return 0; - } - - if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) != 0) { - return 0; - } - - memcpy(buf, data->eeprom, sizeof(data->eeprom)); - - return sizeof(data->eeprom); -} - -static const struct attribute_group as5812_54x_sfp_group = { - .attrs = as5812_54x_sfp_attributes, -}; - -static int as5812_54x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as5812_54x_sfp_data *data; - int status; - - extern int platform_accton_as5812_54x(void); - if(!platform_accton_as5812_54x()) { - return -ENODEV; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as5812_54x_sfp_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5812_54x_sfp_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as5812_54x_sfp_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as5812_54x_sfp_remove(struct i2c_client *client) -{ - struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as5812_54x_sfp_group); - kfree(data); - - return 0; -} - -enum port_numbers { -as5812_54x_sfp1, as5812_54x_sfp2, as5812_54x_sfp3, as5812_54x_sfp4, -as5812_54x_sfp5, as5812_54x_sfp6, as5812_54x_sfp7, as5812_54x_sfp8, -as5812_54x_sfp9, as5812_54x_sfp10, as5812_54x_sfp11,as5812_54x_sfp12, -as5812_54x_sfp13, as5812_54x_sfp14, as5812_54x_sfp15,as5812_54x_sfp16, -as5812_54x_sfp17, as5812_54x_sfp18, as5812_54x_sfp19,as5812_54x_sfp20, -as5812_54x_sfp21, as5812_54x_sfp22, as5812_54x_sfp23,as5812_54x_sfp24, -as5812_54x_sfp25, as5812_54x_sfp26, as5812_54x_sfp27,as5812_54x_sfp28, -as5812_54x_sfp29, as5812_54x_sfp30, as5812_54x_sfp31,as5812_54x_sfp32, -as5812_54x_sfp33, as5812_54x_sfp34, as5812_54x_sfp35,as5812_54x_sfp36, -as5812_54x_sfp37, as5812_54x_sfp38, as5812_54x_sfp39,as5812_54x_sfp40, -as5812_54x_sfp41, as5812_54x_sfp42, as5812_54x_sfp43,as5812_54x_sfp44, -as5812_54x_sfp45, as5812_54x_sfp46, as5812_54x_sfp47,as5812_54x_sfp48, -as5812_54x_sfp49, as5812_54x_sfp52, as5812_54x_sfp50,as5812_54x_sfp53, -as5812_54x_sfp51, as5812_54x_sfp54 -}; - -static const struct i2c_device_id as5812_54x_sfp_id[] = { -{ "as5812_54x_sfp1", as5812_54x_sfp1 }, { "as5812_54x_sfp2", as5812_54x_sfp2 }, -{ "as5812_54x_sfp3", as5812_54x_sfp3 }, { "as5812_54x_sfp4", as5812_54x_sfp4 }, -{ "as5812_54x_sfp5", as5812_54x_sfp5 }, { "as5812_54x_sfp6", as5812_54x_sfp6 }, -{ "as5812_54x_sfp7", as5812_54x_sfp7 }, { "as5812_54x_sfp8", as5812_54x_sfp8 }, -{ "as5812_54x_sfp9", as5812_54x_sfp9 }, { "as5812_54x_sfp10", as5812_54x_sfp10 }, -{ "as5812_54x_sfp11", as5812_54x_sfp11 }, { "as5812_54x_sfp12", as5812_54x_sfp12 }, -{ "as5812_54x_sfp13", as5812_54x_sfp13 }, { "as5812_54x_sfp14", as5812_54x_sfp14 }, -{ "as5812_54x_sfp15", as5812_54x_sfp15 }, { "as5812_54x_sfp16", as5812_54x_sfp16 }, -{ "as5812_54x_sfp17", as5812_54x_sfp17 }, { "as5812_54x_sfp18", as5812_54x_sfp18 }, -{ "as5812_54x_sfp19", as5812_54x_sfp19 }, { "as5812_54x_sfp20", as5812_54x_sfp20 }, -{ "as5812_54x_sfp21", as5812_54x_sfp21 }, { "as5812_54x_sfp22", as5812_54x_sfp22 }, -{ "as5812_54x_sfp23", as5812_54x_sfp23 }, { "as5812_54x_sfp24", as5812_54x_sfp24 }, -{ "as5812_54x_sfp25", as5812_54x_sfp25 }, { "as5812_54x_sfp26", as5812_54x_sfp26 }, -{ "as5812_54x_sfp27", as5812_54x_sfp27 }, { "as5812_54x_sfp28", as5812_54x_sfp28 }, -{ "as5812_54x_sfp29", as5812_54x_sfp29 }, { "as5812_54x_sfp30", as5812_54x_sfp30 }, -{ "as5812_54x_sfp31", as5812_54x_sfp31 }, { "as5812_54x_sfp32", as5812_54x_sfp32 }, -{ "as5812_54x_sfp33", as5812_54x_sfp33 }, { "as5812_54x_sfp34", as5812_54x_sfp34 }, -{ "as5812_54x_sfp35", as5812_54x_sfp35 }, { "as5812_54x_sfp36", as5812_54x_sfp36 }, -{ "as5812_54x_sfp37", as5812_54x_sfp37 }, { "as5812_54x_sfp38", as5812_54x_sfp38 }, -{ "as5812_54x_sfp39", as5812_54x_sfp39 }, { "as5812_54x_sfp40", as5812_54x_sfp40 }, -{ "as5812_54x_sfp41", as5812_54x_sfp41 }, { "as5812_54x_sfp42", as5812_54x_sfp42 }, -{ "as5812_54x_sfp43", as5812_54x_sfp43 }, { "as5812_54x_sfp44", as5812_54x_sfp44 }, -{ "as5812_54x_sfp45", as5812_54x_sfp45 }, { "as5812_54x_sfp46", as5812_54x_sfp46 }, -{ "as5812_54x_sfp47", as5812_54x_sfp47 }, { "as5812_54x_sfp48", as5812_54x_sfp48 }, -{ "as5812_54x_sfp49", as5812_54x_sfp49 }, { "as5812_54x_sfp50", as5812_54x_sfp50 }, -{ "as5812_54x_sfp51", as5812_54x_sfp51 }, { "as5812_54x_sfp52", as5812_54x_sfp52 }, -{ "as5812_54x_sfp53", as5812_54x_sfp53 }, { "as5812_54x_sfp54", as5812_54x_sfp54 }, - -{} -}; -MODULE_DEVICE_TABLE(i2c, as5812_54x_sfp_id); - -static struct i2c_driver as5812_54x_sfp_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as5812_54x_sfp", - }, - .probe = as5812_54x_sfp_probe, - .remove = as5812_54x_sfp_remove, - .id_table = as5812_54x_sfp_id, - .address_list = normal_i2c, -}; - -static int as5812_54x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data) -{ - int result = i2c_smbus_read_byte_data(client, command); - - if (unlikely(result < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); - goto abort; - } - - *data = (u8)result; - result = 0; - -abort: - return result; -} - -#define ALWAYS_UPDATE_DEVICE 1 - -static struct as5812_54x_sfp_data *as5812_54x_sfp_update_device(struct device *dev, int update_eeprom) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (ALWAYS_UPDATE_DEVICE || time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status = -1; - int i = 0, j = 0; - - data->valid = 0; - //dev_dbg(&client->dev, "Starting as5812_54x sfp status update\n"); - memset(data->status, 0, sizeof(data->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 12; j++) { - status = as5812_54x_i2c_cpld_read(0x61+i, 0x6+j); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - goto exit; - } - - data->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* - * Bring QSFPs out of reset, - * This is a temporary fix until the QSFP+_MOD_RST register - * can be exposed through the driver. - */ - as5812_54x_i2c_cpld_write(0x62, 0x15, 0x3F); - - /* Read present status of port 49-54(QSFP port) */ - status = as5812_54x_i2c_cpld_read(0x62, 0x14); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); - } - else { - data->status[SFP_IS_PRESENT] |= (u64)status << 48; - } - - if (update_eeprom) { - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) == 0) { - /* read eeprom */ - for (i = 0; i < sizeof(data->eeprom); i++) { - status = as5812_54x_sfp_read_byte(client, i, data->eeprom + i); - - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", - CPLD_PORT_TO_FRONT_PORT(data->port)); - goto exit; - } - } - } - } - - data->valid = 1; - data->last_updated = jiffies; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} - -module_i2c_driver(as5812_54x_sfp_driver); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5812_54x_sfp driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c index 6cfa29a9..f731e0d3 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c @@ -24,20 +24,24 @@ * ***********************************************************/ #include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include #include -#include "platform_lib.h" +#include +#include "x86_64_accton_as5812_54x_int.h" +#include "x86_64_accton_as5812_54x_log.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; #define CPLD_MUX_BUS_START_INDEX 2 -static int front_port_to_cpld_mux_index(int port) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/0-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_present_all" +#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_rx_los_all" + +static int front_port_bus_index(int port) { int rport = 0; @@ -63,38 +67,6 @@ static int front_port_to_cpld_mux_index(int port) return (rport + CPLD_MUX_BUS_START_INDEX); } -static int -as5812_54x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8] = {0}; - *value = 0; - - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as5812_54x_sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - front_port_to_cpld_mux_index(port), addr, - node_name); - return sfp_node_path; -} - -static char* -as5812_54x_sfp_get_port_path(int port, char *node_name) -{ - return as5812_54x_sfp_get_port_path_addr(port, 50, node_name); -} - - /************************************************************ * * SFPI Entry Points @@ -203,10 +175,10 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as5812_54x_sfp_get_port_path(port, "sfp_is_present"); - - if (as5812_54x_sfp_node_read_int(path, &present, 1) != 0) { - AIM_LOG_INFO("Unable to read present status from port(%d)\r\n", port); + int addr = (port < 24) ? 61 : 62; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -217,29 +189,35 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[7]; - char* path; FILE* fp; - path = as5812_54x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); - + /* Read present status of port 0~23 */ + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD2."); return ONLP_STATUS_E_INTERNAL; } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); + + int count = fscanf(fp, "%x %x %x", bytes+0, bytes+1, bytes+2); fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { + if(count != 3) { /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD2."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Read present status of port 24~53 */ + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + count = fscanf(fp, "%x %x %x %x", bytes+3, bytes+4, bytes+5, bytes+6); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); return ONLP_STATUS_E_INTERNAL; } @@ -268,33 +246,39 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char* path; + uint32_t bytes[6]; + uint32_t *ptr = bytes; FILE* fp; - path = as5812_54x_sfp_get_port_path(0, "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 61; addr <= 62; addr++) { + if (addr == 61) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; @@ -315,18 +299,22 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as5812_54x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, front_port_bus_index(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -336,11 +324,26 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - char* path = as5812_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, front_port_bus_index(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); return ONLP_STATUS_E_INTERNAL; } @@ -350,28 +353,28 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) { - int bus = front_port_to_cpld_mux_index(port); + int bus = front_port_bus_index(port); return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } @@ -384,13 +387,13 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) return ONLP_STATUS_E_UNSUPPORTED; } + int addr = (port < 24) ? 61 : 62; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - char* path = as5812_54x_sfp_get_port_path(port, "sfp_tx_disable"); - - if (deviceNodeWriteInt(path, value, 0) != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -412,19 +415,18 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; - char* path = NULL; if (port < 0 || port >= 48) { return ONLP_STATUS_E_UNSUPPORTED; } + int addr = (port < 24) ? 61 : 62; + switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - path = as5812_54x_sfp_get_port_path(port, "sfp_rx_loss"); - - if (as5812_54x_sfp_node_read_int(path, value, 1) != 0) { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -436,9 +438,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - path = as5812_54x_sfp_get_port_path(port, "sfp_tx_fault"); - - if (as5812_54x_sfp_node_read_int(path, value, 1) != 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -450,9 +450,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - path = as5812_54x_sfp_get_port_path(port, "sfp_tx_disable"); - - if (as5812_54x_sfp_node_read_int(path, value, 0) != 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py index 5eee6748..b6505028 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py @@ -9,9 +9,10 @@ class OnlPlatform_x86_64_accton_as5812_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5812.54.1" def baseconfig(self): + self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: self.insmod("x86-64-accton-as5812-54x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -26,16 +27,18 @@ class OnlPlatform_x86_64_accton_as5812_54x_r0(OnlPlatformAccton, ) # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5812_54x_sfp%d' % port, 0x50, port+1) - self.new_i2c_device('as5812_54x_sfp%d' % port, 0x51, port+1) + self.new_i2c_device('optoe2', 0x50, port+1) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) # Initialize QSFP devices - self.new_i2c_device('as5812_54x_sfp49', 0x50, 50) - self.new_i2c_device('as5812_54x_sfp52', 0x50, 51) - self.new_i2c_device('as5812_54x_sfp50', 0x50, 52) - self.new_i2c_device('as5812_54x_sfp53', 0x50, 53) - self.new_i2c_device('as5812_54x_sfp51', 0x50, 54) - self.new_i2c_device('as5812_54x_sfp54', 0x50, 55) + for port in range(49, 55): + self.new_i2c_device('optoe1', 0x50, port+1) + subprocess.call('echo port49 > /sys/bus/i2c/devices/50-0050/port_name', shell=True) + subprocess.call('echo port52 > /sys/bus/i2c/devices/51-0050/port_name', shell=True) + subprocess.call('echo port50 > /sys/bus/i2c/devices/52-0050/port_name', shell=True) + subprocess.call('echo port53 > /sys/bus/i2c/devices/53-0050/port_name', shell=True) + subprocess.call('echo port51 > /sys/bus/i2c/devices/54-0050/port_name', shell=True) + subprocess.call('echo port54 > /sys/bus/i2c/devices/55-0050/port_name', shell=True) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From f258852eb425bafb873122163090fb78f571524a Mon Sep 17 00:00:00 2001 From: cytsai0409 Date: Tue, 20 Mar 2018 11:39:07 +0800 Subject: [PATCH 190/244] [ingrasys s9100] platform driver update --- .../x86_64_ingrasys_s9100/module/src/fani.c | 75 +++++++++++++---- .../x86_64_ingrasys_s9100/module/src/ledi.c | 82 ++++++++++++++++++- .../module/src/platform_lib.c | 70 +++++++++++++++- .../module/src/platform_lib.h | 19 +++++ .../x86_64_ingrasys_s9100/module/src/psui.c | 4 +- .../x86_64_ingrasys_s9100/module/src/sysi.c | 74 ++++++++++++++--- .../x86_64_ingrasys_s9100_r0/__init__.py | 75 +++++++++++++++++ 7 files changed, 365 insertions(+), 34 deletions(-) diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/fani.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/fani.c index 921b3ffa..66f33b16 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/fani.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/fani.c @@ -25,6 +25,7 @@ #include #include "x86_64_ingrasys_s9100_int.h" #include +#include #include "platform_lib.h" onlp_fan_info_t fan_info[] = { @@ -111,12 +112,67 @@ onlp_fani_init(void) return ONLP_STATUS_OK; } +/* get fan present status*/ +int sys_fan_present_get(onlp_fan_info_t* info, int id) +{ + int rv, fan_presence, i2c_bus, offset, fan_reg_mask; + + /* get fan presence*/ + i2c_bus = I2C_BUS_9; + switch (id) + { + case FAN_ID_FAN1: + case FAN_ID_FAN2: + offset = 0; + fan_reg_mask = FAN_1_2_PRESENT_MASK; + break; + case FAN_ID_FAN3: + case FAN_ID_FAN4: + offset = 0; + fan_reg_mask = FAN_3_4_PRESENT_MASK; + break; + case FAN_ID_FAN5: + case FAN_ID_FAN6: + offset = 1; + fan_reg_mask = FAN_5_6_PRESENT_MASK; + break; + case FAN_ID_FAN7: + case FAN_ID_FAN8: + offset = 1; + fan_reg_mask = FAN_7_8_PRESENT_MASK; + break; + default: + return ONLP_STATUS_E_INVALID; + } + + rv = onlp_i2c_readb(i2c_bus, FAN_REG, offset, ONLP_I2C_F_FORCE); + if (rv < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + fan_presence = (rv & fan_reg_mask) ? 0 : 1; + + if (!fan_presence) { + info->status &= ~ONLP_FAN_STATUS_PRESENT; + } else { + info->status |= ONLP_FAN_STATUS_PRESENT; + } + + return ONLP_STATUS_OK; +} + int sys_fan_info_get(onlp_fan_info_t* info, int id) { int rv, fan_status, fan_rpm, perc_val, percentage; + int max_fan_speed = 16000; fan_status = 0; fan_rpm = 0; + + rv = sys_fan_present_get(info, id); + if (rv < 0) { + return ONLP_STATUS_E_INTERNAL; + } rv = onlp_file_read_int(&fan_status, SYS_FAN_PREFIX "fan%d_alarm", id); if (rv < 0) { @@ -157,21 +213,8 @@ sys_fan_info_get(onlp_fan_info_t* info, int id) return ONLP_STATUS_E_INTERNAL; } - /* - Get fan speed, converting driver value to percnet. - Value 128 is 50%. - Value 200 is 80%. - Value 255 is 100%. - */ - if (perc_val == 255) { - percentage = 100; - } else if (perc_val == 200) { - percentage = 80; - } else if (perc_val == 128) { - percentage = 50; - } else { - return ONLP_STATUS_E_INTERNAL; - } + percentage = (info->rpm*100)/max_fan_speed; + info->percentage = percentage; return ONLP_STATUS_OK; @@ -280,4 +323,4 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) return rc; } - \ No newline at end of file + diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/ledi.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/ledi.c index 306ab37b..b694ca2e 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/ledi.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/ledi.c @@ -55,9 +55,36 @@ static onlp_led_info_t led_info[] = { LED_OID_PSU2, "Chassis LED 4 (PSU2 LED)", 0 }, ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + }, + { + { LED_OID_FAN_TRAY1, "Rear LED 1 (FAN TRAY1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + }, + { + { LED_OID_FAN_TRAY2, "Rear LED 2 (FAN TRAY2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + }, + { + { LED_OID_FAN_TRAY3, "Rear LED 3 (FAN TRAY3 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + }, + { + { LED_OID_FAN_TRAY4, "Rear LED 4 (FAN TRAY4 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, } + }; +extern int sys_fan_info_get(onlp_fan_info_t* info, int id); + /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -70,13 +97,56 @@ onlp_ledi_init(void) int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { - int led_id; + int led_id, pw_exist, pw_good, rc, psu_mask, fan_id; + onlp_fan_info_t fan_info; + memset(&fan_info, 0, sizeof(onlp_fan_info_t)); led_id = ONLP_OID_ID_GET(id); *info = led_info[led_id]; - info->status |= ONLP_LED_STATUS_ON; - info->mode |= ONLP_LED_MODE_ON; + + if (id == LED_OID_PSU1 || id == LED_OID_PSU2) { + if (id == LED_OID_PSU1) { + psu_mask = PSU1_MUX_MASK; + } else { + psu_mask = PSU2_MUX_MASK; + } + /* check psu status */ + if ((rc = psu_present_get(&pw_exist, I2C_BUS_0, psu_mask)) != ONLP_STATUS_OK) { + return ONLP_STATUS_E_INTERNAL; + } + if ((rc = psu_pwgood_get(&pw_good, I2C_BUS_0, psu_mask)) != ONLP_STATUS_OK) { + return ONLP_STATUS_E_INTERNAL; + } + /* psu not present */ + if (pw_exist != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_LED_STATUS_ON; + info->mode = ONLP_LED_MODE_OFF; + } else if (pw_good != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_ORANGE; + } else { + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_GREEN; + } + } else if (id == LED_OID_FAN) { + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_GREEN; + for (fan_id=FAN_ID_FAN1; fan_id<=FAN_ID_FAN8; ++fan_id) { + rc = sys_fan_info_get(&fan_info, fan_id); + if (rc != ONLP_STATUS_OK || fan_info.status & ONLP_FAN_STATUS_FAILED) { + info->mode &= ~ONLP_LED_MODE_GREEN; + info->mode |= ONLP_LED_MODE_ORANGE; + break; + } + } + } else if (id == LED_OID_SYSTEM) { + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_GREEN; + } else { + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_ON; + } return ONLP_STATUS_OK; } @@ -125,6 +195,12 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) case LED_PSU2_LED: rc = psu2_led_set(mode); break; + case LED_FAN_TRAY1: + case LED_FAN_TRAY2: + case LED_FAN_TRAY3: + case LED_FAN_TRAY4: + rc = fan_tray_led_set(id, mode); + break; default: return ONLP_STATUS_E_INTERNAL; break; diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.c index 172b7f13..43d2b965 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.c @@ -70,8 +70,11 @@ psu_thermal_get(onlp_thermal_info_t* info, int thermal_id) if (pw_exist != PSU_STATUS_PRESENT) { info->mcelsius = 0; + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; return ONLP_STATUS_OK; - } + } else { + info->status |= ONLP_THERMAL_STATUS_PRESENT; + } if ((rc = psu_pwgood_get(&pw_good, I2C_BUS_0, psu_mask)) != ONLP_STATUS_OK) { return ONLP_STATUS_E_INTERNAL; @@ -126,7 +129,10 @@ psu_fan_info_get(onlp_fan_info_t* info, int id) if (pw_exist != PSU_STATUS_PRESENT) { info->rpm = 0; + info->status &= ~ONLP_FAN_STATUS_PRESENT; return ONLP_STATUS_OK; + } else { + info->status |= ONLP_FAN_STATUS_PRESENT; } if ((rc = psu_pwgood_get(&pw_good, I2C_BUS_0, psu_mask)) != ONLP_STATUS_OK) { @@ -472,6 +478,10 @@ psu1_led_set(onlp_led_mode_t mode) rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, LED_PSU1_AND_MASK, LED_PSU1_YMASK, ONLP_I2C_F_FORCE); + } else if(mode == ONLP_LED_MODE_OFF) { + rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, + LED_PSU1_AND_MASK, LED_PSU1_OFFMASK, + ONLP_I2C_F_FORCE); } else { return ONLP_STATUS_E_INTERNAL; } @@ -495,6 +505,10 @@ psu2_led_set(onlp_led_mode_t mode) rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, LED_PSU2_AND_MASK, LED_PSU2_YMASK, ONLP_I2C_F_FORCE); + } else if(mode == ONLP_LED_MODE_OFF) { + rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, + LED_PSU2_AND_MASK, LED_PSU2_OFFMASK, + ONLP_I2C_F_FORCE); } else { return ONLP_STATUS_E_INTERNAL; } @@ -507,6 +521,60 @@ psu2_led_set(onlp_led_mode_t mode) return ONLP_STATUS_OK; } +int +fan_tray_led_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int rc, temp_id; + int fan_tray_id, offset; +char cmd[256]; +memset(cmd, 0, sizeof(cmd)); + + temp_id = ONLP_OID_ID_GET(id); + switch (temp_id) { + case 5: + fan_tray_id = 1; + offset = 2; + break; + case 6: + fan_tray_id = 2; + offset = 2; + break; + case 7: + fan_tray_id = 3; + offset = 3; + break; + case 8: + fan_tray_id = 4; + offset = 3; + break; + default: + return ONLP_STATUS_E_INTERNAL; + break; + } + if (fan_tray_id == 1 || fan_tray_id == 3) { + if (mode == ONLP_LED_MODE_GREEN) { + rc = onlp_i2c_modifyb(I2C_BUS_9, FAN_REG, offset, 0xFC, + 0x01, ONLP_I2C_F_FORCE); + } else if (mode == ONLP_LED_MODE_ORANGE) { + rc = onlp_i2c_modifyb(I2C_BUS_9, FAN_REG, offset, 0xFC, + 0x02, ONLP_I2C_F_FORCE); + } + } else if (fan_tray_id == 2 || fan_tray_id == 4) { + if (mode == ONLP_LED_MODE_GREEN) { + rc = onlp_i2c_modifyb(I2C_BUS_9, FAN_REG, offset, 0xCF, + 0x10, ONLP_I2C_F_FORCE); + } else if (mode == ONLP_LED_MODE_ORANGE) { + rc = onlp_i2c_modifyb(I2C_BUS_9, FAN_REG, offset, 0xCF, + 0x20, ONLP_I2C_F_FORCE); + } + } + if (rc < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + int sysi_platform_info_get(onlp_platform_info_t* pi) { diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.h b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.h index c06d2de9..e9f44ed6 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.h +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/platform_lib.h @@ -111,9 +111,11 @@ #define LED_PSU1_AND_MASK 0xFC #define LED_PSU1_GMASK 0x01 #define LED_PSU1_YMASK 0x02 +#define LED_PSU1_OFFMASK 0x03 #define LED_PSU2_AND_MASK 0xCF #define LED_PSU2_GMASK 0x10 #define LED_PSU2_YMASK 0x20 +#define LED_PSU2_OFFMASK 0x30 /* SYS */ #define CPLD_REG 0x33 @@ -125,12 +127,23 @@ #define QSFP_PRES_OFFSET1 0x00 #define QSFP_PRES_OFFSET2 0x01 +/* FAN */ +#define FAN_REG 0x20 +#define FAN_1_2_PRESENT_MASK 0x04 +#define FAN_3_4_PRESENT_MASK 0x40 +#define FAN_5_6_PRESENT_MASK 0x04 +#define FAN_7_8_PRESENT_MASK 0x40 + /** led_oid */ typedef enum led_oid_e { LED_OID_SYSTEM = ONLP_LED_ID_CREATE(1), LED_OID_FAN = ONLP_LED_ID_CREATE(2), LED_OID_PSU1 = ONLP_LED_ID_CREATE(3), LED_OID_PSU2 = ONLP_LED_ID_CREATE(4), + LED_OID_FAN_TRAY1 = ONLP_LED_ID_CREATE(5), + LED_OID_FAN_TRAY2 = ONLP_LED_ID_CREATE(6), + LED_OID_FAN_TRAY3 = ONLP_LED_ID_CREATE(7), + LED_OID_FAN_TRAY4 = ONLP_LED_ID_CREATE(8), } led_oid_t; /** led_id */ @@ -139,6 +152,10 @@ typedef enum led_id_e { LED_FAN_LED = 2, LED_PSU1_LED = 3, LED_PSU2_LED = 4, + LED_FAN_TRAY1 = 5, + LED_FAN_TRAY2 = 6, + LED_FAN_TRAY3 = 7, + LED_FAN_TRAY4 = 8, } led_id_t; /** Thermal_oid */ @@ -241,6 +258,8 @@ int fan_led_set(onlp_led_mode_t mode); int system_led_set(onlp_led_mode_t mode); +int fan_tray_led_set(onlp_oid_t id, onlp_led_mode_t mode); + int sysi_platform_info_get(onlp_platform_info_t* pi); int qsfp_present_get(int port, int *pres_val); diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/psui.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/psui.c index 496bc1ea..52f0d92f 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/psui.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/psui.c @@ -93,6 +93,8 @@ psu_status_info_get(int id, onlp_psu_info_t *info) if (pw_good != PSU_STATUS_POWER_GOOD) { info->status |= ONLP_PSU_STATUS_UNPLUGGED; return ONLP_STATUS_OK; + } else { + info->status &= ~ONLP_PSU_STATUS_UNPLUGGED; } /* Get power eeprom status */ @@ -147,4 +149,4 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) return ONLP_STATUS_OK; -} \ No newline at end of file +} diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/sysi.c b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/sysi.c index 20c65b24..f748eb9c 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/sysi.c +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/onlp/builds/src/x86_64_ingrasys_s9100/module/src/sysi.c @@ -197,13 +197,18 @@ _EXIT : int onlp_sysi_platform_manage_leds(void) { - int psu1_status, psu2_status, rc, i, tmp_fan_status; + int psu1_status, psu2_status, rc, i; + int fan_tray_id, sum, total = 0; static int pre_psu1_status = 0, pre_psu2_status = 0, pre_fan_status = 0; + static int pre_fan_tray_status[4] = {0}; onlp_psu_info_t psu_info; onlp_fan_info_t fan_info; + onlp_led_status_t fan_tray_status[SYS_FAN_NUM]; + memset(&psu_info, 0, sizeof(onlp_psu_info_t)); memset(&fan_info, 0, sizeof(onlp_fan_info_t)); + memset(&fan_tray_status, 0, sizeof(fan_tray_status)); uint32_t fan_arr[] = { FAN_OID_FAN1, FAN_OID_FAN2, FAN_OID_FAN3, @@ -213,6 +218,7 @@ onlp_sysi_platform_manage_leds(void) FAN_OID_FAN7, FAN_OID_FAN8, }; + /* PSU LED CTRL */ if ((rc = onlp_psui_info_get(PSU_OID_PSU1, &psu_info)) != ONLP_STATUS_OK) { goto _EXIT; @@ -220,7 +226,10 @@ onlp_sysi_platform_manage_leds(void) psu1_status = psu_info.status; if (psu1_status != pre_psu1_status) { - if(psu1_status != ONLP_PSU_STATUS_PRESENT) { + if((psu1_status & ONLP_PSU_STATUS_PRESENT) == 0) { + rc = onlp_ledi_mode_set(LED_OID_PSU1, ONLP_LED_MODE_OFF); + } + else if(psu1_status != ONLP_PSU_STATUS_PRESENT) { rc = onlp_ledi_mode_set(LED_OID_PSU1, ONLP_LED_MODE_ORANGE); } else { rc = onlp_ledi_mode_set(LED_OID_PSU1, ONLP_LED_MODE_GREEN); @@ -238,7 +247,10 @@ onlp_sysi_platform_manage_leds(void) psu2_status = psu_info.status; if( psu2_status != pre_psu2_status) { - if(psu2_status != ONLP_PSU_STATUS_PRESENT) { + if((psu2_status & ONLP_PSU_STATUS_PRESENT) == 0) { + rc = onlp_ledi_mode_set(LED_OID_PSU2, ONLP_LED_MODE_OFF); + } + else if(psu2_status != ONLP_PSU_STATUS_PRESENT) { rc = onlp_ledi_mode_set(LED_OID_PSU2, ONLP_LED_MODE_ORANGE); } else { rc = onlp_ledi_mode_set(LED_OID_PSU2, ONLP_LED_MODE_GREEN); @@ -251,29 +263,65 @@ onlp_sysi_platform_manage_leds(void) } /* FAN LED CTRL */ - tmp_fan_status = ONLP_LED_STATUS_PRESENT; + for (i=0; i ONLP_LED_STATUS_FAILED) { + rc = onlp_ledi_mode_set(fan_tray_id, ONLP_LED_MODE_ORANGE); + } else { + rc = onlp_ledi_mode_set(fan_tray_id, ONLP_LED_MODE_GREEN); + } - if(fan_info.status != ONLP_LED_STATUS_PRESENT) { - tmp_fan_status = fan_info.status; + if (rc != ONLP_STATUS_OK) { + goto _EXIT; + } + + pre_fan_tray_status[fan_tray_id - 5] = sum; + } } - } + } - if (tmp_fan_status != pre_fan_status) { - if (tmp_fan_status != ONLP_LED_STATUS_PRESENT) { - rc = onlp_ledi_mode_set(LED_OID_FAN, ONLP_LED_MODE_ORANGE); - } else { + if (total != pre_fan_status) { + if (total == (ONLP_LED_STATUS_PRESENT * 8)) { rc = onlp_ledi_mode_set(LED_OID_FAN, ONLP_LED_MODE_GREEN); + } else { + rc = onlp_ledi_mode_set(LED_OID_FAN, ONLP_LED_MODE_ORANGE); } - + if (rc != ONLP_STATUS_OK) { goto _EXIT; } + + pre_fan_status = total; } - pre_fan_status = fan_info.status; _EXIT : return rc; diff --git a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py index cba0b0fe..3a808108 100755 --- a/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py +++ b/packages/platforms/ingrasys/x86-64/x86-64-ingrasys-s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py @@ -365,6 +365,38 @@ class OnlPlatform_x86_64_ingrasys_s9100_r0(OnlPlatformIngrasys): os.system("echo out > /sys/class/gpio/gpio413/direction") os.system("echo out > /sys/class/gpio/gpio414/direction") os.system("echo out > /sys/class/gpio/gpio415/direction") + os.system("echo 1 > /sys/class/gpio/gpio400/active_low") + os.system("echo 1 > /sys/class/gpio/gpio401/active_low") + os.system("echo 1 > /sys/class/gpio/gpio402/active_low") + os.system("echo 1 > /sys/class/gpio/gpio403/active_low") + os.system("echo 1 > /sys/class/gpio/gpio404/active_low") + os.system("echo 1 > /sys/class/gpio/gpio405/active_low") + os.system("echo 1 > /sys/class/gpio/gpio406/active_low") + os.system("echo 1 > /sys/class/gpio/gpio407/active_low") + os.system("echo 1 > /sys/class/gpio/gpio408/active_low") + os.system("echo 1 > /sys/class/gpio/gpio409/active_low") + os.system("echo 1 > /sys/class/gpio/gpio410/active_low") + os.system("echo 1 > /sys/class/gpio/gpio411/active_low") + os.system("echo 1 > /sys/class/gpio/gpio412/active_low") + os.system("echo 1 > /sys/class/gpio/gpio413/active_low") + os.system("echo 1 > /sys/class/gpio/gpio414/active_low") + os.system("echo 1 > /sys/class/gpio/gpio415/active_low") + os.system("echo 0 > /sys/class/gpio/gpio400/value") + os.system("echo 0 > /sys/class/gpio/gpio401/value") + os.system("echo 0 > /sys/class/gpio/gpio402/value") + os.system("echo 0 > /sys/class/gpio/gpio403/value") + os.system("echo 0 > /sys/class/gpio/gpio404/value") + os.system("echo 0 > /sys/class/gpio/gpio405/value") + os.system("echo 0 > /sys/class/gpio/gpio406/value") + os.system("echo 0 > /sys/class/gpio/gpio407/value") + os.system("echo 0 > /sys/class/gpio/gpio408/value") + os.system("echo 0 > /sys/class/gpio/gpio409/value") + os.system("echo 0 > /sys/class/gpio/gpio410/value") + os.system("echo 0 > /sys/class/gpio/gpio411/value") + os.system("echo 0 > /sys/class/gpio/gpio412/value") + os.system("echo 0 > /sys/class/gpio/gpio413/value") + os.system("echo 0 > /sys/class/gpio/gpio414/value") + os.system("echo 0 > /sys/class/gpio/gpio415/value") # initialize RST Port 16-31 self.new_i2c_device('pca9535', 0x23, 7) @@ -400,6 +432,38 @@ class OnlPlatform_x86_64_ingrasys_s9100_r0(OnlPlatformIngrasys): os.system("echo out > /sys/class/gpio/gpio397/direction") os.system("echo out > /sys/class/gpio/gpio398/direction") os.system("echo out > /sys/class/gpio/gpio399/direction") + os.system("echo 1 > /sys/class/gpio/gpio384/active_low") + os.system("echo 1 > /sys/class/gpio/gpio385/active_low") + os.system("echo 1 > /sys/class/gpio/gpio386/active_low") + os.system("echo 1 > /sys/class/gpio/gpio387/active_low") + os.system("echo 1 > /sys/class/gpio/gpio388/active_low") + os.system("echo 1 > /sys/class/gpio/gpio389/active_low") + os.system("echo 1 > /sys/class/gpio/gpio390/active_low") + os.system("echo 1 > /sys/class/gpio/gpio391/active_low") + os.system("echo 1 > /sys/class/gpio/gpio392/active_low") + os.system("echo 1 > /sys/class/gpio/gpio393/active_low") + os.system("echo 1 > /sys/class/gpio/gpio394/active_low") + os.system("echo 1 > /sys/class/gpio/gpio395/active_low") + os.system("echo 1 > /sys/class/gpio/gpio396/active_low") + os.system("echo 1 > /sys/class/gpio/gpio397/active_low") + os.system("echo 1 > /sys/class/gpio/gpio398/active_low") + os.system("echo 1 > /sys/class/gpio/gpio399/active_low") + os.system("echo 0 > /sys/class/gpio/gpio384/value") + os.system("echo 0 > /sys/class/gpio/gpio385/value") + os.system("echo 0 > /sys/class/gpio/gpio386/value") + os.system("echo 0 > /sys/class/gpio/gpio387/value") + os.system("echo 0 > /sys/class/gpio/gpio388/value") + os.system("echo 0 > /sys/class/gpio/gpio389/value") + os.system("echo 0 > /sys/class/gpio/gpio390/value") + os.system("echo 0 > /sys/class/gpio/gpio391/value") + os.system("echo 0 > /sys/class/gpio/gpio392/value") + os.system("echo 0 > /sys/class/gpio/gpio393/value") + os.system("echo 0 > /sys/class/gpio/gpio394/value") + os.system("echo 0 > /sys/class/gpio/gpio395/value") + os.system("echo 0 > /sys/class/gpio/gpio396/value") + os.system("echo 0 > /sys/class/gpio/gpio397/value") + os.system("echo 0 > /sys/class/gpio/gpio398/value") + os.system("echo 0 > /sys/class/gpio/gpio399/value") # initialize MODSEL Port 0-15 self.new_i2c_device('pca9535', 0x24, 7) @@ -491,6 +555,17 @@ class OnlPlatform_x86_64_ingrasys_s9100_r0(OnlPlatformIngrasys): os.system("i2cset -m 0x40 -y -r 9 0x22 2 0xFF") os.system("i2cset -m 0x80 -y -r 9 0x22 2 0x00") + # init CPLD LED_CLR Register (Switch Port LED) + os.system("i2cset -y 0 0x33 0x34 0x10") + + # init Fan I/O Exanpler + os.system("i2cset -y -r 9 0x20 4 0x00") + os.system("i2cset -y -r 9 0x20 5 0x00") + os.system("i2cset -y -r 9 0x20 2 0x00") + os.system("i2cset -y -r 9 0x20 3 0x00") + os.system("i2cset -y -r 9 0x20 6 0xCC") + os.system("i2cset -y -r 9 0x20 7 0xCC") + return True From f24caec55af1cd2d2ae71126b20ec23e464a5c87 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Tue, 20 Mar 2018 11:43:44 +0800 Subject: [PATCH 191/244] [as6812-32x] Add support for OOM --- .../builds/x86-64-accton-as6812-32x-cpld.c | 621 +++++-- .../builds/x86-64-accton-as6812-32x-fan.c | 13 +- .../builds/x86-64-accton-as6812-32x-leds.c | 13 +- .../builds/x86-64-accton-as6812-32x-psu.c | 16 +- .../builds/x86-64-accton-as6812-32x-sfp.c | 1532 ----------------- .../onlp/builds/src/module/src/sfpi.c | 95 +- .../x86_64_accton_as6812_32x_r0/__init__.py | 8 +- 7 files changed, 536 insertions(+), 1762 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c index 6c146767..b42e5c2a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c @@ -33,44 +33,28 @@ #include #include #include -#include #include +#include +#include +#include -static struct dmi_system_id as6812_dmi_table[] = { - { - .ident = "Accton AS6812", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS6812"), - }, - }, - { - .ident = "Accton AS6812", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Accton"), - DMI_MATCH(DMI_PRODUCT_NAME, "AS6812"), - }, - }, -}; - -int platform_accton_as6812_32x(void) -{ - return dmi_check_system(as6812_dmi_table); -} -EXPORT_SYMBOL(platform_accton_as6812_32x); +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x10 #define NUM_OF_CPLD3_CHANS 0x10 -#define NUM_OF_ALL_CPLD_CHANS (NUM_OF_CPLD2_CHANS + NUM_OF_CPLD3_CHANS) -#define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS +#define CPLD_CHANNEL_SELECT_REG 0x2 +#define CPLD_DESELECT_CHANNEL 0xFF + +#define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; +static struct mutex list_lock; struct cpld_client_node { - struct i2c_client *client; - struct list_head list; + struct i2c_client *client; + struct list_head list; }; enum cpld_mux_type { @@ -79,10 +63,13 @@ enum cpld_mux_type { as6812_32x_cpld1 }; -struct accton_i2c_cpld_mux { - enum cpld_mux_type type; - struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; - u8 last_chan; /* last register value */ +struct as6812_32x_cpld_data { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ + + struct device *hwmon_dev; + struct mutex update_lock; }; struct chip_desc { @@ -106,18 +93,289 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { +static const struct i2c_device_id as6812_32x_cpld_mux_id[] = { { "as6812_32x_cpld1", as6812_32x_cpld1 }, { "as6812_32x_cpld2", as6812_32x_cpld2 }, { "as6812_32x_cpld3", as6812_32x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); +MODULE_DEVICE_TABLE(i2c, as6812_32x_cpld_mux_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as6812_32x_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as6812_32x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as6812_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); + +static struct attribute *as6812_32x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as6812_32x_cpld1_group = { + .attrs = as6812_32x_cpld1_attributes, +}; + +static struct attribute *as6812_32x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + NULL +}; + +static const struct attribute_group as6812_32x_cpld2_group = { + .attrs = as6812_32x_cpld2_attributes, +}; + +static struct attribute *as6812_32x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + NULL +}; + +static const struct attribute_group as6812_32x_cpld3_group = { + .attrs = as6812_32x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[2] = {0}; + u8 regs[] = {0xA, 0xB}; + struct i2c_client *client = to_i2c_client(dev); + struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as6812_32x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x\n", values[0], values[1]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as6812_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + default: + return 0; + } + + mutex_lock(&data->update_lock); + status = as6812_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as6812_32x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, u8 val) +static int as6812_32x_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) { unsigned long orig_jiffies; unsigned short flags; @@ -134,8 +392,8 @@ static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, orig_jiffies = jiffies; for (res = 0, try = 0; try <= adap->retries; try++) { res = adap->algo->smbus_xfer(adap, client->addr, flags, - I2C_SMBUS_WRITE, 0x2, - I2C_SMBUS_BYTE_DATA, &data); + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); if (res != -EAGAIN) break; if (time_after(jiffies, @@ -147,35 +405,35 @@ static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, return res; } -static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) +static int as6812_32x_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); u8 regval; int ret = 0; regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); + ret = as6812_32x_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int as6812_32x_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); + return as6812_32x_cpld_mux_reg_write(adap, client, data->last_chan); } -static void accton_i2c_cpld_add_client(struct i2c_client *client) +static void as6812_32x_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -191,7 +449,7 @@ static void accton_i2c_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void accton_i2c_cpld_remove_client(struct i2c_client *client) +static void as6812_32x_cpld_remove_client(struct i2c_client *client) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -217,177 +475,250 @@ static void accton_i2c_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) { - u8 reg = 0x1; - struct i2c_client *client; - int len; + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); - client = to_i2c_client(dev); - len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); - - return len; + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); } -static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); - /* * I2C init/probing/exit functions */ -static int accton_i2c_cpld_mux_probe(struct i2c_client *client, +static int as6812_32x_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct accton_i2c_cpld_mux *data; + struct as6812_32x_cpld_data *data; int ret = -ENODEV; + const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; + goto exit; - data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); + data = kzalloc(sizeof(struct as6812_32x_cpld_data), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto err; + goto exit; } i2c_set_clientdata(client, data); - + mutex_init(&data->update_lock); data->type = id->driver_data; - if (data->type == as6812_32x_cpld2 || data->type == as6812_32x_cpld3) { - data->last_chan = chips[data->type].deselectChan; /* force the first selection */ + if (data->type == as6812_32x_cpld2 || data->type == as6812_32x_cpld3) { + data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ - for (chan = 0; chan < chips[data->type].nchans; chan++) { - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) - I2C_CLASS_HWMON | I2C_CLASS_SPD, -#endif - accton_i2c_cpld_mux_select_chan, - accton_i2c_cpld_mux_deselect_mux); + /* Now create an adapter for each channel */ + for (chan = 0; chan < chips[data->type].nchans; chan++) { + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, + as6812_32x_cpld_mux_select_chan, + as6812_32x_cpld_mux_deselect_mux); - if (data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto virt_reg_failed; - } - } + if (data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); + goto exit_mux_register; + } + } - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); - } + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); + } - accton_i2c_cpld_add_client(client); + /* Register sysfs hooks */ + switch (data->type) { + case as6812_32x_cpld1: + group = &as6812_32x_cpld1_group; + break; + case as6812_32x_cpld2: + group = &as6812_32x_cpld2_group; + break; + case as6812_32x_cpld3: + group = &as6812_32x_cpld3_group; + break; + default: + break; + } - ret = sysfs_create_file(&client->dev.kobj, &ver.attr); - if (ret) - goto virt_reg_failed; + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_mux_register; + } + } - return 0; + as6812_32x_cpld_add_client(client); -virt_reg_failed: + return 0; + +exit_mux_register: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); - } - kfree(data); -err: + } + kfree(data); +exit: return ret; +} + +static int as6812_32x_cpld_mux_remove(struct i2c_client *client) +{ + struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); + const struct chip_desc *chip = &chips[data->type]; + int chan; + const struct attribute_group *group = NULL; + + as6812_32x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as6812_32x_cpld1: + group = &as6812_32x_cpld1_group; + break; + case as6812_32x_cpld2: + group = &as6812_32x_cpld2_group; + break; + case as6812_32x_cpld3: + group = &as6812_32x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + for (chan = 0; chan < chip->nchans; ++chan) { + if (data->virt_adaps[chan]) { + i2c_del_mux_adapter(data->virt_adaps[chan]); + data->virt_adaps[chan] = NULL; + } + } + + kfree(data); + + return 0; } -static int accton_i2c_cpld_mux_remove(struct i2c_client *client) +static int as6812_32x_cpld_read_internal(struct i2c_client *client, u8 reg) { - struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); - const struct chip_desc *chip = &chips[data->type]; - int chan; + int status = 0, retry = I2C_RW_RETRY_COUNT; - sysfs_remove_file(&client->dev.kobj, &ver.attr); - - for (chan = 0; chan < chip->nchans; ++chan) { - if (data->virt_adaps[chan]) { - i2c_del_mux_adapter(data->virt_adaps[chan]); - data->virt_adaps[chan] = NULL; + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; } + + break; } - kfree(data); - accton_i2c_cpld_remove_client(client); - - return 0; + return status; } -int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) +static int as6812_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) { - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; + int status = 0, retry = I2C_RW_RETRY_COUNT; - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; } + + break; } + return status; +} + +int as6812_32x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as6812_32x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + mutex_unlock(&list_lock); - return ret; + return ret; } -EXPORT_SYMBOL(as6812_32x_i2c_cpld_read); +EXPORT_SYMBOL(as6812_32x_cpld_read); -int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +int as6812_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) { - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; mutex_lock(&list_lock); - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } - } + if (cpld_node->client->addr == cpld_addr) { + ret = as6812_32x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } mutex_unlock(&list_lock); - return ret; + return ret; } -EXPORT_SYMBOL(as6812_32x_i2c_cpld_write); +EXPORT_SYMBOL(as6812_32x_cpld_write); -static struct i2c_driver accton_i2c_cpld_mux_driver = { +static struct i2c_driver as6812_32x_cpld_mux_driver = { .driver = { .name = "as6812_32x_cpld", .owner = THIS_MODULE, }, - .probe = accton_i2c_cpld_mux_probe, - .remove = accton_i2c_cpld_mux_remove, - .id_table = accton_i2c_cpld_mux_id, + .probe = as6812_32x_cpld_mux_probe, + .remove = as6812_32x_cpld_mux_remove, + .id_table = as6812_32x_cpld_mux_id, }; -static int __init accton_i2c_cpld_mux_init(void) +static int __init as6812_32x_cpld_mux_init(void) { - mutex_init(&list_lock); - return i2c_add_driver(&accton_i2c_cpld_mux_driver); + mutex_init(&list_lock); + return i2c_add_driver(&as6812_32x_cpld_mux_driver); } -static void __exit accton_i2c_cpld_mux_exit(void) +static void __exit as6812_32x_cpld_mux_exit(void) { - i2c_del_driver(&accton_i2c_cpld_mux_driver); + i2c_del_driver(&as6812_32x_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(accton_i2c_cpld_mux_init); -module_exit(accton_i2c_cpld_mux_exit); +module_init(as6812_32x_cpld_mux_init); +module_exit(as6812_32x_cpld_mux_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c index f0555674..7e5567df 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c @@ -137,8 +137,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as6812_32x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as6812_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -257,12 +257,12 @@ static const struct attribute_group accton_as6812_32x_fan_group = { static int accton_as6812_32x_fan_read_value(u8 reg) { - return as6812_32x_i2c_cpld_read(0x60, reg); + return as6812_32x_cpld_read(0x60, reg); } static int accton_as6812_32x_fan_write_value(u8 reg, u8 value) { - return as6812_32x_i2c_cpld_write(0x60, reg, value); + return as6812_32x_cpld_write(0x60, reg, value); } static void accton_as6812_32x_fan_update_device(struct device *dev) @@ -385,11 +385,6 @@ static struct platform_driver accton_as6812_32x_fan_driver = { static int __init accton_as6812_32x_fan_init(void) { int ret; - - extern int platform_accton_as6812_32x(void); - if(!platform_accton_as6812_32x()) { - return -ENODEV; - } ret = platform_driver_register(&accton_as6812_32x_fan_driver); if (ret < 0) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c index fd54ce06..691af597 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as6812_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as6812_32x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as6812_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -239,12 +239,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as6812_32x_led_read_value(u8 reg) { - return as6812_32x_i2c_cpld_read(0x60, reg); + return as6812_32x_cpld_read(0x60, reg); } static int accton_as6812_32x_led_write_value(u8 reg, u8 value) { - return as6812_32x_i2c_cpld_write(0x60, reg, value); + return as6812_32x_cpld_write(0x60, reg, value); } static void accton_as6812_32x_led_update(void) @@ -571,11 +571,6 @@ static int __init accton_as6812_32x_led_init(void) { int ret; - extern int platform_accton_as6812_32x(void); - if(!platform_accton_as6812_32x()) { - return -ENODEV; - } - ret = platform_driver_register(&accton_as6812_32x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c index a782870e..40d86b1c 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c @@ -44,7 +44,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_serial_number(struct device *dev, struct device_attribute *da,char *buf); static int as6812_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as6812_32x_cpld_read(unsigned short cpld_addr, u8 reg); static int as6812_32x_psu_model_name_get(struct device *dev, int get_serial); /* Addresses scanned @@ -415,7 +415,7 @@ static struct as6812_32x_psu_data *as6812_32x_psu_update_device(struct device *d data->valid = 0; /* Read psu status */ - status = as6812_32x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as6812_32x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -435,19 +435,9 @@ exit: return data; } -static int __init as6812_32x_psu_init(void) -{ - return i2c_add_driver(&as6812_32x_psu_driver); -} - -static void __exit as6812_32x_psu_exit(void) -{ - i2c_del_driver(&as6812_32x_psu_driver); -} +module_i2c_driver(as6812_32x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as6812_32x_psu driver"); MODULE_LICENSE("GPL"); -module_init(as6812_32x_psu_init); -module_exit(as6812_32x_psu_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c deleted file mode 100644 index 362d87db..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c +++ /dev/null @@ -1,1532 +0,0 @@ -/* - * SFP driver for accton as6812_32x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as6812_32x_sfp" - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 32 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define MULTIPAGE_SUPPORT 1 - -#if (MULTIPAGE_SUPPORT == 1) -/* fundamental unit of addressing for SFF_8472/SFF_8436 */ -#define SFF_8436_PAGE_SIZE 128 -/* - * The current 8436 (QSFP) spec provides for only 4 supported - * pages (pages 0-3). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8436_SPECED_PAGES 4 -#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) -/* - * The current 8472 (SFP) spec provides for only 3 supported - * pages (pages 0-2). - * This driver is prepared to support more, but needs a register in the - * EEPROM to indicate how many pages are supported before it is safe - * to implement more pages in the driver. - */ -#define SFF_8472_SPECED_PAGES 3 -#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) -#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) - -/* a few constants to find our way around the EEPROM */ -#define SFF_8436_PAGE_SELECT_REG 0x7F -#define SFF_8436_PAGEABLE_REG 0x02 -#define SFF_8436_NOT_PAGEABLE (1<<2) -#define SFF_8472_PAGEABLE_REG 0x40 -#define SFF_8472_PAGEABLE (1<<4) - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = SFF_8436_PAGE_SIZE; - -/* - * specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; - -typedef enum qsfp_opcode { - QSFP_READ_OP = 0, - QSFP_WRITE_OP = 1 -} qsfp_opcode_e; -#endif - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int as6812_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as6812_32x_port1, as6812_32x_port2, as6812_32x_port3, as6812_32x_port4, as6812_32x_port5, as6812_32x_port6, as6812_32x_port7, as6812_32x_port8, -as6812_32x_port9, as6812_32x_port10, as6812_32x_port11, as6812_32x_port12, as6812_32x_port13, as6812_32x_port14, as6812_32x_port15, as6812_32x_port16, -as6812_32x_port17, as6812_32x_port18, as6812_32x_port19, as6812_32x_port20, as6812_32x_port21, as6812_32x_port22, as6812_32x_port23, as6812_32x_port24, -as6812_32x_port25, as6812_32x_port26, as6812_32x_port27, as6812_32x_port28, as6812_32x_port29, as6812_32x_port30, as6812_32x_port31, as6812_32x_port32 -}; - -#define I2C_DEV_ID(x) { #x, x} - -static const struct i2c_device_id sfp_device_id[] = { -I2C_DEV_ID(as6812_32x_port1), -I2C_DEV_ID(as6812_32x_port2), -I2C_DEV_ID(as6812_32x_port3), -I2C_DEV_ID(as6812_32x_port4), -I2C_DEV_ID(as6812_32x_port5), -I2C_DEV_ID(as6812_32x_port6), -I2C_DEV_ID(as6812_32x_port7), -I2C_DEV_ID(as6812_32x_port8), -I2C_DEV_ID(as6812_32x_port9), -I2C_DEV_ID(as6812_32x_port10), -I2C_DEV_ID(as6812_32x_port11), -I2C_DEV_ID(as6812_32x_port12), -I2C_DEV_ID(as6812_32x_port13), -I2C_DEV_ID(as6812_32x_port14), -I2C_DEV_ID(as6812_32x_port15), -I2C_DEV_ID(as6812_32x_port16), -I2C_DEV_ID(as6812_32x_port17), -I2C_DEV_ID(as6812_32x_port18), -I2C_DEV_ID(as6812_32x_port19), -I2C_DEV_ID(as6812_32x_port20), -I2C_DEV_ID(as6812_32x_port21), -I2C_DEV_ID(as6812_32x_port22), -I2C_DEV_ID(as6812_32x_port23), -I2C_DEV_ID(as6812_32x_port24), -I2C_DEV_ID(as6812_32x_port25), -I2C_DEV_ID(as6812_32x_port26), -I2C_DEV_ID(as6812_32x_port27), -I2C_DEV_ID(as6812_32x_port28), -I2C_DEV_ID(as6812_32x_port29), -I2C_DEV_ID(as6812_32x_port30), -I2C_DEV_ID(as6812_32x_port31), -I2C_DEV_ID(as6812_32x_port32), -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct qsfp_data *qsfp; - - struct i2c_client *client; -#if (MULTIPAGE_SUPPORT == 1) - int use_smbus; - u8 *writebuf; - unsigned write_max; -#endif -}; - -#if (MULTIPAGE_SUPPORT == 1) -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); -#endif -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - - /* Read present status of port 1~32 */ - data->present = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - status = as6812_32x_i2c_cpld_read(0x62+i*2, 0xA+j); - - if (status < 0) { - DEBUG_PRINT("cpld(0x%x) reg(0x%x) err %d", 0x62+i*2, 0xA+j, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); - data->present |= (u64)status << ((i*16) + (j*8)); - } - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -/* Platform dependent --- */ - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ -} - -/* Platform dependent +++ */ -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[4] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3]); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - if (disable) { - data->qsfp->status[1] |= 0xF; - } - else { - data->qsfp->status[1] &= ~0xF; - } - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -#if (MULTIPAGE_SUPPORT == 0) -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} -#endif - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); -#else - return sfp_port_write(data, buf, off, count); -#endif -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -/*-------------------------------------------------------------------------*/ -/* - * This routine computes the addressing information to be used for - * a given r/w request. - * - * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), - * the page, and the offset. - * - * Handles both SFP and QSFP. - * For SFP, offset 0-255 are on client[0], >255 is on client[1] - * Offset 256-383 are on the lower half of client[1] - * Pages are accessible on the upper half of client[1]. - * Offset >383 are in 128 byte pages mapped into the upper half - * - * For QSFP, all offsets are on client[0] - * offset 0-127 are on the lower half of client[0] (no paging) - * Pages are accessible on the upper half of client[1]. - * Offset >127 are in 128 byte pages mapped into the upper half - * - * Callers must not read/write beyond the end of a client or a page - * without recomputing the client/page. Hence offset (within page) - * plus length must be less than or equal to 128. (Note that this - * routine does not have access to the length of the call, hence - * cannot do the validity check.) - * - * Offset within Lower Page 00h and Upper Page 00h are not recomputed - */ -static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, - loff_t *offset, struct i2c_client **client) -{ - unsigned page = 0; - - *client = port_data->client; - - /* - * if offset is in the range 0-128... - * page doesn't matter (using lower half), return 0. - * offset is already correct (don't add 128 to get to paged area) - */ - if (*offset < SFF_8436_PAGE_SIZE) - return page; - - /* note, page will always be positive since *offset >= 128 */ - page = (*offset >> 7)-1; - /* 0x80 places the offset in the top half, offset is last 7 bits */ - *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); - - return page; /* note also returning client and offset */ -} - -static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, - struct i2c_client *client, - char *buf, unsigned offset, size_t count) -{ - struct i2c_msg msg[2]; - u8 msgbuf[2]; - unsigned long timeout, read_time; - int status, i; - - memset(msg, 0, sizeof(msg)); - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* - * When we have a better choice than SMBus calls, use a - * combined I2C message. Write address; then read up to - * io_limit data bytes. msgbuf is u8 and will cast to our - * needs. - */ - i = 0; - msgbuf[i++] = offset; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = i; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].buf = buf; - msg[1].len = count; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - read_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_read_i2c_block_data(client, offset, - count, buf); - break; - case I2C_SMBUS_WORD_DATA: - status = i2c_smbus_read_word_data(client, offset); - if (status >= 0) { - buf[0] = status & 0xff; - if (count == 2) - buf[1] = status >> 8; - status = count; - } - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_read_byte_data(client, offset); - if (status >= 0) { - buf[0] = status; - status = count; - } - break; - default: - status = i2c_transfer(client->adapter, msg, 2); - if (status == 2) - status = count; - } - - dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); - - if (status == count) /* happy path */ - return count; - - if (status == -ENXIO) /* no module present */ - return status; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(read_time, timeout)); - - return -ETIMEDOUT; -} - -static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, - struct i2c_client *client, - const char *buf, - unsigned offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned next_page_start; - int i = 0; - - /* write max is at most a page - * (In this driver, write_max is actually one byte!) - */ - if (count > port_data->write_max) - count = port_data->write_max; - - /* shorten count if necessary to avoid crossing page boundary */ - next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); - if (offset + count > next_page_start) - count = next_page_start - offset; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - /*smaller eeproms can work given some SMBus extension calls */ - if (count > I2C_SMBUS_BLOCK_MAX) - count = I2C_SMBUS_BLOCK_MAX; - break; - case I2C_SMBUS_WORD_DATA: - /* Check for odd length transaction */ - count = (count == 1) ? 1 : 2; - break; - case I2C_SMBUS_BYTE_DATA: - count = 1; - break; - default: - /* If we'll use I2C calls for I/O, set up the message */ - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = port_data->writebuf; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - break; - } - - /* - * Reads fail if the previous write didn't complete yet. We may - * loop a few times until this one succeeds, waiting at least - * long enough for one entire page write to work. - */ - timeout = jiffies + msecs_to_jiffies(write_timeout); - do { - write_time = jiffies; - - switch (port_data->use_smbus) { - case I2C_SMBUS_I2C_BLOCK_DATA: - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - break; - case I2C_SMBUS_WORD_DATA: - if (count == 2) { - status = i2c_smbus_write_word_data(client, - offset, (u16)((buf[0])|(buf[1] << 8))); - } else { - /* count = 1 */ - status = i2c_smbus_write_byte_data(client, - offset, buf[0]); - } - if (status == 0) - status = count; - break; - case I2C_SMBUS_BYTE_DATA: - status = i2c_smbus_write_byte_data(client, offset, - buf[0]); - if (status == 0) - status = count; - break; - default: - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - break; - } - - dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", - count, offset, (long int) status, jiffies); - - if (status == count) - return count; - - /* REVISIT: at HZ=100, this is sloooow */ - msleep(1); - } while (time_before(write_time, timeout)); - - return -ETIMEDOUT; -} - - -static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, - char *buf, loff_t off, - size_t count, qsfp_opcode_e opcode) -{ - struct i2c_client *client; - ssize_t retval = 0; - u8 page = 0; - loff_t phy_offset = off; - int ret = 0; - - page = sff_8436_translate_offset(port_data, &phy_offset, &client); - - dev_dbg(&client->dev, - "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - off, page, phy_offset, (long int) count, opcode); - if (page > 0) { - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_dbg(&client->dev, - "Write page register for page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - - while (count) { - ssize_t status; - - if (opcode == QSFP_READ_OP) { - status = sff_8436_eeprom_read(port_data, client, - buf, phy_offset, count); - } else { - status = sff_8436_eeprom_write(port_data, client, - buf, phy_offset, count); - } - if (status <= 0) { - if (retval == 0) - retval = status; - break; - } - buf += status; - phy_offset += status; - count -= status; - retval += status; - } - - - if (page > 0) { - /* return the page register to page 0 (why?) */ - page = 0; - ret = sff_8436_eeprom_write(port_data, client, &page, - SFF_8436_PAGE_SELECT_REG, 1); - if (ret < 0) { - dev_err(&client->dev, - "Restore page register to page %d failed ret:%d!\n", - page, ret); - return ret; - } - } - return retval; -} - - -/* - * Figure out if this access is within the range of supported pages. - * Note this is called on every access because we don't know if the - * module has been replaced since the last call. - * If/when modules support more pages, this is the routine to update - * to validate and allow access to additional pages. - * - * Returns updated len for this access: - * - entire access is legal, original len is returned. - * - access begins legal but is too long, len is truncated to fit. - * - initial offset exceeds supported pages, return -EINVAL - */ -static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, - loff_t off, size_t len) -{ - struct i2c_client *client = port_data->client; - u8 regval; - int status; - size_t maxlen; - - if (off < 0) return -EINVAL; - if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { - /* SFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8472_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8472_PAGEABLE) { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8472_EEPROM_SIZE - off; - } else { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, SFP, off %lld len %ld\n", - off, (long int) len); - } - else if (port_data->driver_type == DRIVER_TYPE_QSFP) { - /* QSFP case */ - /* if no pages needed, we're good */ - if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; - /* in between, are pages supported? */ - status = sff_8436_eeprom_read(port_data, client, ®val, - SFF_8436_PAGEABLE_REG, 1); - if (status < 0) return status; /* error out (no module?) */ - if (regval & SFF_8436_NOT_PAGEABLE) { - /* pages not supported, trim len to unpaged size */ - maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; - } else { - /* Pages supported, trim len to the end of pages */ - maxlen = SFF_8436_EEPROM_SIZE - off; - } - len = (len > maxlen) ? maxlen : len; - dev_dbg(&client->dev, - "page_legal, QSFP, off %lld len %ld\n", - off, (long int) len); - } - else { - return -EINVAL; - } - return len; -} - - -static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, - char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) -{ - struct i2c_client *client = port_data->client; - int chunk; - int status = 0; - ssize_t retval; - size_t pending_len = 0, chunk_len = 0; - loff_t chunk_offset = 0, chunk_start_offset = 0; - - if (unlikely(!len)) - return len; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&port_data->update_lock); - - /* - * Confirm this access fits within the device suppored addr range - */ - len = sff_8436_page_legal(port_data, off, len); - if (len < 0) { - status = len; - goto err; - } - - /* - * For each (128 byte) chunk involved in this request, issue a - * separate call to sff_eeprom_update_client(), to - * ensure that each access recalculates the client/page - * and writes the page register as needed. - * Note that chunk to page mapping is confusing, is different for - * QSFP and SFP, and never needs to be done. Don't try! - */ - pending_len = len; /* amount remaining to transfer */ - retval = 0; /* amount transferred */ - for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { - - /* - * Compute the offset and number of bytes to be read/write - * - * 1. start at offset 0 (within the chunk), and read/write - * the entire chunk - * 2. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 3. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 4. start at an offset not equal to 0 and read/write less than - * (end of chunk - offset) - */ - chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < (chunk_start_offset + - SFF_8436_PAGE_SIZE)) - chunk_len = pending_len; - else - chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ - } else { - chunk_offset = chunk_start_offset; - if (pending_len > SFF_8436_PAGE_SIZE) - chunk_len = SFF_8436_PAGE_SIZE; - else - chunk_len = pending_len; - } - - dev_dbg(&client->dev, - "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", - off, (long int) len, chunk_start_offset, chunk_offset, - (long int) chunk_len, (long int) pending_len); - - /* - * note: chunk_offset is from the start of the EEPROM, - * not the start of the chunk - */ - status = sff_8436_eeprom_update_client(port_data, buf, - chunk_offset, chunk_len, opcode); - if (status != chunk_len) { - /* This is another 'no device present' path */ - dev_dbg(&client->dev, - "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - goto err; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&port_data->update_lock); - - return retval; - -err: - mutex_unlock(&port_data->update_lock); - - return status; -} - -#else -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} -#endif - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - -#if (MULTIPAGE_SUPPORT == 1) - return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); -#else - return sfp_port_read(data, buf, off, count); -#endif -} - -#if (MULTIPAGE_SUPPORT == 1) -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) -#else -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -#endif -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; -#if (MULTIPAGE_SUPPORT == 1) - eeprom->size = size; -#else - eeprom->size = EEPROM_SIZE; -#endif - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - - -#if (MULTIPAGE_SUPPORT == 0) -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} -#endif - - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - -#if (MULTIPAGE_SUPPORT == 0) - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } -#endif - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ -#if (MULTIPAGE_SUPPORT == 1) - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); -#else - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); -#endif - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int ret = 0; - struct sfp_port_data *data = NULL; - - if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { - return -ENODEV; - } - - if (dev_id->driver_data < as6812_32x_port1 || dev_id->driver_data > as6812_32x_port32) { - return -ENXIO; - } - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - -#if (MULTIPAGE_SUPPORT == 1) - data->use_smbus = 0; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - data->use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - data->use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - ret = -EPFNOSUPPORT; - goto exit_kfree; - } - } - - if (!data->use_smbus || - (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_WORD_DATA) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - /* - * NOTE: AN-2079 - * Finisar recommends that the host implement 1 byte writes - * only since this module only supports 32 byte page boundaries. - * 2 byte writes are acceptable for PE and Vout changes per - * Application Note AN-2071. - */ - unsigned write_max = 1; - - if (write_max > io_limit) - write_max = io_limit; - if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - data->write_max = write_max; - - /* buffer (data + address at the beginning) */ - data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); - if (!data->writebuf) { - ret = -ENOMEM; - goto exit_kfree; - } - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - - if (data->use_smbus == I2C_SMBUS_WORD_DATA || - data->use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", data->use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } -#endif - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - data->driver_type = DRIVER_TYPE_QSFP; - - ret = qsfp_probe(client, dev_id, &data->qsfp); - if (ret < 0) { - goto exit_kfree_buf; - } - - return ret; - -exit_kfree_buf: -#if (MULTIPAGE_SUPPORT == 1) - if (data->writebuf) kfree(data->writebuf); -#endif - -exit_kfree: - kfree(data); - return ret; -} -/* Platform dependent --- */ - -static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - int ret = 0; - struct sfp_port_data *data = i2c_get_clientdata(client); -#if (MULTIPAGE_SUPPORT == 1) - kfree(data->writebuf); -#endif - - if (data->driver_type == DRIVER_TYPE_QSFP) { - ret = qsfp_remove(client, data->qsfp); - } - - kfree(data); - return ret; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as6812_32x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(sfp_init); -module_exit(sfp_exit); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c index 10288992..20a5a884 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c @@ -24,35 +24,17 @@ * ***********************************************************/ #include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include - -#include "platform_lib.h" +#include #include +#include "x86_64_accton_as6812_32x_int.h" +#include "x86_64_accton_as6812_32x_log.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_TO_CPLD_MUX_INDEX(port) (port+2) +#define PORT_BUS_INDEX(port) (port+2) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0062/module_present_all" +#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0064/module_present_all" -static int -as6812_32x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - return onlp_file_read_int(value, node_path); -} - -static char* -as6812_32x_sfp_get_port_path(int port, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", - FRONT_PORT_TO_CPLD_MUX_INDEX(port), - node_name); - - return sfp_node_path; -} /************************************************************ * @@ -91,12 +73,13 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as6812_32x_sfp_get_port_path(port, "sfp_is_present"); - - if (as6812_32x_sfp_node_read_int(path, &present, 1) != 0) { + int addr = (port < 16) ? 62 : 64; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + return present; } @@ -104,27 +87,34 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; - char* path; + uint32_t *ptr = bytes; FILE* fp; - path = as6812_32x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~31 */ + int addr; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 62; addr <= 64; addr+=2) { + if (addr == 62) { + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x", ptr+0, ptr+1); + fclose(fp); + if(count != 2) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_present_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ @@ -153,21 +143,25 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as6812_32x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } @@ -176,3 +170,4 @@ onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py index 43c9b7d8..115f08b9 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py @@ -8,9 +8,10 @@ class OnlPlatform_x86_64_accton_as6812_32x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".6812.32" def baseconfig(self): + self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: self.insmod("x86-64-accton-as6812-32x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -25,9 +26,8 @@ class OnlPlatform_x86_64_accton_as6812_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 for port in range(1, 33): - self.new_i2c_device('as6812_32x_port%d' % port, - 0x50, - port+1) + self.new_i2c_device('optoe1', 0x50, port+1) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From c3fb9e5abe94cecf4d492419ccbb5f6bf31a48a2 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Tue, 20 Mar 2018 05:39:51 +0000 Subject: [PATCH 192/244] Updating SupportedHardware.md to match new HCL --- docs/SupportedHardware.md | 183 ++++++++++++++++++++------------------ 1 file changed, 95 insertions(+), 88 deletions(-) diff --git a/docs/SupportedHardware.md b/docs/SupportedHardware.md index 4e0e2b0f..658ee98b 100644 --- a/docs/SupportedHardware.md +++ b/docs/SupportedHardware.md @@ -1,107 +1,114 @@ Hardware Support ================ -Because of the HTML formatting, this page may be best viewed from - - - -Quanta ------- - - - - - - - - - - -
Device Ports CPU Forwarding ONL Certified In Lab OF-DPA OpenNSL SAI
QuantaMesh T1048-LB9 48x1G + 4x10G FreeScale P2020 Broadcom BCM56534 (Firebolt3) Yes Yes No No No
QuantaMesh T3048-LY2 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes Yes No No No
QuantaMesh T3048-LY8 48x10G + 6x40G Intel Rangeley C2758 x86 Broadcom BCM56854 (Trident2) Yes Yes No No No
QuantaMesh T5032-LY6 32x40G Intel Rangeley C2758 x86 Broadcom BCM56850 (Trident2) Yes Yes No No No
QuantaMesh T3048-LY9 48x10GT + 6x40G Intel Rangeley C2758 x86 Broadcom BCM56850 (Trident2) Yes Yes No No No
- Accton/Edge-Core ------ - - - - - - - - - - - - - - - - - - - - -
Device Ports CPU Forwarding ONL Certified In Lab OF-DPA OpenNSL SAI
Accton AS4600-54T 48x1G + 4x10G FreeScale P2020 Broadcom BCM56540 (Apollo2) Yes Yes Yes*** Yes*** No
Accton AS4610-54P 48x1G + 4x10G + 2x20G Dual-core ARM Cortex A9 1GHz Broadcom BCM56340 (Helix4) Yes Yes No No No
Accton AS5610-52X 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes Yes No No No
Accton AS5710-54X 48x10G + 6x40G FreeScale P2041 Broadcom BCM56854 (Trident2) Yes Yes Yes*** Yes*** No
Accton AS6700-32X 32x40G FreeScale P2041 Broadcom BCM56850 (Trident2) Yes Yes No No No
Accton AS5512-54X 48x10G + 6x40G Intel Rangeley C2538 x86 MediaTek/Nephos MT3258 Yes Yes No No No
Accton AS5712-54X 48x10G + 6x40G Intel Rangeley C2538 x86 Broadcom BCM56854 (Trident2) Yes Yes Yes*** Yes*** No
Accton AS6712-32X 32x40G Intel Rangeley C2538 x86 Broadcom BCM56850 (Trident2) Yes Yes Yes*** Yes*** No
Accton AS5812-54T 48x10G + 6x40G Intel Rangeley C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No No No
Accton AS5812-54X 48x10G + 6x40G Intel Rangeley C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes Yes*** Yes*** No
Accton AS6812-32X 32x40G Intel Rangeley C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes Yes*** Yes*** No
Accton AS7712-32X 32x100G Intel Rangeley C2538 x86 Broadcom BCM56960 (Tomahawk) Yes Yes Yes*** Yes*** No
Accton AS7716-32X 32x100G Intel Xeon D-1518 x86 Broadcom BCM56960 (Tomahawk) Yes Yes Yes*** Yes*** No
Accton Wedge-16X 16x40G Intel Rangeley C2550 x86 Broadcom BCM56864 (Trident2+) Work In Progress** Yes No Yes No
Accton (FB) Wedge 100 32x100G Intel Bay Trail E3845 x86 Broadcom BCM56960 (Tomahawk) Work In Progress** Yes No Yes No
+Device Ports CPU Forwarding In Lab +Accton AS4600-54T 48x1G + 4x10G FreeScale P2020 Broadcom BCM56540 (Apollo2) Yes +Accton AS4610-54P 48x1G + 4x10G + 2x20G Dual-core ARM Cortex A9 Broadcom BCM56340 (Helix4) Yes +Accton AS5512-54X 48x10G + 6x40G Intel C2538 MediaTek/Nephos MT3258 Yes +Accton AS5610-52X 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes +Accton AS5710-54X 48x10G + 6x40G FreeScale P2041 Broadcom BCM56854 (Trident2) Yes +Accton AS5712-54X 48x10G + 6x40G Intel C2538 Broadcom BCM56854 (Trident2) Yes +Accton AS5812-54T 48x10G + 6x40G Intel C2538 Broadcom BCM56864 (Trident2+) Yes +Accton AS5812-54X 48x10G + 6x40G Intel C2538 Broadcom BCM56864 (Trident2+) Yes +Accton AS5822-32X 48x10G + 6x100G Intel C2558 Broadcom BCM88375 (Qumran) Yes +Accton AS5912-54X 48x10G + 6x100G Intel C2558 Broadcom BCM88375 (Qumran) Yes +Accton AS5912-54XK 48x10G + 6x100G Intel C2558 Broadcom BCM88375 (Qumran) Yes +Accton AS5916-54XM 48x10G + 6x100G Intel C2558 Broadcom BCM88375 (Qumran) No +Accton AS5916-54X 48x10G + 6x100G Intel C2558 Broadcom BCM88375 (Qumran) No +Accton AS6700-32X 32x40G FreeScale P2041 Broadcom BCM56850 (Trident2) Yes +Accton AS6712-32X 32x40G Intel C2538 Broadcom BCM56850 (Trident2) Yes +Accton AS6812-32X 32x40G Intel C2538 Broadcom BCM56864 (Trident2+) Yes +Accton AS7312-54X 48x25G + 6x100G Intel C2558 Broadcom BCM88375 (Qumran) Yes +Accton AS7712-32X 32x100G Intel C2538 Broadcom BCM56960 (Tomahawk) Yes +Accton AS7716-32X 32x100G Intel Xeon D-1518 Broadcom BCM56960 (Tomahawk) Yes +Accton AS7816-64X 64x100 Intel C2558 Broadcom BCM56970 (Tomahawk II) Yes +Accton Wedge-16X 16x40G Intel C2550 Broadcom BCM56864 (Trident2+) Yes +Accton Wedge 100-32X 32x100G Intel E3845 Broadcom BCM56960 (Tomahawk) Yes +Accton Wedge 100S-32X 32x100G Intel D1508 Broadcom BCM56960 (Tomahawk) Yes + +Alpha Networks +--- +Device Ports CPU Forwarding In Lab +SNX-60A0-486F 48x10G + 6x40G Intel C2558 Broadcom BCM56850 (Trident2) Yes + +Celestica +--- +Device Ports CPU Forwarding In Lab +Redstone-XP 48x10G + 6x40G Intel C2558 Broadcom BCM56854 (Trident2) Yes +Seastone 32x100G Intel C2558 Broadcom BCM56960 (Tomahawk) No DNI/Agema --- - - - - - - -
Device Ports CPU Forwarding ONL Certified In Lab OF-DPA OpenNSL SAI
AG-7448CU 48x10G + 4x40G FreeScale P2020 Broadcom BCM56845 (Trident) Yes Yes No No No
+Device Ports CPU Forwarding In Lab +AG-7448CU 48x10G + 4x40G FreeScale P2020 Broadcom BCM56845 (Trident) Yes +AG-5648 48x25G + 6x100G Intel D1548 Broadcom BCM56960 (Tomahawk) No +AG-5648v1 48x25G + 6x100G Intel D1548 Broadcom BCM56963 (Tomahawk+) No +AG-7648 48x10G + 6x40G Intel D1548 Broadcom BCM56854 (Trident2) Yes +AG-9032v1 32x100G Intel D1548 Broadcom BCM56960 (Tomahawk) Yes +AG-9032v2 32x100G Intel D1548 Broadcom BCM56963 (Tomahawk+) No +AG-9064 64x100G Intel D1547 Broadcom BCM56970 (Tomahawk II) No +AGC-5648S 48x25G + 6x100G Intel D1548 Broadcom BCM88680 (Jericho+) No +AGC-7648A 48x10G + 6x100G Intel D1548 Broadcom BCM88370 (Qumran MX) No +WB-2448 48x1GT + 4x10G Intel E3805 Broadcom BCM56150 (Hurricane2) No +AG-6248C 48x1GT + 2x10G ARM A9 1GHz Broadcom BCM56340 (Helix4) Yes Dell --- - - - - - - - - - -
Device Ports CPU Forwarding ONL Certified In Lab OF-DPA OpenNSL SAI
S4810-ON 48x10G + 4x40G FreeScale P2020 Broadcom BCM56845 (Trident) Yes Yes No No No
S4048-ON 48x10G + 6x40G Intel Atom C2338 Broadcom BCM56854 (Trident2) Yes Yes No No No
S6000-ON 32x40G Intel Atom S1220 Broadcom BCM56850 (Trident2) Yes Yes No No No
Z9100-ON 32x100G Intel Atom C2538 Broadcom BCM56960 (Tomahawk) Yes Yes No No No
+Device Ports CPU Forwarding In Lab +S4000-ON 48x10G + 6x40G Intel C2338 Broadcom BCM56854 (Trident2) Yes +S4810-ON 48x10G + 4x40G FreeScale P2020 Broadcom BCM56845 (Trident) Yes +S4048-ON 48x10G + 6x40G Intel C2338 Broadcom BCM56854 (Trident2) Yes +S6000-ON 32x40G Intel S1220 Broadcom BCM56850 (Trident2) Yes +S6010-ON 32x40G Intel S1220 Broadcom BCM56850 (Trident2) Yes +S6100-ON 64x50G/128x25G Intel C2538 Broadcom BCM56960 (Tomahawk) Yes +Z9100-ON 32x100G Intel C2538 Broadcom BCM56960 (Tomahawk) Yes -Interface Masters Technologies, Inc. +HPE --- - - - - - - - - - - -
Device Ports CPU Forwarding ONL Certified In Lab OF-DPA OpenNSL SAI
Niagara 2948X12XLm 48x10G + 12x40G Intel/AMD x86 Broadcom BCM56850 (Trident2) Work In Progress** No Yes*** Yes*** No
Niagara 2960X6XLm 60x10G + 6x40G Intel/AMD x86 Broadcom BCM56850 (Trident2) Work In Progress** No Yes*** Yes*** No
Niagara 2972Xm 72x10G Intel/AMD x86 Broadcom BCM56850 (Trident2) Work In Progress** Yes Yes*** Yes*** No
Niagara 2932XL 32x40G Intel/AMD x86 Broadcom BCM56850 (Trident2) Work In Progress** No Yes*** Yes*** No
Niagara 2948X6XL 48x10G + 6x40G Intel/AMD x86 Broadcom BCM56850 (Trident2) Work In Progress** No Yes*** Yes No
+Device Ports CPU Forwarding In Lab +Altoline 6921 48x10G + 6x40G Intel C2538 Broadcom BCM56864 (Trident2+) Yes +Altoline 6921T 48x10G + 6x40G Intel C2538 Broadcom BCM56864 (Trident2+) Yes +Altoline 6941 32x40G Intel C2538 Broadcom BCM56864 (Trident2+) Yes +Altoline 6960 32x100G Intel C2538 Broadcom BCM56960 (Tomahawk) Yes + +Ingrasys +--- +Device Ports CPU Forwarding In Lab +S9100-32X 32x100G Intel Broadcom BCM56960 (Tomahawk) No + +Inventec +--- +Device Ports CPU Forwarding In Lab +D7032Q28B 32x100G Intel No Mellanox --- - - - - - - - - - - - -
Device Ports CPU Forwarding ONL Certified In Lab SAI
SN2100 16x100G Intel Rangeley C2558 Mellanox Spectrum Yes Yes Yes
SN2100B 16x40G Intel Rangeley C2558 Mellanox Spectrum Yes No Yes
SN2410 48x25G + 8x100G Intel Ivybridge 1047UE Mellanox Spectrum Yes Yes Yes
SN2410B 48x10G + 8x100G Intel Ivybridge 1047UE Mellanox Spectrum Yes No Yes
SN2700 32x100G Intel Ivybridge 1047UE Mellanox Spectrum Yes Yes Yes
SN2700B 32x40G Intel Ivybridge 1047UE Mellanox Spectrum Yes No Yes
+Device Ports CPU Forwarding In Lab +SN2100 16x100G Intel C2558 Mellanox Spectrum Yes +SN2100B 16x40G Intel C2558 Mellanox Spectrum No +SN2410 48x25G + 8x100G Intel 1047UE Mellanox Spectrum Yes +SN2410B 48x10G + 8x100G Intel 1047UE Mellanox Spectrum No +SN2700 32x100G Intel 1047UE Mellanox Spectrum Yes +SN2700B 32x40G Intel 1047UE Mellanox Spectrum No -Notes: +Netberg --- +Device Ports CPU Forwarding In Lab +Aurora 620 32x100G Intel C2558 Broadcom BCM56960 (Tomahawk) Yes +Aurora 720 48x10/25G + 6x40/100G Intel C2558 Broadcom BCM56960 (Tomahawk) Yes -ONL Certified means that the system runs ONIE, is able to install a generic version of ONL and has the ONL Platform drivers necessary to manage the system. - -\* Systems no longer in the lab cannot be certified post removal - -\** Developing ONL Platform Drivers - -\*** Vendor provided +Quanta +------ +Device Ports CPU Forwarding In Lab +QuantaMesh T1048-LB9 48x1G + 4x10G FreeScale P2020 Broadcom BCM56534 (Firebolt3) Yes +QuantaMesh T3048-LY2 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes +QuantaMesh T5032-LY6 32x40G Intel C2758 Broadcom BCM56850 (Trident2) Yes +QuantaMesh T3048-LY7 48x10G + 4x100G Intel C2558 Broadcom BCM56768 (Maverick) Yes +QuantaMesh T3048-LY8 48x10G + 6x40G Intel C2758 Broadcom BCM56854 (Trident2) Yes +QuantaMesh T3048-LY9 48x10GT + 6x40G Intel C2758 Broadcom BCM56850 (Trident2) Yes +QuantaMesh T7032-IX1 32x100G Intel C2758 Broadcom BCM56960 (Tomahawk) Yes +QuantaMesh T7032-IX1B 32x100G Intel C2758 Broadcom BCM56960 (Tomahawk) Yes +QuantaMesh T4048-IX2 48xSFP28 + 8xQSFP28 Intel C2758 Broadcom BCM56960 (Tomahawk) Yes +QuantaMesh T4048-IX8 48x10G + 8x100G Intel Broadcom BCM56870 (Trident 3) Yes From 128514d78dee06a60a4494045c8327e53b73d085 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Fri, 23 Mar 2018 16:29:12 +0800 Subject: [PATCH 193/244] Initial commit. Copied from as7312-54x and modify. Signed-off-by: roy_lee --- .../x86-64-accton-as7326-56x/.gitignore | 3 + .../x86-64/x86-64-accton-as7326-56x/Makefile | 1 + .../x86-64-accton-as7326-56x/modules/Makefile | 1 + .../x86-64-accton-as7326-56x/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as7326-56x-cpld.c | 1080 +++++++++++++++++ .../builds/x86-64-accton-as7326-56x-fan.c | 815 +++++++++++++ .../builds/x86-64-accton-as7326-56x-leds.c | 438 +++++++ .../builds/x86-64-accton-as7326-56x-psu.c | 277 +++++ .../x86-64-accton-as7326-56x/onlp/Makefile | 1 + .../x86-64-accton-as7326-56x/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../module/auto/x86_64_accton_as7326_56x.yml | 50 + .../x86_64_accton_as7326_56x.x | 14 + .../x86_64_accton_as7326_56x_config.h | 137 +++ .../x86_64_accton_as7326_56x_dox.h | 26 + .../x86_64_accton_as7326_56x_porting.h | 107 ++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/debug.c | 45 + .../onlp/builds/src/module/src/fani.c | 367 ++++++ .../onlp/builds/src/module/src/ledi.c | 261 ++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 175 +++ .../onlp/builds/src/module/src/platform_lib.h | 85 ++ .../onlp/builds/src/module/src/psui.c | 186 +++ .../onlp/builds/src/module/src/sfpi.c | 394 ++++++ .../onlp/builds/src/module/src/sysi.c | 490 ++++++++ .../onlp/builds/src/module/src/thermali.c | 169 +++ .../src/x86_64_accton_as7326_56x_config.c | 81 ++ .../src/x86_64_accton_as7326_56x_enums.c | 10 + .../module/src/x86_64_accton_as7326_56x_int.h | 12 + .../module/src/x86_64_accton_as7326_56x_log.c | 18 + .../module/src/x86_64_accton_as7326_56x_log.h | 12 + .../src/x86_64_accton_as7326_56x_module.c | 24 + .../src/x86_64_accton_as7326_56x_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-as7326-56x-r0.yml | 31 + .../x86_64_accton_as7326_56x_r0/__init__.py | 95 ++ 48 files changed, 5613 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-fan.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-leds.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-psu.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/x86_64_accton_as7326_56x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/debug.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/.gitignore new file mode 100644 index 00000000..f00c8387 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*as7326*56x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/PKG.yml new file mode 100644 index 00000000..703ce5b4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as7326-56x ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/Makefile new file mode 100644 index 00000000..a0721bb6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as7326-56x +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c new file mode 100644 index 00000000..2274c4a9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c @@ -0,0 +1,1080 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as7326_56x CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as7326_56x_cpld1, + as7326_56x_cpld2, + as7326_56x_cpld3 +}; + +struct as7326_56x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as7326_56x_cpld_id[] = { + { "as7326_56x_cpld1", as7326_56x_cpld1 }, + { "as7326_56x_cpld2", as7326_56x_cpld2 }, + { "as7326_56x_cpld3", as7326_56x_cpld3 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as7326_56x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index +#define TRANSCEIVER_RESET_ATTR_ID(index) MODULE_RESET_##index + +enum as7326_56x_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_PRESENT_ATTR_ID(55), + TRANSCEIVER_PRESENT_ATTR_ID(56), + TRANSCEIVER_PRESENT_ATTR_ID(57), + TRANSCEIVER_PRESENT_ATTR_ID(58), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_TXDISABLE_ATTR_ID(57), + TRANSCEIVER_TXDISABLE_ATTR_ID(58), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(57), + TRANSCEIVER_RXLOS_ATTR_ID(58), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(57), + TRANSCEIVER_TXFAULT_ATTR_ID(58), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7326_56x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7326_56x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_TRANSCEIVER_RESET_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_reset_##index, S_IRUGO | S_IWUSR, show_status, set_reset, MODULE_RESET_##index) +#define DECLARE_TRANSCEIVER_RESET_ATTR(index) &sensor_dev_attr_module_reset_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(55); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(56); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(57); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(58); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(57); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(58); + +static struct attribute *as7326_56x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7326_56x_cpld3_group = { + .attrs = as7326_56x_cpld3_attributes, +}; + +static struct attribute *as7326_56x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + NULL +}; + +static const struct attribute_group as7326_56x_cpld2_group = { + .attrs = as7326_56x_cpld2_attributes, +}; + +static struct attribute *as7326_56x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_TRANSCEIVER_PRESENT_ATTR(55), + DECLARE_TRANSCEIVER_PRESENT_ATTR(56), + DECLARE_TRANSCEIVER_PRESENT_ATTR(57), + DECLARE_TRANSCEIVER_PRESENT_ATTR(58), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + DECLARE_SFP_TRANSCEIVER_ATTR(57), + DECLARE_SFP_TRANSCEIVER_ATTR(58), + NULL +}; + +static const struct attribute_group as7326_56x_cpld1_group = { + .attrs = as7326_56x_cpld1_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x9, 0xA, 0xB, 0x18}; + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7326_56x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 56 in order */ + if (data->type == as7326_56x_cpld2) { + values[3] &= 0xF; + } + else { /* as7326_56x_cpld3 */ + values[3] &= 0x3; + } + + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x12, 0x13, 0x14}; + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7326_56x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as7326_56x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_30: + reg = 0x0f + (attr->index-MODULE_PRESENT_1)/8; + mask = 0x1 << ((attr->index - MODULE_PRESENT_1)%8); + break; + case MODULE_PRESENT_31 ... MODULE_PRESENT_48: + reg = 0x10 + (attr->index-MODULE_PRESENT_31)/8; + mask = 0x1 << ((attr->index - MODULE_PRESENT_31)%8); + break; + case MODULE_PRESENT_57 ... MODULE_PRESENT_58: + reg = 0x12; + mask = 0x1 << (( MODULE_PRESENT_58 - attr->index)+2); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_56: /*QSFP*/ + reg = 0x13 ; + mask = 0x1 << ((attr->index - MODULE_PRESENT_49)%8); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_30: + reg = 0x03 + (attr->index - MODULE_TXFAULT_1)/8; + mask = 0x1 << ((attr->index - MODULE_TXFAULT_1)%8); + break; + case MODULE_TXFAULT_31 ... MODULE_TXFAULT_48: + reg = 0x1a + (attr->index-MODULE_TXFAULT_31)/8; + mask = 0x1 << ((attr->index - MODULE_TXFAULT_31)%8); + break; + case MODULE_TXFAULT_57 ... MODULE_TXFAULT_58: + reg = 0x1c; + mask = 0x1 << (( attr->index - MODULE_TXFAULT_57)+2); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_30: + reg = 0x07 + (attr->index - MODULE_TXDISABLE_1)/8; + mask = 0x1 << ((attr->index - MODULE_TXDISABLE_1)%8); + break; + case MODULE_TXDISABLE_31 ... MODULE_TXDISABLE_48: + reg = 0x14 + (attr->index-MODULE_TXDISABLE_31)/8; + mask = 0x1 << ((attr->index - MODULE_TXDISABLE_31)%8); + break; + case MODULE_TXDISABLE_57 ... MODULE_TXDISABLE_58: + reg = 0x16; + mask = 0x1 << ((attr->index - MODULE_TXDISABLE_57)+2); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_30: + reg = 0x0b + (attr->index - MODULE_RXLOS_1)/8; + mask = 0x1 << ((attr->index - MODULE_RXLOS_1)%8); + break; + case MODULE_RXLOS_31 ... MODULE_RXLOS_48: + reg = 0x17 + (attr->index-MODULE_RXLOS_31)/8; + mask = 0x1 << ((attr->index - MODULE_RXLOS_31)%8); + break; + case MODULE_RXLOS_57 ... MODULE_RXLOS_58: + reg = 0x19; + mask = 0x1 << (( attr->index - MODULE_RXLOS_57)+2); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_56) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as7326_56x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_30: + reg = 0x07 + (attr->index - MODULE_TXDISABLE_1)/8; + mask = 0x1 << ((attr->index - MODULE_TXDISABLE_1)%8); + break; + case MODULE_TXDISABLE_31 ... MODULE_TXDISABLE_48: + reg = 0x14 + (attr->index - MODULE_TXDISABLE_31)/8; + mask = 0x1 << ((attr->index - MODULE_TXDISABLE_31)%8); + break; + case MODULE_TXDISABLE_57 ... MODULE_TXDISABLE_58: + reg = 0x16; + mask = 0x1 << ((attr->index - MODULE_TXDISABLE_57)+2); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as7326_56x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as7326_56x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7326_56x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as7326_56x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7326_56x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as7326_56x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as7326_56x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as7326_56x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as7326_56x_cpld1: + group = &as7326_56x_cpld1_group; + break; + case as7326_56x_cpld2: + group = &as7326_56x_cpld2_group; + break; + case as7326_56x_cpld3: + group = &as7326_56x_cpld3_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as7326_56x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as7326_56x_cpld_remove(struct i2c_client *client) +{ + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as7326_56x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as7326_56x_cpld1: + group = &as7326_56x_cpld1_group; + break; + case as7326_56x_cpld2: + group = &as7326_56x_cpld2_group; + break; + case as7326_56x_cpld3: + group = &as7326_56x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as7326_56x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7326_56x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as7326_56x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7326_56x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7326_56x_cpld_read); + +int as7326_56x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7326_56x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7326_56x_cpld_write); + +static struct i2c_driver as7326_56x_cpld_driver = { + .driver = { + .name = "as7326_56x_cpld", + .owner = THIS_MODULE, + }, + .probe = as7326_56x_cpld_probe, + .remove = as7326_56x_cpld_remove, + .id_table = as7326_56x_cpld_id, +}; + +static int __init as7326_56x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7326_56x_cpld_driver); +} + +static void __exit as7326_56x_cpld_exit(void) +{ + i2c_del_driver(&as7326_56x_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as7326_56x_cpld_init); +module_exit(as7326_56x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-fan.c new file mode 100644 index 00000000..606019f3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-fan.c @@ -0,0 +1,815 @@ +/* + * A hwmon driver for the Accton as7326 56x fan + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as7326_56x_fan" + +#define NUM_THERMAL_SENSORS (3) /* Get sum of this number of sensors.*/ +#define THERMAL_SENSORS_DRIVER "lm75" +#define THERMAL_SENSORS_ADDRS {0x48, 0x49, 0x4a} + +#define IN +#define OUT + +static struct as7326_56x_fan_data *as7326_56x_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t get_enable(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_enable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x0F, /* fan 1-6 present status */ + 0x10, /* fan 1-6 direction(0:F2B 1:B2F) */ + 0x11, /* fan PWM(for all fan) */ + 0x12, /* front fan 1 speed(rpm) */ + 0x13, /* front fan 2 speed(rpm) */ + 0x14, /* front fan 3 speed(rpm) */ + 0x15, /* front fan 4 speed(rpm) */ + 0x16, /* front fan 5 speed(rpm) */ + 0x17, /* front fan 6 speed(rpm) */ + 0x22, /* rear fan 1 speed(rpm) */ + 0x23, /* rear fan 2 speed(rpm) */ + 0x24, /* rear fan 3 speed(rpm) */ + 0x25, /* rear fan 4 speed(rpm) */ + 0x26, /* rear fan 5 speed(rpm) */ + 0x27, /* rear fan 6 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as7326_56x_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ + u8 enable; + int system_temp; /*In unit of mini-Celsius*/ + int sensors_found; +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID, + FAN5_ID, + FAN6_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DIRECTION_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN5_FRONT_SPEED_RPM, + FAN6_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN5_REAR_SPEED_RPM, + FAN6_REAR_SPEED_RPM, + FAN1_DIRECTION, + FAN2_DIRECTION, + FAN3_DIRECTION, + FAN4_DIRECTION, + FAN5_DIRECTION, + FAN6_DIRECTION, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN6_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT, + FAN5_FAULT, + FAN6_FAULT +}; + +/* Define attributes + */ +#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index, index2) \ + static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT);\ + static SENSOR_DEVICE_ATTR(fan##index2##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT) +#define DECLARE_FAN_FAULT_ATTR(index, index2) &sensor_dev_attr_fan##index##_fault.dev_attr.attr, \ + &sensor_dev_attr_fan##index2##_fault.dev_attr.attr + +#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN_DUTY_CYCLE_PERCENTAGE);\ + static SENSOR_DEVICE_ATTR(pwm##index, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN_DUTY_CYCLE_PERCENTAGE);\ + static SENSOR_DEVICE_ATTR(pwm##index##_enable, S_IWUSR | S_IRUGO, get_enable, set_enable, FAN_DUTY_CYCLE_PERCENTAGE) + +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan_duty_cycle_percentage.dev_attr.attr, \ + &sensor_dev_attr_pwm##index.dev_attr.attr, \ + &sensor_dev_attr_pwm##index##_enable.dev_attr.attr + +#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ + static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) + +#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr + + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index, index2) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_input, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index2##_input, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index, index2) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_input.dev_attr.attr, \ + &sensor_dev_attr_fan##index2##_input.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1,11); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2,12); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3,13); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4,14); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5,15); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6,16); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1,11); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2,12); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3,13); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4,14); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5,15); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6,16); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); +/* 6 fan direction attribute in this platform */ +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); +/* System temperature for fancontrol */ +DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); + +static struct attribute *as7326_56x_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1,11), + DECLARE_FAN_FAULT_ATTR(2,12), + DECLARE_FAN_FAULT_ATTR(3,13), + DECLARE_FAN_FAULT_ATTR(4,14), + DECLARE_FAN_FAULT_ATTR(5,15), + DECLARE_FAN_FAULT_ATTR(6,16), + DECLARE_FAN_SPEED_RPM_ATTR(1,11), + DECLARE_FAN_SPEED_RPM_ATTR(2,12), + DECLARE_FAN_SPEED_RPM_ATTR(3,13), + DECLARE_FAN_SPEED_RPM_ATTR(4,14), + DECLARE_FAN_SPEED_RPM_ATTR(5,15), + DECLARE_FAN_SPEED_RPM_ATTR(6,16), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(5), + DECLARE_FAN_PRESENT_ATTR(6), + DECLARE_FAN_DIRECTION_ATTR(1), + DECLARE_FAN_DIRECTION_ATTR(2), + DECLARE_FAN_DIRECTION_ATTR(3), + DECLARE_FAN_DIRECTION_ATTR(4), + DECLARE_FAN_DIRECTION_ATTR(5), + DECLARE_FAN_DIRECTION_ATTR(6), + DECLARE_FAN_DUTY_CYCLE_ATTR(1), + DECLARE_FAN_SYSTEM_TEMP_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as7326_56x_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as7326_56x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val+1) * 625 + 75)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + return ((u32)duty_cycle * 100 / 625) - 1; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 1 : 0; +} +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 0 : 1; +} + +static u8 is_fan_fault(struct as7326_56x_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_enable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); + int error, value; + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > 1) + return -EINVAL; + + data->enable = value; + if (value == 0) + { + return set_duty_cycle(dev, da, buf, FAN_MAX_DUTY_CYCLE); + } + return count; +} + + +static ssize_t get_enable(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); + + return sprintf(buf, "%u\n", data->enable); +} +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0) + return -EINVAL; + + value = (value > FAN_MAX_DUTY_CYCLE)? FAN_MAX_DUTY_CYCLE : value; + + as7326_56x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as7326_56x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +/* Due to this struct is declared at lm75.c, it cannot be include + * under Sonic environment. I duplicate it from lm75.c. + */ +struct lm75_data { + struct i2c_client *client; + struct device *hwmon_dev; + struct thermal_zone_device *tz; + struct mutex update_lock; + u8 orig_conf; + u8 resolution; /* In bits, between 9 and 12 */ + u8 resolution_limits; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + unsigned long sample_time; /* In jiffies */ + s16 temp[3]; /* Register values, + 0 = input + 1 = max + 2 = hyst */ +}; + +/*Copied from lm75.c*/ +static inline long lm75_reg_to_mc(s16 temp, u8 resolution) +{ + return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); +} + +/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ +static struct device * get_hwmon_dev( + struct i2c_client *client) +{ + struct lm75_data *data = NULL; + + data = i2c_get_clientdata(client); + if(data) + { + if( data->valid == 1 && data->hwmon_dev) + { + return data->hwmon_dev; + } + + } + return NULL; +} + +/* To find hwmon index by opening hwmon under that i2c address. + */ +static int find_hwmon_index_by_FileOpen( + int bus_nr, + unsigned short addr, + OUT int *index) +{ +#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ + struct file *sfd; + char client_name[96]; + int i=0; + + do { + snprintf(client_name, sizeof(client_name), + "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", + bus_nr, addr, i); + + sfd = filp_open(client_name, O_RDONLY, 0); + i++; + } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); + + if (IS_ERR(sfd)) { + pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); + return -ENOENT; + } + filp_close(sfd, 0); + *index = i - 1; + return 0; + +#undef MAX_HWMON_DEVICE +} + +static int get_temp_file_path( + int bus_nr, unsigned short addr, + struct device *hwmon_dev + ,char *path, int max_len) +{ + + if(hwmon_dev && strlen(dev_name(hwmon_dev))) + { + snprintf(path, max_len, + "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", + bus_nr, addr, dev_name(hwmon_dev)); + } + else + { + int i=0; + if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) + { + return -EIO; + } + snprintf(path, max_len, + "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", + bus_nr, addr, i); + } + return 0; +} + +/*File read the dev file at user space.*/ +static int read_devfile_temp1_input( + struct device *dev, + int bus_nr, + unsigned short addr, + struct device *hwmon_dev, + int *miniCelsius) +{ + struct file *sfd; + char buffer[96]; + char devfile[96]; + int rc, status; + int rdlen, value; + mm_segment_t old_fs; + + rc = 0; + get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); + sfd = filp_open(devfile, O_RDONLY, 0); + if (IS_ERR(sfd)) { + pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); + return -ENOENT; + } + dev_dbg(dev, "Found device:%s\n",devfile); + + if(!(sfd->f_op) || !(sfd->f_op->read) ) { + pr_err("file %s cann't readable ?\n",devfile); + return -ENOENT; + } + + old_fs = get_fs(); + set_fs(KERNEL_DS); + rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); + if (rdlen == 0) { + pr_err( "File(%s) empty!\n", devfile); + rc = -EIO; + goto exit; + } + status = sscanf(buffer, "%d", &value); + if (status != 1) { + rc = -EIO; + goto exit; + } + *miniCelsius = value; + dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); + +exit: + set_fs(old_fs); + filp_close(sfd, 0); + return rc; +} + +static u8 is_lm75_data_due(struct i2c_client *client) +{ + struct lm75_data *data = NULL; + + data = i2c_get_clientdata(client); + if (time_after(jiffies, data->last_updated + data->sample_time)) + { + return 1; + } + return 0; +} +static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) +{ + struct lm75_data *data = NULL; + + data = i2c_get_clientdata(client); + *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); + + return 0; +} + +static bool lm75_addr_mached(unsigned short addr) +{ + int i; + unsigned short addrs[] = THERMAL_SENSORS_ADDRS; + + for (i = 0; i < ARRAY_SIZE(addrs); i++) + { + if( addr == addrs[i]) + return 1; + } + return 0; +} + +static int _find_lm75_device(struct device *dev, void *data) +{ + struct device_driver *driver; + struct as7326_56x_fan_data *prv = data; + char *driver_name = THERMAL_SENSORS_DRIVER; + + driver = dev->driver; + if (driver && driver->name && + strcmp(driver->name, driver_name) == 0) + { + struct i2c_client *client; + client = to_i2c_client(dev); + if (client) + { + /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ + struct i2c_adapter *adap = client->adapter; + int miniCelsius = 0; + + if (! lm75_addr_mached(client->addr)) + { + return 0; + } + + if (!adap) { + return -ENXIO; + } + + /* If the data is not updated, read them from devfile + to drive them updateing data from chip.*/ + if (is_lm75_data_due(client)) + { + struct device *hwmon_dev; + + hwmon_dev = get_hwmon_dev(client); + if(0 == read_devfile_temp1_input(dev, adap->nr, + client->addr, hwmon_dev, &miniCelsius)) + { + prv->system_temp += miniCelsius; + prv->sensors_found++; + } + + } + else + { + get_lm75_temp(client, &miniCelsius); + prv->system_temp += miniCelsius; + prv->sensors_found++; + + } + } + } + return 0; +} + +/*Find all lm75 devices and return sum of temperatures.*/ +static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, + char *buf) +{ + ssize_t ret = 0; + struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); + + data->system_temp=0; + data->sensors_found=0; + i2c_for_each_dev(data, _find_lm75_device); + if (NUM_THERMAL_SENSORS != data->sensors_found) + { + dev_dbg(dev,"only %d of %d temps are found\n", + data->sensors_found, NUM_THERMAL_SENSORS); + data->system_temp = INT_MAX; + } + ret = sprintf(buf, "%d\n",data->system_temp); + return ret; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN5_FRONT_SPEED_RPM: + case FAN6_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + case FAN5_REAR_SPEED_RPM: + case FAN6_REAR_SPEED_RPM: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + case FAN6_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + case FAN5_FAULT: + case FAN6_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIRECTION: + case FAN2_DIRECTION: + case FAN3_DIRECTION: + case FAN4_DIRECTION: + case FAN5_DIRECTION: + case FAN6_DIRECTION: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], + attr->index - FAN1_DIRECTION)); + break; + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as7326_56x_fan_group = { + .attrs = as7326_56x_fan_attributes, +}; + +static struct as7326_56x_fan_data *as7326_56x_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as7326_56x_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as7326_56x_fan_read_value(client, fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as7326_56x_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7326_56x_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7326_56x_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->enable = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7326_56x_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7326_56x_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7326_56x_fan_remove(struct i2c_client *client) +{ + struct as7326_56x_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7326_56x_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; + +static const struct i2c_device_id as7326_56x_fan_id[] = { + { "as7326_56x_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7326_56x_fan_id); + +static struct i2c_driver as7326_56x_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as7326_56x_fan_probe, + .remove = as7326_56x_fan_remove, + .id_table = as7326_56x_fan_id, + .address_list = normal_i2c, +}; + +static int __init as7326_56x_fan_init(void) +{ + return i2c_add_driver(&as7326_56x_fan_driver); +} + +static void __exit as7326_56x_fan_exit(void) +{ + i2c_del_driver(&as7326_56x_fan_driver); +} + +module_init(as7326_56x_fan_init); +module_exit(as7326_56x_fan_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7326_56x_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-leds.c new file mode 100644 index 00000000..679b8960 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-leds.c @@ -0,0 +1,438 @@ +/* + * A LED driver for the accton_as7326_56x_led + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*#define DEBUG*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int as7326_56x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7326_56x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +extern void led_classdev_unregister(struct led_classdev *led_cdev); +extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); +extern void led_classdev_resume(struct led_classdev *led_cdev); +extern void led_classdev_suspend(struct led_classdev *led_cdev); + +#define DRVNAME "accton_as7326_56x_led" + +struct accton_as7326_56x_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[1]; /* only 1 register*/ +}; + +static struct accton_as7326_56x_led_data *ledctl = NULL; + +/* LED related data + */ + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x3) +#define LED_MODE_DIAG_GREEN_VALUE (0x02) +#define LED_MODE_DIAG_RED_VALUE (0x01) +#define LED_MODE_DIAG_AMBER_VALUE (0x00) /*It's yellow actually. Green+Red=Yellow*/ +#define LED_MODE_DIAG_OFF_VALUE (0x03) + + +#define LED_TYPE_LOC_REG_MASK (0x80) +#define LED_MODE_LOC_ON_VALUE (0) +#define LED_MODE_LOC_OFF_VALUE (0x80) + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +struct led_reg { + u32 types; + u8 reg_addr; +}; + +static const struct led_reg led_reg_map[] = { + {(1<update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as7326_56x_led update\n"); + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as7326_56x_led_read_value(led_reg_map[i].reg_addr); + + if (status < 0) { + ledctl->valid = 0; + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); + goto exit; + } + else + { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as7326_56x_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + enum led_type type) +{ + int reg_val; + u8 reg ; + mutex_lock(&ledctl->update_lock); + + if( !accton_getLedReg(type, ®)) + { + dev_dbg(&ledctl->pdev->dev, "Not match item for %d.\n", type); + } + + reg_val = accton_as7326_56x_led_read_value(reg); + + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + accton_as7326_56x_led_write_value(reg, reg_val); + + /* to prevent the slow-update issue */ + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + + +static void accton_as7326_56x_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7326_56x_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); +} + +static enum led_brightness accton_as7326_56x_led_diag_get(struct led_classdev *cdev) +{ + accton_as7326_56x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static void accton_as7326_56x_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7326_56x_led_set(led_cdev, led_light_mode, LED_TYPE_LOC); +} + +static enum led_brightness accton_as7326_56x_led_loc_get(struct led_classdev *cdev) +{ + accton_as7326_56x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void accton_as7326_56x_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness accton_as7326_56x_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static struct led_classdev accton_as7326_56x_leds[] = { + [LED_TYPE_DIAG] = { + .name = "accton_as7326_56x_led::diag", + .default_trigger = "unused", + .brightness_set = accton_as7326_56x_led_diag_set, + .brightness_get = accton_as7326_56x_led_diag_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_RED, + }, + [LED_TYPE_LOC] = { + .name = "accton_as7326_56x_led::loc", + .default_trigger = "unused", + .brightness_set = accton_as7326_56x_led_loc_set, + .brightness_get = accton_as7326_56x_led_loc_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_BLUE, + }, + [LED_TYPE_FAN] = { + .name = "accton_as7326_56x_led::fan", + .default_trigger = "unused", + .brightness_set = accton_as7326_56x_led_auto_set, + .brightness_get = accton_as7326_56x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU1] = { + .name = "accton_as7326_56x_led::psu1", + .default_trigger = "unused", + .brightness_set = accton_as7326_56x_led_auto_set, + .brightness_get = accton_as7326_56x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "accton_as7326_56x_led::psu2", + .default_trigger = "unused", + .brightness_set = accton_as7326_56x_led_auto_set, + .brightness_get = accton_as7326_56x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as7326_56x_led_suspend(struct platform_device *dev, + pm_message_t state) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7326_56x_leds); i++) { + led_classdev_suspend(&accton_as7326_56x_leds[i]); + } + + return 0; +} + +static int accton_as7326_56x_led_resume(struct platform_device *dev) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7326_56x_leds); i++) { + led_classdev_resume(&accton_as7326_56x_leds[i]); + } + + return 0; +} + +static int accton_as7326_56x_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as7326_56x_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as7326_56x_leds[i]); + + if (ret < 0) + break; + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as7326_56x_leds)) { + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as7326_56x_leds[i]); + } + } + + return ret; +} + +static int accton_as7326_56x_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as7326_56x_leds); i++) { + led_classdev_unregister(&accton_as7326_56x_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as7326_56x_led_driver = { + .probe = accton_as7326_56x_led_probe, + .remove = accton_as7326_56x_led_remove, + .suspend = accton_as7326_56x_led_suspend, + .resume = accton_as7326_56x_led_resume, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as7326_56x_led_init(void) +{ + int ret; + + ret = platform_driver_register(&accton_as7326_56x_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as7326_56x_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + platform_driver_unregister(&accton_as7326_56x_led_driver); + goto exit; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + platform_driver_unregister(&accton_as7326_56x_led_driver); + kfree(ledctl); + goto exit; + } + +exit: + return ret; +} + +static void __exit accton_as7326_56x_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as7326_56x_led_driver); + kfree(ledctl); +} + +module_init(accton_as7326_56x_led_init); +module_exit(accton_as7326_56x_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as7326_56x_led driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-psu.c new file mode 100644 index 00000000..8c2ece62 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-psu.c @@ -0,0 +1,277 @@ +/* + * An hwmon driver for accton as7326_56x Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static int as7326_56x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int as7326_56x_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x50, 0x53, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as7326_56x_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[9]; /* Model name, read from eeprom */ +}; + +static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *dev); + +enum as7326_56x_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as7326_56x_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7326_56x_psu_data *data = as7326_56x_psu_update_device(dev); + u8 status = 0; + + if (attr->index == PSU_PRESENT) { + status = !(data->status >> (1-data->index) & 0x1); + } + else { /* PSU_POWER_GOOD */ + status = (data->status >> (3-data->index) & 0x1); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as7326_56x_psu_data *data = as7326_56x_psu_update_device(dev); + + return sprintf(buf, "%s\n", data->model_name); +} + +static const struct attribute_group as7326_56x_psu_group = { + .attrs = as7326_56x_psu_attributes, +}; + +static int as7326_56x_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7326_56x_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7326_56x_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7326_56x_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7326_56x_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7326_56x_psu_remove(struct i2c_client *client) +{ + struct as7326_56x_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7326_56x_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as7326_56x_psu1, + as7326_56x_psu2 +}; + +static const struct i2c_device_id as7326_56x_psu_id[] = { + { "as7326_56x_psu1", as7326_56x_psu1 }, + { "as7326_56x_psu2", as7326_56x_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7326_56x_psu_id); + +static struct i2c_driver as7326_56x_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7326_56x_psu", + }, + .probe = as7326_56x_psu_probe, + .remove = as7326_56x_psu_remove, + .id_table = as7326_56x_psu_id, + .address_list = normal_i2c, +}; + +static int as7326_56x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as7326_56x_psu_data *as7326_56x_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as7326_56x update\n"); + + /* Read psu status */ + status = as7326_56x_cpld_read(0x60, 0x2); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + power_good = (data->status >> (3-data->index) & 0x1); + + if (power_good) { + status = as7326_56x_psu_read_block(client, 0x20, data->model_name, + ARRAY_SIZE(data->model_name)-1); + + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +module_i2c_driver(as7326_56x_psu_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7326_56x_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/PKG.yml new file mode 100644 index 00000000..ff22d474 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7326-56x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/lib/Makefile new file mode 100644 index 00000000..51dfecd1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as7326-56x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as7326_56x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as7326-56x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..10ffd95b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as7326_56x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/.module new file mode 100644 index 00000000..855b6544 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as7326_56x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile new file mode 100644 index 00000000..4007d6bd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_accton_as7326_56x +AUTOMODULE := x86_64_accton_as7326_56x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/README new file mode 100644 index 00000000..a26221d5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as7326_56x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..47c33e9f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_as7326_56x Autogeneration +# +############################################################################### +x86_64_accton_as7326_56x_AUTO_DEFS := module/auto/x86_64_accton_as7326_56x.yml +x86_64_accton_as7326_56x_AUTO_DIRS := module/inc/x86_64_accton_as7326_56x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/x86_64_accton_as7326_56x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/x86_64_accton_as7326_56x.yml new file mode 100644 index 00000000..2295d34c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/auto/x86_64_accton_as7326_56x.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_accton_as7326_56x Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB +- x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + x86_64_accton_as7326_56x_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as7326_56x_config + + portingmacro: + x86_64_accton_as7326_56x: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x.x b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x.x new file mode 100644 index 00000000..7900ee9e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_config.h new file mode 100644 index 00000000..7e32b421 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7326_56x Configuration Header + * + * @addtogroup x86_64_accton_as7326_56x-config + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7326_56x_CONFIG_H__ +#define __x86_64_accton_as7326_56x_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef x86_64_accton_as7326_56x_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING +#define x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT +#define x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT +#define x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB +#define x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as5512_56x_CONFIG_PORTING_STDLIB +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI +#define x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as7326_56x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as7326_56x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as7326_56x_config_settings table. */ +extern x86_64_accton_as7326_56x_config_settings_t x86_64_accton_as7326_56x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as7326_56x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as7326_56x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as7326_56x_porting.h" + +#endif /* __x86_64_accton_as7326_56x_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_dox.h new file mode 100644 index 00000000..57e513ce --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as7326_56x Doxygen Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7326_56x_DOX_H__ +#define __x86_64_accton_as7326_56x_DOX_H__ + +/** + * @defgroup x86_64_accton_as7326_56x x86_64_accton_as7326_56x - x86_64_accton_as7326_56x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as7326_56x-x86_64_accton_as7326_56x Public Interface + * @defgroup x86_64_accton_as7326_56x-config Compile Time Configuration + * @defgroup x86_64_accton_as7326_56x-porting Porting Macros + * + * @} + * + */ + +#endif /* __x86_64_accton_as7326_56x_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_porting.h new file mode 100644 index 00000000..9aa10b55 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/inc/x86_64_accton_as7326_56x/x86_64_accton_as7326_56x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7326_56x Porting Macros. + * + * @addtogroup x86_64_accton_as7326_56x-porting + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7326_56x_PORTING_H__ +#define __x86_64_accton_as7326_56x_PORTING_H__ + + +/* */ +#if x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_accton_as7326_56x_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_accton_as7326_56x_MALLOC GLOBAL_MALLOC + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_MALLOC malloc + #else + #error The macro x86_64_accton_as7326_56x_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_FREE + #if defined(GLOBAL_FREE) + #define x86_64_accton_as7326_56x_FREE GLOBAL_FREE + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_FREE free + #else + #error The macro x86_64_accton_as7326_56x_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_accton_as7326_56x_MEMSET GLOBAL_MEMSET + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_MEMSET memset + #else + #error The macro x86_64_accton_as7326_56x_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_accton_as7326_56x_MEMCPY GLOBAL_MEMCPY + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_MEMCPY memcpy + #else + #error The macro x86_64_accton_as7326_56x_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_accton_as7326_56x_STRNCPY GLOBAL_STRNCPY + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_STRNCPY strncpy + #else + #error The macro x86_64_accton_as7326_56x_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_accton_as7326_56x_VSNPRINTF GLOBAL_VSNPRINTF + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_VSNPRINTF vsnprintf + #else + #error The macro x86_64_accton_as7326_56x_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_accton_as7326_56x_SNPRINTF GLOBAL_SNPRINTF + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_SNPRINTF snprintf + #else + #error The macro x86_64_accton_as7326_56x_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_accton_as7326_56x_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_accton_as7326_56x_STRLEN GLOBAL_STRLEN + #elif x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB == 1 + #define x86_64_accton_as7326_56x_STRLEN strlen + #else + #error The macro x86_64_accton_as7326_56x_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __x86_64_accton_as7326_56x_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..b7aa99d1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as7326_56x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as7326_56x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as7326_56x_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7326_56x ucli:x86_64_accton_as7326_56x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..2cf04663 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as7326_56x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/debug.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/debug.c new file mode 100644 index 00000000..9b1be5f5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/debug.c @@ -0,0 +1,45 @@ +#include "x86_64_accton_as7326_56x_int.h" + +#if x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEBUG == 1 + +#include + +static char help__[] = + "Usage: debug [options]\n" + " -c CPLD Versions\n" + " -h Help\n" + ; + +int +x86_64_accton_as7326_56x_debug_main(int argc, char* argv[]) +{ + int c = 0; + int help = 0; + int rv = 0; + + while( (c = getopt(argc, argv, "ch")) != -1) { + switch(c) + { + case 'c': c = 1; break; + case 'h': help = 1; rv = 0; break; + default: help = 1; rv = 1; break; + } + + } + + if(help || argc == 1) { + printf("%s", help__); + return rv; + } + + if(c) { + printf("Not implemented.\n"); + } + + + return 0; +} + +#endif + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..e82f8a77 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/fani.c @@ -0,0 +1,367 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#define PSU_PREFIX_PATH "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + CHASSIS_FAN_INFO(6), + PSU_FAN_INFO(1,1), + PSU_FAN_INFO(2,1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value; + char path[64] = {0}; + + /* get fan present status + */ + sprintf(path, "%s""fan%d_present", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), present path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + sprintf(path, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), fault path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + sprintf(path, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), direction path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; + + + /* get front fan speed + */ + sprintf(path, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), front speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + sprintf(path, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), rear speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan fault status + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + DEBUG_PRINT("Fan path = (%s)", path); + + if (onlp_file_write_integer(path, p) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..de35ecc6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,261 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/accton_as7326_56x_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..4909163f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as7326_56x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..2758d9b3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,175 @@ +#include +#include +#include "platform_lib.h" +#include +#include "x86_64_accton_as7326_56x_log.h" + + +static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { + return -1; + } + + if ((len = write(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_write_integer(char *filename, int value) +{ + char buf[8] = {0}; + sprintf(buf, "%d", value); + + return _onlp_file_write(filename, buf, (int)strlen(buf), 0); +} + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_RDONLY)) == -1) { + return -1; + } + + if ((len = read(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 9 +#define I2C_PSU_FAN_DIR_LEN 3 + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model); + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (modelname) { + strncpy(modelname, model_name, modelname_len-1); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_integer(path, value) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..d54311e0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,85 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include +#include "x86_64_accton_as7326_56x_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 +#define CHASSIS_PSU_COUNT 2 +#define CHASSIS_LED_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/17-0059/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/13-005b/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/17-0051/" +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/13-0053/" + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/11-0066/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/0-0056/eeprom" + +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); + + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); + +//#define DEBUG_MODE 1 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..77074bb8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c @@ -0,0 +1,186 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +//#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + + + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..a73e8602 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,394 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "x86_64_accton_as7326_56x_int.h" +#include "x86_64_accton_as7326_56x_log.h" + +#define PORT_BUS_INDEX(port) sfp_map(port) + +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD1 "/sys/bus/i2c/devices/18-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/12-0062/module_rx_los_all" + +const int sfp_map[] = { + 42,41,44,43,47,45,46,50, + 48,49,51,52,53,56,55,54, + 58,57,59,60,61,63,62,64, + 66,68,65,67,69,71,72,70, + 74,73,76,75,77,79,78,80, + 81,82,84,85,83,87,88,86, /*port 41~48*/ + 25,26,27,28,29,30,31,32, /*port 49~56 QSFP*/ + 22,23}; /*port 57~58 SFP+ from CPU NIF.*/ + + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 58} + */ + int p; + + for(p = 0; p < 58; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus, addr; + + addr = (port < 30) ? 62 : 60; + bus = (addr == 62) ? 12 : 18; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[8], *ptr = NULL; + FILE* fp; + int addr; + + ptr = bytes; + + for (addr = 62; addr >= 60; addr-=2) { + /* Read present status of port 0~53 */ + char file[64] = {0}; + int bus = (addr == 62) ? 12 : 18; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; + } + + /* Mask out non-existant QSFP ports */ + bytes[3] &= 0xF; + bytes[7] &= 0x3; + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t presence_all = 0 ; + presence_all |= bytes[7]; + presence_all <<= 4; + presence_all |= bytes[3]; + + for(i = 6; i >= 4; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + for(i = 2; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[6]; + uint32_t *ptr = bytes; + FILE* fp; + + /* Read present status of port 0~23 */ + int addr, i = 0; + + for (addr = 62; addr >= 60; addr-=2) { + if (addr == 62) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; + } + + /* Convert to 64 bit integer in port order */ + i = 0; + uint64_t rx_los_all = 0 ; + for(i = 5; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 30) ? 62 : 60; + int bus = (addr == 62) ? 12 : 18; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 30) ? 62 : 60; + int bus = (addr == 62) ? 12 : 18; + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..25b37496 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,490 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_accton_as7326_56x_int.h" +#include "x86_64_accton_as7326_56x_log.h" + + +#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" +#define NUM_OF_CPLD 3 +#define FAN_DUTY_CYCLE_MAX (100) +#define FAN_DUTY_CYCLE_DEFAULT (32) +#define FAN_DUTY_PLUS_FOR_DIR (13) +/* Note, all chassis fans share 1 single duty setting. + * Here use fan 1 to represent global fan duty value.*/ +#define FAN_ID_FOR_SET_FAN_DUTY (1) +#define CELSIUS_RECORD_NUMBER (2) /*Must >= 2*/ + +typedef struct fan_ctrl_policy { + int duty_cycle; /* In percetage */ + int step_up_thermal; /* In mini-Celsius */ + int step_dn_thermal; /* In mini-Celsius */ +} fan_ctrl_policy_t; + +static char arr_cplddev_name[NUM_OF_CPLD][10] = +{ + "4-0060", + "5-0062", + "6-0064" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as7326-56x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 5 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +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); +} + +/* Thermal plan: + * $TMP = (CPU_core + LM75_1+ LM75_2 + LM75_3 + LM75_4)/5 + * 1. If any FAN failed, set all the other fans as full speed, 100%. + * 2. If any sensor is high than 45 degrees, set fan speed to duty 62.5%. + * 3. If any sensor is high than 50 degrees, set fan speed to duty 100%. + * 4. When $TMP >= 40 C, set fan speed to duty 62.5%. + * 5. When $TMP >= 45 C, set fan speed to duty 100%. + * 6. When $TMP < 35 C, set fan speed to duty 31.25%. + * 7. Direction factor, when B2F, duty + 12.5%. + * + * Note, all chassis fans share 1 single duty setting. + */ +fan_ctrl_policy_t fan_ctrl_policy_avg[] = { +{FAN_DUTY_CYCLE_MAX , 45000, INT_MIN}, +{63 , 40000, INT_MIN}, +{32 , INT_MAX, 35000}, +}; + +fan_ctrl_policy_t fan_ctrl_policy_single[] = { +{FAN_DUTY_CYCLE_MAX , 50000, INT_MIN}, +{63 , 45000, INT_MIN}, +}; + +struct fan_control_data_s { + int duty_cycle; + int dir_plus; + int mc_avg_pre[CELSIUS_RECORD_NUMBER]; + int mc_high_pre[CELSIUS_RECORD_NUMBER]; + +} fan_control_data_pre = +{ + .duty_cycle = FAN_DUTY_CYCLE_DEFAULT, + .dir_plus = 0, + .mc_avg_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + .mc_high_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + +}; + +static int +sysi_check_fan(uint32_t *fan_dir){ + int i, present; + + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + present = fan_info.status & ONLP_FAN_STATUS_PRESENT; + if ((fan_info.status & ONLP_FAN_STATUS_FAILED) || !present) { + AIM_LOG_WARN("Fan(%d) is not working, set the other fans as full speed\r\n", i); + int ret = onlp_fani_percentage_set( + ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY), FAN_DUTY_CYCLE_MAX); + if (ret != ONLP_STATUS_OK) + return ret; + else + return ONLP_STATUS_E_MISSING; + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + *fan_dir = fan_info.status & (ONLP_FAN_STATUS_F2B|ONLP_FAN_STATUS_B2F); + } + } + + return ONLP_STATUS_OK; +} + +static int +sysi_get_fan_duty(int *cur_duty_cycle){ + int fd, len; + char buf[10] = {0}; + char *node = FAN_NODE(fan_duty_cycle_percentage); + + /* Get current fan duty*/ + fd = open(node, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + *cur_duty_cycle = atoi(buf); + + return ONLP_STATUS_OK; +} + +static int +sysi_get_thermal_sum(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i; + + *mcelsius = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + *mcelsius += thermal_info.mcelsius; + + DEBUG_PRINT("Thermal %d: %d \n ", i, thermal_info.mcelsius); + + } + + return ONLP_STATUS_OK; + +} + +static int +sysi_get_highest_thermal(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i, highest; + + highest = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + highest = (thermal_info.mcelsius > highest)? + thermal_info.mcelsius : highest; + } + *mcelsius = highest; + return ONLP_STATUS_OK; +} + +/* Anaylze thermal changing history to judge if the change is a stable trend. */ +static int _is_thermal_a_trend(int *mc_history){ + int i, trend, trended; + + if (mc_history == NULL) { + AIM_LOG_ERROR("Unable to get history of thermal\n"); + return 0; + } + + /* Get heat up/down trend. */ + trend = 0; + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + if (( mc_history[i+1] < mc_history[i])){ + trend++; + }else if (( mc_history[i+1] > mc_history[i])){ + trend--; + } + } + + trended = (abs(trend) >= ((CELSIUS_RECORD_NUMBER+1)/2))? 1:0; +#if (DEBUG_MODE == 1) + DEBUG_PRINT("[INFO]%s#%d, trended: %d, UP/DW: %d mcelsius:", + __func__, __LINE__, trended, trend ); + for (i = 0; i <= CELSIUS_RECORD_NUMBER; i++) { + DEBUG_PRINT(" %d =>", mc_history[i]); + } + DEBUG_PRINT("%c\n", ' '); +#endif + + /*For more than half changes are same direction, it's a firm trend.*/ + return trended; +} + + +/* Decide duty by highest value of thermal sensors.*/ +static int +sysi_get_duty_by_highest(int *duty_cycle){ + int i, ret, maxtrix_len; + int new_duty_cycle = 0 ; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + ret = sysi_get_highest_thermal(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_high_pre, + sizeof(fan_control_data_pre.mc_high_pre)); + + DEBUG_PRINT("[INFO]%s#%d, highest mcelsius:%d!\n", + __func__, __LINE__, *mcelsius_now_p); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_high_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_single); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((*mcelsius_now_p > fan_ctrl_policy_single[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_single[i].duty_cycle; + matched = !matched; + break; + } + } +/* if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, *mcelsius_now_p); + } */ + } + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +/* Decide duty by average value of thermal sensors.*/ +static int +sysi_get_duty_by_average(int *duty_cycle){ + int i, mcelsius_avg, ret, maxtrix_len; + int new_duty_cycle=0; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + *mcelsius_now_p = 0; + ret = sysi_get_thermal_sum(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + mcelsius_avg = (*mcelsius_now_p)/CHASSIS_THERMAL_COUNT; + + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_avg_pre, + sizeof(fan_control_data_pre.mc_avg_pre)); + + DEBUG_PRINT("[INFO]%s#%d, mcelsius:%d!\n", __func__, __LINE__, mcelsius_avg); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_avg_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_avg); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((mcelsius_avg >= fan_ctrl_policy_avg[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + for (i = maxtrix_len-1; i>=0; i--) { + if ((mcelsius_avg < fan_ctrl_policy_avg[i].step_dn_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + /*if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, mcelsius_avg); + } */ + } + + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_fans(void) +{ + uint32_t fan_dir; + int ret; + int cur_duty_cycle, new_duty_cycle, tmp; + int direct_addon = 0; + onlp_oid_t fan_duty_oid = ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY); + + /********************************************************** + * Decision 1: Set fan as full speed if any fan is failed. + **********************************************************/ + ret = sysi_check_fan(&fan_dir); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + if (fan_dir & ONLP_FAN_STATUS_B2F) { + direct_addon = FAN_DUTY_PLUS_FOR_DIR; + } + + /********************************************************** + * Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + **********************************************************/ + ret = sysi_get_fan_duty(&cur_duty_cycle); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + /********************************************************** + * Decision 3: Decide new fan speed depend on fan direction and temperature + **********************************************************/ + ret = sysi_get_duty_by_average(&new_duty_cycle); + if (ONLP_STATUS_OK != ret){ + return ret; + } + ret = sysi_get_duty_by_highest(&tmp); + if (ONLP_STATUS_OK != ret){ + return ret; + } + + new_duty_cycle = (tmp > new_duty_cycle)? tmp : new_duty_cycle; + if (new_duty_cycle == 0) + { + new_duty_cycle = fan_control_data_pre.duty_cycle; + } else { + fan_control_data_pre.duty_cycle = new_duty_cycle; + } + fan_control_data_pre.dir_plus = direct_addon; + DEBUG_PRINT("[INFO]%s#%d, new duty: %d = %d + %d (%d)!\n", __func__, __LINE__, + new_duty_cycle + direct_addon, new_duty_cycle, direct_addon, cur_duty_cycle); + + new_duty_cycle += direct_addon; + new_duty_cycle = (new_duty_cycle > FAN_DUTY_CYCLE_MAX)? + FAN_DUTY_CYCLE_MAX : new_duty_cycle; + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(fan_duty_oid, new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..cfa2ecbf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,169 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +//#include +#include +#include +#include "platform_lib.h" + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*temp1_input" +#define PSU_THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*psu_temp1_input" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "15-0048", + "15-0049", + "15-004a", + "15-004b", + "17-0059", + "13-005b", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-4-4B", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char *format = NULL; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if(tid == THERMAL_CPU_CORE) { + return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + } + + switch (tid) { + case THERMAL_1_ON_MAIN_BROAD: + case THERMAL_2_ON_MAIN_BROAD: + case THERMAL_3_ON_MAIN_BROAD: + case THERMAL_4_ON_MAIN_BROAD: + format = THERMAL_PATH_FORMAT; + break; + case THERMAL_1_ON_PSU1: + case THERMAL_1_ON_PSU2: + format = PSU_THERMAL_PATH_FORMAT; + break; + default: + return ONLP_STATUS_E_INVALID; + }; + + /* get path */ + sprintf(path, format, directory[tid], tid); + + if (onlp_file_read_int(&info->mcelsius, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_config.c new file mode 100644 index 00000000..a7e200ad --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(_x) +x86_64_accton_as7326_56x_config_settings_t x86_64_accton_as7326_56x_config_settings[] = +{ +#ifdef x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_PORTING_STDLIB(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7326_56x_config_STRINGIFY_NAME(x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE(x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ x86_64_accton_as7326_56x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7326_56x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as7326_56x_config_STRINGIFY_VALUE +#undef __x86_64_accton_as7326_56x_config_STRINGIFY_NAME + +const char* +x86_64_accton_as7326_56x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as7326_56x_config_settings[i].name; i++) { + if(strcmp(x86_64_accton_as7326_56x_config_settings[i].name, setting)) { + return x86_64_accton_as7326_56x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as7326_56x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as7326_56x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as7326_56x_config_settings[i].name, x86_64_accton_as7326_56x_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_enums.c new file mode 100644 index 00000000..c8a1f141 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_int.h new file mode 100644 index 00000000..3b6704f7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as7326_56x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7326_56x_INT_H__ +#define __x86_64_accton_as7326_56x_INT_H__ + +#include + + +#endif /* __x86_64_accton_as7326_56x_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.c new file mode 100644 index 00000000..11fdcb33 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7326_56x_log.h" +/* + * x86_64_accton_as7326_56x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + x86_64_accton_as7326_56x_CONFIG_LOG_OPTIONS_DEFAULT, + x86_64_accton_as7326_56x_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + x86_64_accton_as7326_56x_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.h new file mode 100644 index 00000000..242e7993 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7326_56x_LOG_H__ +#define __x86_64_accton_as7326_56x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as7326_56x +#include + +#endif /* __x86_64_accton_as7326_56x_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_module.c new file mode 100644 index 00000000..9d1cbdbd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7326_56x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as7326_56x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as7326_56x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_ucli.c new file mode 100644 index 00000000..bad2c3a7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/x86_64_accton_as7326_56x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as7326_56x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as7326_56x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7326_56x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as7326_56x_ucli_module__ = + { + "x86_64_accton_as7326_56x_ucli", + NULL, + x86_64_accton_as7326_56x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as7326_56x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as7326_56x_ucli_module__); + n = ucli_node_create("x86_64_accton_as7326_56x", NULL, &x86_64_accton_as7326_56x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7326_56x")); + return n; +} + +#else +void* +x86_64_accton_as7326_56x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/PKG.yml new file mode 100644 index 00000000..953869a4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as7326-56x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml new file mode 100644 index 00000000..b1927c8e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for AS7326 +# +###################################################################### + +x86-64-accton-as7326-56x-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS1,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py new file mode 100644 index 00000000..1efb26e0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py @@ -0,0 +1,95 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as7326_56x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_48x25_6x100): + + PLATFORM='x86-64-accton-as7326-56x-r0' + MODEL="AS7326-56X" + SYS_OBJECT_ID=".7326.54" + + def baseconfig(self): + self.insmod('optoe') + self.insmod('ym2651y') + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + self.insmod("x86-64-accton-as7326-56x-%s.ko" % m) + + self.new_i2c_device('pca9548', 0x77, 0) + ########### initialize I2C bus 1 ########### + # initialize multiplexer (PCA9548) + self.new_i2c_device('pca9548', 0x70, 1) + self.new_i2c_device('pca9548', 0x71, 1) + self.new_i2c_device('pca9548', 0x72, 24) + + self.new_i2c_devices([ + # initiate chassis fan + ('as7326_56x_fan', 0x66, 11), + + # inititate LM75 + ('lm75', 0x48, 15), + ('lm75', 0x49, 15), + ('lm75', 0x4a, 15), + ('lm75', 0x4b, 15), + ]) + + self.new_i2c_devices([ + # initialize CPLD + ('as7326_56x_cpld1', 0x60, 18), + ('as7326_56x_cpld2', 0x62, 12), + ('as7326_56x_cpld3', 0x64, 19), + ]) + + self.new_i2c_devices([ + # initiate PSU-1 + ('as7326_56x_psu1', 0x51, 17), + ('ym2651', 0x59, 17), + + # initiate PSU-2 + ('as7326_56x_psu2', 0x53, 13), + ('ym2651', 0x5b, 13), + ]) + ########### initialize I2C bus 1 ########### + + # initiate multiplexer (PCA9548) + self.new_i2c_devices( + [ + ('pca9548', 0x70, 2), + # initiate multiplexer (PCA9548) + ('pca9548', 0x71, 33), + ('pca9548', 0x72, 34), + ('pca9548', 0x73, 35), + ('pca9548', 0x74, 36), + ('pca9548', 0x75, 37), + ('pca9548', 0x76, 38), + ] + ) + + sfp_map = [ + 42,41,44,43,47,45,46,50, + 48,49,51,52,53,56,55,54, + 58,57,59,60,61,63,62,64, + 66,68,65,67,69,71,72,70, + 74,73,76,75,77,79,78,80, + 81,82,84,85,83,87,88,86, #port 41~48 + 25,26,27,28,29,30,31,32, #port 49~56 QSFP + 22,23] #port 57~58 SFP+ from CPU NIF. + + # initialize SFP+ port 1~54 and 57+58. + for port in range(1, 49): + bus = sfp_map[port-1] + self.new_i2c_device('optoe2', 0x50, bus) + + self.new_i2c_device('optoe2', 0x50, sfp[56]) + self.new_i2c_device('optoe2', 0x50, sfp[57]) + + # initialize QSFP port 49~56 + for port in range(49, 58): + bus = sfp_map[port-1] + self.new_i2c_device('optoe1', 0x50, bus) + + for port in range(1, len(sfp)+1): + bus = sfp_map[port-1] + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, bus), shell=True) + + self.new_i2c_device('24c04', 0x56, 0) + return True From 95615b571e0a8ba0fc092dcdcf48ef9fb86e1d2a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 23 Mar 2018 07:50:21 -0700 Subject: [PATCH 194/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 47d6d0a8..9cc37062 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 47d6d0a878046990981b7bc023e0d5cb03ce455c +Subproject commit 9cc37062419222acc152d8d94b9f95965ccd665f From 9856e658997797f8590c57e0ca7e2924bc79e49a Mon Sep 17 00:00:00 2001 From: Nataliya Yakuts Date: Mon, 26 Mar 2018 14:20:06 +0000 Subject: [PATCH 195/244] Mellanox common code restructuring. MSN2100, MSN2410, MSN2700 platforms support. Signed-off-by: Nataliya Yakuts Reviewed-by: Michael Shych --- .../mellanox/any/src/mlnx_common/.module | 1 + .../mellanox/any/src/mlnx_common/Makefile | 9 + .../mellanox/any/src/mlnx_common/README | 5 + .../any/src/mlnx_common/mlnx_common.doxy | 0 .../any/src/mlnx_common/mlnx_common.mk | 13 + .../any/src/mlnx_common/module/auto/make.mk | 8 + .../mlnx_common/module/auto/mlnx_common.yml | 47 ++ .../module/inc/mlnx_common/mlnx_common.h | 183 +++++++ .../module/inc/mlnx_common/mlnx_common.x | 12 + .../inc/mlnx_common/mlnx_common_config.h | 127 +++++ .../module/inc/mlnx_common/mlnx_common_dox.h | 26 + .../inc/mlnx_common/mlnx_common_porting.h | 107 ++++ .../any/src/mlnx_common/module/make.mk | 9 + .../any/src/mlnx_common/module/src/Makefile | 8 + .../any/src/mlnx_common/module/src/make.mk | 9 + .../module/src/mlnx_common_config.c | 75 +++ .../module/src/mlnx_common_enums.c | 9 + .../mlnx_common/module/src/mlnx_common_fani.c | 411 +++++++++++++++ .../mlnx_common/module/src/mlnx_common_int.h | 17 + .../mlnx_common/module/src/mlnx_common_ledi.c | 346 +++++++++++++ .../mlnx_common/module/src/mlnx_common_log.c | 17 + .../mlnx_common/module/src/mlnx_common_log.h | 12 + .../module/src/mlnx_common_module.c | 22 + .../module/src/mlnx_common_psui.c} | 155 ++++-- .../module/src/mlnx_common_sfpi.c} | 69 +-- .../mlnx_common/module/src/mlnx_common_sysi.c | 391 ++++++++++++++ .../module/src/mlnx_common_thermali.c | 74 +++ .../mlnx_common/module/src/mlnx_common_ucli.c | 49 ++ .../module/src/mlnx_common_utils.c} | 8 +- .../module/src/mlnx_platform_common_int.h | 17 + .../any/src/mlnx_common/utest/_make.mk | 8 + .../mellanox/any/src/mlnx_common/utest/main.c | 18 + .../onlp/builds/lib/Makefile | 3 +- .../onlp/builds/onlpdump/Makefile | 3 +- .../onlp/builds/src/module/src/fani.c | 309 +---------- .../onlp/builds/src/module/src/ledi.c | 292 +---------- .../onlp/builds/src/module/src/platform_lib.c | 63 --- .../onlp/builds/src/module/src/platform_lib.h | 40 +- .../onlp/builds/src/module/src/psui.c | 173 ------- .../onlp/builds/src/module/src/sysi.c | 185 +------ .../onlp/builds/src/module/src/thermali.c | 75 +-- .../x86-64/x86-64-mlnx-msn2410/onlp/Makefile | 2 +- .../onlp/builds/lib/Makefile | 3 +- .../onlp/builds/onlpdump/Makefile | 3 +- .../onlp/builds/src/module/src/fani.c | 478 +----------------- .../onlp/builds/src/module/src/ledi.c | 304 +---------- .../onlp/builds/src/module/src/platform_lib.c | 109 ---- .../onlp/builds/src/module/src/platform_lib.h | 43 +- .../onlp/builds/src/module/src/sfpi.c | 262 ---------- .../onlp/builds/src/module/src/sysi.c | 231 ++------- .../onlp/builds/src/module/src/thermali.c | 80 +-- .../onlp/builds/lib/Makefile | 3 +- .../onlp/builds/onlpdump/Makefile | 2 +- .../onlp/builds/src/module/src/fani.c | 478 +----------------- .../onlp/builds/src/module/src/ledi.c | 304 +---------- .../onlp/builds/src/module/src/platform_lib.h | 43 +- .../onlp/builds/src/module/src/psui.c | 200 -------- .../onlp/builds/src/module/src/sfpi.c | 262 ---------- .../onlp/builds/src/module/src/sysi.c | 231 ++------- .../onlp/builds/src/module/src/thermali.c | 80 +-- 60 files changed, 2347 insertions(+), 4176 deletions(-) create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/.module create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/Makefile create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/README create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.doxy create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.mk create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/auto/make.mk create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/auto/mlnx_common.yml create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.x create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_config.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_dox.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_porting.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/make.mk create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/Makefile create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/make.mk create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_config.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_enums.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_module.c rename packages/platforms/mellanox/{x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c => any/src/mlnx_common/module/src/mlnx_common_psui.c} (59%) rename packages/platforms/mellanox/{x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c => any/src/mlnx_common/module/src/mlnx_common_sfpi.c} (75%) create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sysi.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ucli.c rename packages/platforms/mellanox/{x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c => any/src/mlnx_common/module/src/mlnx_common_utils.c} (94%) create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_platform_common_int.h create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/utest/_make.mk create mode 100644 packages/platforms/mellanox/any/src/mlnx_common/utest/main.c delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c delete mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c diff --git a/packages/platforms/mellanox/any/src/mlnx_common/.module b/packages/platforms/mellanox/any/src/mlnx_common/.module new file mode 100644 index 00000000..404e7177 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/.module @@ -0,0 +1 @@ +name: mlnx_common diff --git a/packages/platforms/mellanox/any/src/mlnx_common/Makefile b/packages/platforms/mellanox/any/src/mlnx_common/Makefile new file mode 100644 index 00000000..79031835 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := mlnx_common +AUTOMODULE := mlnx_common +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mellanox/any/src/mlnx_common/README b/packages/platforms/mellanox/any/src/mlnx_common/README new file mode 100644 index 00000000..2134ce57 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/README @@ -0,0 +1,5 @@ +############################################################################### +# +# mlnx_common README +# +############################################################################### diff --git a/packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.doxy b/packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.doxy new file mode 100644 index 00000000..e69de29b diff --git a/packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.mk b/packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.mk new file mode 100644 index 00000000..6670b8fa --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/mlnx_common.mk @@ -0,0 +1,13 @@ + +############################################################################### +# +# Inclusive Makefile for the mlnx_common module. +# +# Autogenerated 2017-11-15 18:52:06.437798 +# +############################################################################### +mlnx_common_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(mlnx_common_BASEDIR)/module/make.mk +include $(mlnx_common_BASEDIR)/module/auto/make.mk +include $(mlnx_common_BASEDIR)/module/src/make.mk +include $(mlnx_common_BASEDIR)/utest/_make.mk diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/auto/make.mk b/packages/platforms/mellanox/any/src/mlnx_common/module/auto/make.mk new file mode 100644 index 00000000..b4dd174b --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/auto/make.mk @@ -0,0 +1,8 @@ +############################################################################### +# +# mlnx_common Autogeneration +# +############################################################################### +mlnx_common_AUTO_DEFS := module/auto/mlnx_common.yml +mlnx_common_AUTO_DIRS := module/inc/mlnx_common module/src +include $(BUILDER)/auto.mk diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/auto/mlnx_common.yml b/packages/platforms/mellanox/any/src/mlnx_common/module/auto/mlnx_common.yml new file mode 100644 index 00000000..d79c0cb7 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/auto/mlnx_common.yml @@ -0,0 +1,47 @@ +############################################################################### +# +# mlnx_common Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- MLNX_COMMON_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- MLNX_COMMON_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: MLNX_COMMON_CONFIG_PORTING_STDLIB +- MLNX_COMMON_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 + + +definitions: + cdefs: + MLNX_COMMON_CONFIG_HEADER: + defs: *cdefs + basename: mlnx_common_config + + portingmacro: + MLNX_COMMON: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h new file mode 100644 index 00000000..f2bd7dbe --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h @@ -0,0 +1,183 @@ +/**************************************************************************//** + * + * @file + * @brief mlnx_common Main Interface Header + * + * @addtogroup mlnx_common + * @{ + * + *****************************************************************************/ +#ifndef __MLNX_COMMON_H__ +#define __MLNX_COMMON_H__ + +#include +#include +#include +#include +#include + +#define PLATFORM_NAME_MAX_LEN 64 + +#ifndef KERNEL_VERSION +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#endif + +#define LED_TYPE_1 1 +#define LED_TYPE_2 2 + +/* led common id */ +#define LED_RESERVED 0 +#define LED_SYSTEM 1 +/*led type 1 id */ +#define LED_FAN1 2 +#define LED_FAN2 3 +#define LED_FAN3 4 +#define LED_FAN4 5 +#define LED_PSU 6 +/*led type 2 id */ +#define LED_FAN 2 +#define LED_PSU1 3 +#define LED_PSU2 4 +#define LED_UID 5 + +#define PERCENTAGE_MIN 60.0 +#define PERCENTAGE_MAX 100.0 +#define RPM_MAGIC_MIN 153.0 +#define RPM_MAGIC_MAX 255.0 + +#define PSU_FAN_RPM_MIN 11700.0 +#define PSU_FAN_RPM_MAX 19500.0 + +#define PROJECT_NAME +#define LEN_FILE_NAME 80 + +/* 1 -without eeprom, 2 - with eeprom */ +#define PSU_TYPE_1 1 +#define PSU_TYPE_2 2 + +#define FAN_MODEL "MEC012579" + +#define FAN_TYPE_NO_EEPROM 1 +#define FAN_TYPE_EEPROM 2 + +#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ + { #prj"fan"#id"_status", \ + #prj"fan"#id"_speed_get", \ + #prj"fan"#id"_speed_set", \ + #prj"fan"#id"_min", \ + #prj"fan"#id"_max" } + +#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) + +#define MAKE_FAN_PATH_ON_PSU(psu_id, fan_id) \ + {"psu"#psu_id"_status", \ + "psu"#psu_id"_fan"#fan_id"_speed_get", "", "", "",} + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | \ + ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_RPM), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id" Fan "#fan_id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +typedef struct fan_path_S +{ + char status[LEN_FILE_NAME]; + char r_speed_get[LEN_FILE_NAME]; + char r_speed_set[LEN_FILE_NAME]; + char min[LEN_FILE_NAME]; + char max[LEN_FILE_NAME]; +} fan_path_T; + +/** Specific platform info structure. */ +typedef struct mlnx_platform_info_s { + char onl_platform_name[PLATFORM_NAME_MAX_LEN]; + int sfp_num; + int led_num; + int psu_num; + int fan_num; + int thermal_num; + int cpld_num; + bool psu_fixed; + bool fan_fixed; + int* min_fan_speed; + int* max_fan_speed; + onlp_thermal_info_t* tinfo; + char** thermal_fnames; + onlp_led_info_t* linfo; + char** led_fnames; + int psu_type; + int led_type; + onlp_fan_info_t* finfo; + fan_path_T* fan_fnames; + int fan_type; + int first_psu_fan_id; +} mlnx_platform_info_t; + +#define PSU1_ID 1 +#define PSU2_ID 2 +#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s" +#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" +#define IDPROM_PATH "/bsp/eeprom/%s%d_info" + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +/* CPU thermal_threshold */ +typedef enum cpu_thermal_threshold_e { + CPU_THERMAL_THRESHOLD_WARNING_DEFAULT = 87000, + CPU_THERMAL_THRESHOLD_ERROR_DEFAULT = 100000, + CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 105000, +} cpu_thermal_threshold_t; + +/* Shortcut for CPU thermal threshold value. */ +#define CPU_THERMAL_THRESHOLD_INIT_DEFAULTS \ + { CPU_THERMAL_THRESHOLD_WARNING_DEFAULT, \ + CPU_THERMAL_THRESHOLD_ERROR_DEFAULT, \ + CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } + +/* Asic thermal_threshold */ +typedef enum asic_thermal_threshold_e { + ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT = 105000, + ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT = 115000, + ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 120000, +} asic_thermal_threshold_t; + +/* Shortcut for CPU thermal threshold value. */ +#define ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS \ + { ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT, \ + ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT, \ + ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } + +int mc_get_kernel_ver(void); + +int mc_get_platform_info(mlnx_platform_info_t* mlnx_platform); + +int onlp_fani_get_min_rpm(int id); + +int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, + onlp_fan_info_t* fan_info); + +mlnx_platform_info_t* get_platform_info(); + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); + +#endif /* __MLNX_COMMON_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.x b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.x new file mode 100644 index 00000000..2ab1c9da --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.x @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_config.h b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_config.h new file mode 100644 index 00000000..8de249db --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_config.h @@ -0,0 +1,127 @@ +/**************************************************************************//** + * + * @file + * @brief mlnx_common Configuration Header + * + * @addtogroup mlnx_common-config + * @{ + * + *****************************************************************************/ +#ifndef __MLNX_COMMON_CONFIG_H__ +#define __MLNX_COMMON_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef MLNX_COMMON_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * MLNX_COMMON_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef MLNX_COMMON_CONFIG_INCLUDE_LOGGING +#define MLNX_COMMON_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT +#define MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT +#define MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * MLNX_COMMON_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef MLNX_COMMON_CONFIG_PORTING_STDLIB +#define MLNX_COMMON_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS MLNX_COMMON_CONFIG_PORTING_STDLIB +#endif + +/** + * MLNX_COMMON_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef MLNX_COMMON_CONFIG_INCLUDE_UCLI +#define MLNX_COMMON_CONFIG_INCLUDE_UCLI 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct mlnx_common_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} mlnx_common_config_settings_t; + +/** Configuration settings table. */ +/** mlnx_common_config_settings table. */ +extern mlnx_common_config_settings_t mlnx_common_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* mlnx_common_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int mlnx_common_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "mlnx_common_porting.h" + +#endif /* __MLNX_COMMON_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_dox.h b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_dox.h new file mode 100644 index 00000000..e81bf8e0 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * mlnx_common Doxygen Header + * + *****************************************************************************/ +#ifndef __MLNX_COMMON_DOX_H__ +#define __MLNX_COMMON_DOX_H__ + +/** + * @defgroup mlnx_common mlnx_common - mlnx_common Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup mlnx_common-mlnx_common Public Interface + * @defgroup mlnx_common-config Compile Time Configuration + * @defgroup mlnx_common-porting Porting Macros + * + * @} + * + */ + +#endif /* __MLNX_COMMON_DOX_H__ */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_porting.h b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_porting.h new file mode 100644 index 00000000..7ee1207a --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief mlnx_common Porting Macros. + * + * @addtogroup mlnx_common-porting + * @{ + * + *****************************************************************************/ +#ifndef __MLNX_COMMON_PORTING_H__ +#define __MLNX_COMMON_PORTING_H__ + + +/* */ +#if MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef MLNX_COMMON_MALLOC + #if defined(GLOBAL_MALLOC) + #define MLNX_COMMON_MALLOC GLOBAL_MALLOC + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_MALLOC malloc + #else + #error The macro MLNX_COMMON_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_FREE + #if defined(GLOBAL_FREE) + #define MLNX_COMMON_FREE GLOBAL_FREE + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_FREE free + #else + #error The macro MLNX_COMMON_FREE is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_MEMSET + #if defined(GLOBAL_MEMSET) + #define MLNX_COMMON_MEMSET GLOBAL_MEMSET + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_MEMSET memset + #else + #error The macro MLNX_COMMON_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define MLNX_COMMON_MEMCPY GLOBAL_MEMCPY + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_MEMCPY memcpy + #else + #error The macro MLNX_COMMON_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define MLNX_COMMON_STRNCPY GLOBAL_STRNCPY + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_STRNCPY strncpy + #else + #error The macro MLNX_COMMON_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define MLNX_COMMON_VSNPRINTF GLOBAL_VSNPRINTF + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_VSNPRINTF vsnprintf + #else + #error The macro MLNX_COMMON_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define MLNX_COMMON_SNPRINTF GLOBAL_SNPRINTF + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_SNPRINTF snprintf + #else + #error The macro MLNX_COMMON_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef MLNX_COMMON_STRLEN + #if defined(GLOBAL_STRLEN) + #define MLNX_COMMON_STRLEN GLOBAL_STRLEN + #elif MLNX_COMMON_CONFIG_PORTING_STDLIB == 1 + #define MLNX_COMMON_STRLEN strlen + #else + #error The macro MLNX_COMMON_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __MLNX_COMMON_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/make.mk b/packages/platforms/mellanox/any/src/mlnx_common/module/make.mk new file mode 100644 index 00000000..c6e5d32e --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +mlnx_common_INCLUDES := -I $(THIS_DIR)inc +mlnx_common_INTERNAL_INCLUDES := -I $(THIS_DIR)src +mlnx_common_DEPENDMODULE_ENTRIES := init:mlnx_common ucli:mlnx_common diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/Makefile b/packages/platforms/mellanox/any/src/mlnx_common/module/src/Makefile new file mode 100644 index 00000000..df367563 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/Makefile @@ -0,0 +1,8 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py mlnx_common_ucli.c diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/make.mk b/packages/platforms/mellanox/any/src/mlnx_common/module/src/make.mk new file mode 100644 index 00000000..5153671b --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := mlnx_common +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_config.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_config.c new file mode 100644 index 00000000..72849a4f --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_config.c @@ -0,0 +1,75 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __mlnx_common_config_STRINGIFY_NAME(_x) #_x +#define __mlnx_common_config_STRINGIFY_VALUE(_x) __mlnx_common_config_STRINGIFY_NAME(_x) +mlnx_common_config_settings_t mlnx_common_config_settings[] = +{ +#ifdef MLNX_COMMON_CONFIG_INCLUDE_LOGGING + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_INCLUDE_LOGGING), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_INCLUDE_LOGGING) }, +#else +{ MLNX_COMMON_CONFIG_INCLUDE_LOGGING(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef MLNX_COMMON_CONFIG_PORTING_STDLIB + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_PORTING_STDLIB), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_PORTING_STDLIB) }, +#else +{ MLNX_COMMON_CONFIG_PORTING_STDLIB(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ MLNX_COMMON_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef MLNX_COMMON_CONFIG_INCLUDE_UCLI + { __mlnx_common_config_STRINGIFY_NAME(MLNX_COMMON_CONFIG_INCLUDE_UCLI), __mlnx_common_config_STRINGIFY_VALUE(MLNX_COMMON_CONFIG_INCLUDE_UCLI) }, +#else +{ MLNX_COMMON_CONFIG_INCLUDE_UCLI(__mlnx_common_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __mlnx_common_config_STRINGIFY_VALUE +#undef __mlnx_common_config_STRINGIFY_NAME + +const char* +mlnx_common_config_lookup(const char* setting) +{ + int i; + for(i = 0; mlnx_common_config_settings[i].name; i++) { + if(strcmp(mlnx_common_config_settings[i].name, setting)) { + return mlnx_common_config_settings[i].value; + } + } + return NULL; +} + +int +mlnx_common_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; mlnx_common_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", mlnx_common_config_settings[i].name, mlnx_common_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_enums.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_enums.c new file mode 100644 index 00000000..924d6e6e --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_enums.c @@ -0,0 +1,9 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c new file mode 100644 index 00000000..caa088ca --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c @@ -0,0 +1,411 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include "mlnx_common/mlnx_common.h" +#include "mlnx_common_log.h" + +#define PREFIX_PATH "/bsp/fan/" +#define PREFIX_MODULE_PATH "/bsp/module/" + +#define FAN_STATUS_OK 1 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +int onlp_fani_get_min_rpm(int id); + +static int +_onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) +{ + const char sanity_checker[] = "MLNX"; + const uint8_t sanity_offset = 8; + const uint8_t sanity_len = 4; + const uint8_t block1_start = 12; + const uint8_t block1_type = 1; + const uint8_t block2_start = 14; + const uint8_t block2_type = 5; + const uint8_t serial_offset = 8; + const uint8_t serial_len = 24; + const uint8_t part_len = 20; + const uint8_t fan_offset = 14; + const uint8_t multiplier = 16; + uint8_t data[256] = {0}; + uint8_t offset = 0; + uint8_t temp = 0; + int rv = 0; + int len = 0; + + /* We have 4 FRU with 2 fans(total 8 fans). + Eeprom is per FRU but not per fan. + So, need to convert fan ID to FRU ID.*/ + if (local_id % 2) { + local_id = local_id / 2 + 1; + } else { + local_id /= 2; + } + + rv = onlp_file_read(data, sizeof(data), &len, + IDPROM_PATH, "fan", local_id); + if (rv < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* Sanity checker */ + if (strncmp(sanity_checker, (char*)&data[sanity_offset], sanity_len)) { + return ONLP_STATUS_E_INVALID; + } + + /* Checking eeprom block type with S/N and P/N */ + if (data[block1_start + 1] != block1_type) { + return ONLP_STATUS_E_INVALID; + } + + /* Reading serial number */ + offset = data[block1_start] * multiplier + serial_offset; + strncpy(info->serial, (char *)&data[offset], serial_len); + + /* Reading part number */ + offset += serial_len; + strncpy(info->model, (char *)&data[offset], part_len); + + /* Reading fan direction */ + if (data[block2_start + 1] != block2_type) { + return ONLP_STATUS_E_INVALID; + } + offset = data[block2_start] * multiplier + fan_offset; + temp = data[offset]; + switch (temp) { + case 1: + info->caps |= ONLP_FAN_CAPS_F2B; + break; + case 2: + info->caps |= ONLP_FAN_CAPS_B2F; + break; + default: + break; + } + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) +{ + int r_val, ret; + float range = 0; + float temp = 0; + float fru_index = 0; + const char fan_model[]=FAN_MODEL; + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + if(mlnx_platform_info->fan_type == FAN_TYPE_NO_EEPROM) + strncpy(info->model, fan_model, sizeof(info->model)); + + if(!mlnx_platform_info->fan_fixed) { + /* We have 4 FRU with 2 fans(total 8 fans). + Eeprom is per FRU but not per fan. + So, need to convert fan ID to FRU ID.*/ + if (local_id % 2) { + fru_index = local_id / 2 + 1; + } else { + fru_index = local_id / 2; + } + /* get fan status + */ + if(mlnx_platform_info->fan_type == FAN_TYPE_EEPROM) { + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_MODULE_PATH, mlnx_platform_info->fan_fnames[(int)fru_index].status); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (r_val != FAN_STATUS_OK) { + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + } + else { + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_MODULE_PATH, mlnx_platform_info->fan_fnames[local_id].status); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + if (r_val != FAN_STATUS_OK) { + return ONLP_STATUS_OK; + } + } + } + /* Fixed system FAN is always present */ + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan speed */ + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_get); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = r_val; + + /* check failure */ + if (info->rpm <= 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) { + /* get fan min speed */ + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].min); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + mlnx_platform_info->min_fan_speed[local_id] = r_val; + + /* get fan max speed */ + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].max); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + mlnx_platform_info->max_fan_speed[local_id] = r_val; + + /* get speed percentage from rpm */ + range = mlnx_platform_info->max_fan_speed[local_id] - mlnx_platform_info->min_fan_speed[local_id]; + if (range > 0) { + temp = ((float)info->rpm - (float)mlnx_platform_info->min_fan_speed[local_id]) / range * 40.0 + 60.0; + if (temp < PERCENTAGE_MIN) { + temp = PERCENTAGE_MIN; + } + info->percentage = (int)temp; + } else { + return ONLP_STATUS_E_INTERNAL; + } + } + if(mlnx_platform_info->fan_type == FAN_TYPE_NO_EEPROM) + return ONLP_STATUS_OK; + else + return _onlp_fani_read_fan_eeprom(local_id, info); + +} + + +static int +_onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) +{ + int r_val, ret; + float rpms_per_perc = 0.0; + float temp = 0.0; + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + /* get fan status + */ + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_MODULE_PATH, mlnx_platform_info->fan_fnames[local_id].status); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (r_val != FAN_STATUS_OK) { + if(mlnx_platform_info->fan_type == FAN_TYPE_EEPROM) + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan speed + */ + ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_get); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = r_val; + + /* check failure */ + if (info->rpm <= 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + /* get speed percentage from rpm */ + rpms_per_perc = PSU_FAN_RPM_MIN / PERCENTAGE_MIN; + temp = (float)info->rpm / rpms_per_perc; + if (temp < PERCENTAGE_MIN) { + temp = PERCENTAGE_MIN; + } + info->percentage = (int)temp; + + if (0 != psu_read_eeprom((local_id-mlnx_platform_info->first_psu_fan_id)+1, NULL, info)) + return ONLP_STATUS_E_INTERNAL; + + return ONLP_STATUS_OK; +} + + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id = 0; + VALIDATE(id); + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + local_id = ONLP_OID_ID_GET(id); + + *info = mlnx_platform_info->finfo[local_id]; + + if(local_idfirst_psu_fan_id) + rc =_onlp_fani_info_get_fan(local_id, info); + else + rc = _onlp_fani_info_get_fan_on_psu(local_id, (local_id-mlnx_platform_info->first_psu_fan_id)+1, info); + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + float temp = 0.0; + int rv = 0, local_id = 0, nbytes = 10; + char r_data[10] = {0}; + onlp_fan_info_t* info = NULL; + + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + info = &mlnx_platform_info->finfo[local_id]; + + if (0 == (ONLP_FAN_CAPS_SET_RPM & info->caps)) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* reject rpm=0% (rpm=0%, stop fan) */ + if (0 == rpm) { + return ONLP_STATUS_E_INVALID; + } + + /* Set fan speed + Converting percent to driver value. + Driver accept value in range between 153 and 255. + Value 153 is minimum rpm. + Value 255 is maximum rpm. + */ + if (local_id > sizeof(mlnx_platform_info->min_fan_speed)/sizeof(mlnx_platform_info->min_fan_speed[0])) { + return ONLP_STATUS_E_INTERNAL; + } + if (mlnx_platform_info->max_fan_speed[local_id] - mlnx_platform_info->min_fan_speed[local_id] < 0) { + return ONLP_STATUS_E_INTERNAL; + } + if (rpm < mlnx_platform_info->min_fan_speed[local_id] || rpm > mlnx_platform_info->max_fan_speed[local_id]) { + return ONLP_STATUS_E_PARAM; + } + + temp = (rpm - mlnx_platform_info->min_fan_speed[local_id]) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / + (mlnx_platform_info->max_fan_speed[local_id] - mlnx_platform_info->min_fan_speed[local_id]) + RPM_MAGIC_MIN; + + snprintf(r_data, sizeof(r_data), "%d", (int)temp); + nbytes = strnlen(r_data, sizeof(r_data)); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + mlnx_platform_info->fan_fnames[local_id].r_speed_set); + if (rv < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + float temp = 0.0; + int rv = 0, local_id = 0, nbytes = 10; + char r_data[10] = {0}; + onlp_fan_info_t* info = NULL; + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + VALIDATE(id); + local_id = ONLP_OID_ID_GET(id); + info = &mlnx_platform_info->finfo[local_id]; + + if (0 == (ONLP_FAN_CAPS_SET_PERCENTAGE & info->caps)) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* reject p=0% (p=0%, stop fan) */ + if (0 == p) { + return ONLP_STATUS_E_INVALID; + } + + if (p < PERCENTAGE_MIN || p > PERCENTAGE_MAX) { + return ONLP_STATUS_E_PARAM; + } + + /* Set fan speed + Converting percent to driver value. + Driver accept value in range between 153 and 255. + Value 153 is 60%. + Value 255 is 100%. + */ + temp = (p - PERCENTAGE_MIN) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / + (PERCENTAGE_MAX - PERCENTAGE_MIN) + RPM_MAGIC_MIN; + + snprintf(r_data, sizeof(r_data), "%d", (int)temp); + nbytes = strnlen(r_data, sizeof(r_data)); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + mlnx_platform_info->fan_fnames[local_id].r_speed_set); + if (rv < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_fani_get_min_rpm(int id) +{ + int r_val; + + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + + if (onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[id].min) < 0) + return ONLP_STATUS_E_INTERNAL; + + return r_val; +} diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h new file mode 100644 index 00000000..d75227d9 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h @@ -0,0 +1,17 @@ +/**************************************************************************//** + * + * mlnx_common Internal Header + * + *****************************************************************************/ +#ifndef __MLNX_COMMON_INT_H__ +#define __MLNX_COMMON_INT_H__ + +#include +#include + +#define MAX_NUM_OF_CPLD 3 +#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld" + +mlnx_platform_info_t* get_platform_info(void); + +#endif /* __MLNX_COMMON_INT_H__ */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c new file mode 100644 index 00000000..8669cf52 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c @@ -0,0 +1,346 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#define prefix_path "/bsp/led/led_" +#define driver_value_len 50 + +#define LED_MODE_OFF "none" +#define LED_MODE_GREEN "green" +#define LED_MODE_RED "red" +#define LED_MODE_BLUE "blue" +#define LED_MODE_GREEN_BLINK "green_blink" +#define LED_MODE_RED_BLINK "red_blink" +#define LED_MODE_BLUE_BLINK "blue_blink" +#define LED_MODE_AUTO "cpld_control" + +#define LED_BLINK_PERIOD "100" +#define LED_ON "1" +#define LED_OFF "0" +#define LED_BLINK_PERIOD_LEN 3 +#define LED_MODE_LEN 1 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ + +typedef struct led_light_mode_map { + int id; + char* driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { + {LED_SYSTEM, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_SYSTEM, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_SYSTEM, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_SYSTEM, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_SYSTEM, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_SYSTEM, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_FAN1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN1, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_FAN1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_FAN1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_FAN2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN2, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_FAN2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_FAN2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_FAN3, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN3, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN3, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN3, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_FAN3, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_FAN3, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_FAN4, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN4, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN4, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN4, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_FAN4, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_FAN4, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_PSU, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_PSU, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_PSU, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_PSU, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_PSU, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_PSU, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_FAN, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_FAN, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_FAN, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_PSU1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_PSU1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_PSU1, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_PSU1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_PSU1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_PSU2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_PSU2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, + {LED_PSU2, LED_MODE_RED, ONLP_LED_MODE_RED}, + {LED_PSU2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, + {LED_PSU2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, + {LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, + + {LED_UID, LED_MODE_OFF, ONLP_LED_MODE_OFF}, + {LED_UID, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, + {LED_UID, LED_MODE_BLUE_BLINK, ONLP_LED_MODE_BLUE_BLINKING}, + {LED_UID, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +}; + +typedef struct led_colors { + int id; + const char* color1; + const char* color2; +} led_colors_t; + +static led_colors_t led_colors_map[] = { + {LED_SYSTEM, "green", "red"}, + {LED_FAN1, "green", "red"}, + {LED_FAN2, "green", "red"}, + {LED_FAN3, "green", "red"}, + {LED_FAN4, "green", "red"}, + {LED_PSU, "green", "red"}, + {LED_FAN, "green", "red"}, + {LED_PSU1, "green", "red"}, + {LED_PSU2, "green", "red"}, + {LED_UID, "blue", NULL}, +}; + +static int driver_to_onlp_led_mode(int id, char* driver_led_mode) +{ + char *pos; + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + if ((pos=strchr(driver_led_mode, '\n')) != NULL) + *pos = '\0'; + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && + !strncmp(led_map[i].driver_led_mode, driver_led_mode, driver_value_len)) + { + return led_map[i].onlp_led_mode; + } + } + + return ONLP_STATUS_OK; +} + +static char* onlp_to_driver_led_mode(int id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return LED_MODE_OFF; +} + +static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id = ONLP_OID_ID_GET(id); + char color[10]= {0}; + int blinking = 0; + + switch (mode) { + case ONLP_LED_MODE_RED_BLINKING: + strcpy(color, "red"); + blinking = 1; + break; + case ONLP_LED_MODE_GREEN_BLINKING: + strcpy(color, "green"); + blinking = 1; + break; + case ONLP_LED_MODE_BLUE_BLINKING: + strcpy(color, "blue"); + blinking = 1; + break; + case ONLP_LED_MODE_YELLOW_BLINKING: + strcpy(color, "yellow"); + blinking = 1; + break; + case ONLP_LED_MODE_RED: + strcpy(color, "red"); + break; + case ONLP_LED_MODE_GREEN: + strcpy(color, "green"); + break; + case ONLP_LED_MODE_BLUE: + strcpy(color, "blue"); + break; + case ONLP_LED_MODE_YELLOW: + strcpy(color, "yellow"); + break; + default: + return ONLP_STATUS_E_PARAM; + } + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + if (blinking) { + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_off", prefix_path, mlnx_platform_info->led_fnames[local_id], color); + onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, + "%s%s_%s_delay_on", prefix_path, mlnx_platform_info->led_fnames[local_id], color); + } + onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, + "%s%s_%s", prefix_path, mlnx_platform_info->led_fnames[local_id], color); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int len, local_id = 0; + uint8_t data[driver_value_len] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + /* Set the onlp_oid_hdr_t and capabilities */ + *info = mlnx_platform_info->linfo[ONLP_OID_ID_GET(id)]; + + /* Get LED mode */ + if (mc_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + char* cmd = aim_fstrdup("%s%s_state", prefix_path, mlnx_platform_info->led_fnames[local_id]); + if(system(cmd) != 0) { + aim_free(cmd); + return ONLP_STATUS_E_INTERNAL; + } + aim_free(cmd); + } + + if (onlp_file_read(data, sizeof(data), &len, "%s%s", + prefix_path, mlnx_platform_info->led_fnames[local_id]) != 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, (char*)data); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + if (!on_or_off) { + if (mc_get_kernel_ver() < KERNEL_VERSION(4,9,30)) + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + else { + int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); + for (i = 0; i < nsize; i++) + { + if (id == led_colors_map[i].id) + break; + } + if (led_colors_map[i].color1) + onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, + "%s%s_%s", prefix_path, mlnx_platform_info->led_fnames[id], led_colors_map[i].color1); + } + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char* driver_led_mode; + int nbytes; + + VALIDATE(id); + + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + if (mc_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { + local_id = ONLP_OID_ID_GET(id); + driver_led_mode = onlp_to_driver_led_mode(local_id, mode); + nbytes = strnlen(driver_led_mode, driver_value_len); + if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, + "%s%s", prefix_path, mlnx_platform_info->led_fnames[local_id]) != 0) { + return ONLP_STATUS_E_INTERNAL; + } + } else { + if (led_set_mode(id, mode) != 0) { + return ONLP_STATUS_E_INTERNAL; + } + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.c new file mode 100644 index 00000000..4bb47490 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.c @@ -0,0 +1,17 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "mlnx_common_log.h" +/* + * mlnx_common log struct. + */ +AIM_LOG_STRUCT_DEFINE( + MLNX_COMMON_CONFIG_LOG_OPTIONS_DEFAULT, + MLNX_COMMON_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + MLNX_COMMON_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.h b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.h new file mode 100644 index 00000000..7034e9af --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __MLNX_COMMON_LOG_H__ +#define __MLNX_COMMON_LOG_H__ + +#define AIM_LOG_MODULE_NAME mlnx_common +#include + +#endif /* __MLNX_COMMON_LOG_H__ */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_module.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_module.c new file mode 100644 index 00000000..e2454d05 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_module.c @@ -0,0 +1,22 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "mlnx_common_log.h" + +static int +datatypes_init__(void) +{ +#define MLNX_COMMON_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __mlnx_common_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_psui.c similarity index 59% rename from packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c rename to packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_psui.c index f5555b60..e9c557ec 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_psui.c @@ -19,7 +19,7 @@ *
************************************************************ * - * + * PSU Platform Implementation Defaults. * ***********************************************************/ #include @@ -27,7 +27,8 @@ #include #include #include -#include "platform_lib.h" +#include +#include "mlnx_common_log.h" #define PSU_STATUS_PRESENT 1 #define PSU_CABLE_PRESENT 1 @@ -35,6 +36,8 @@ #define PSU_NODE_MAX_INT_LEN 8 #define PSU_NODE_MAX_PATH_LEN 64 +#define PSU_MODEL "POW000167" + #define VALIDATE(_id) \ do { \ if(!ONLP_OID_IS_PSU(_id)) { \ @@ -42,35 +45,31 @@ } \ } while(0) -static int +int psu_module_info_get(int id, char *node, int *value) { - int len, ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; + int ret = 0; *value = 0; - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, - PSU_MODULE_PREFIX, id, node); - if (ret == 0) { - *value = atoi(buf); + ret = onlp_file_read_int(value, PSU_MODULE_PREFIX, id, node); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; } return ret; } -static int +int psu_power_info_get(int id, char *node, int *value) { - int len, ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; + int ret = 0; *value = 0; - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, - PSU_POWER_PREFIX, id, node); - if (ret == 0) { - *value = atoi(buf); + ret = onlp_file_read_int(value, PSU_POWER_PREFIX, id, node); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; } return ret; @@ -82,12 +81,63 @@ onlp_psui_init(void) return ONLP_STATUS_OK; } +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + static int -_psu_info_get(onlp_psu_info_t* info) +_psu_info_get_type1(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + const char psu_model[]=PSU_MODEL; + + strncpy(info->model, psu_model, sizeof(info->model)); + + /* Set capability */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Read voltage, current and power */ + if (psu_power_info_get(index, "volt", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_power_info_get(index, "curr", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + info->mpout = info->mvout * info->miout; + info->caps |= ONLP_PSU_CAPS_POUT; + + info->mpin = ((int)(info->mpout / 91)) * 100; + info->caps |= ONLP_PSU_CAPS_PIN; + + return ONLP_STATUS_OK; +} + +static int +_psu_info_get_type2(onlp_psu_info_t* info) { int val = 0; int index = ONLP_OID_ID_GET(info->hdr.id); + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); /* Set capability */ info->caps = ONLP_PSU_CAPS_AC; @@ -97,12 +147,12 @@ _psu_info_get(onlp_psu_info_t* info) } /* Set the associated oid_table */ - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + mlnx_platform_info->fan_num); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + mlnx_platform_info->thermal_num); /* Read voltage, current and power */ if (psu_power_info_get(index, "volt_in", &val) == 0 && - 0 != val) { + 0 != val) { info->mvin = val; info->caps |= ONLP_PSU_CAPS_VIN; @@ -138,19 +188,20 @@ _psu_info_get(onlp_psu_info_t* info) return psu_read_eeprom(index, info, NULL); } -/* - * Get all information about the given PSU oid. - */ -static onlp_psu_info_t pinfo[] = +int _psu_info_get(onlp_psu_info_t* info) { - { }, /* Not used */ - { - { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, - }, - { - { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + int res; + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + switch(mlnx_platform_info->psu_type) { + case PSU_TYPE_1: + res=_psu_info_get_type1(info); + break; + case PSU_TYPE_2: + res=_psu_info_get_type2(info); + break; } -}; + return res; +} int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) @@ -164,37 +215,39 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) memset(info, 0, sizeof(onlp_psu_info_t)); *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - /* Get the present state */ - if (psu_module_info_get(index, "status", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index); - } + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + if(mlnx_platform_info->psu_fixed == false) { + /* Get the present state */ + if (psu_module_info_get(index, "status", &val) != 0) { + AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index); + } - if (val != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; - } - else - info->status |= ONLP_PSU_STATUS_PRESENT; + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + return ONLP_STATUS_OK; + } + else + info->status |= ONLP_PSU_STATUS_PRESENT; + } + else { + /* Fixed system, PSU is always present */ + info->status |= ONLP_PSU_STATUS_PRESENT; + } /* Get the cable preset state */ if (psu_module_info_get(index, "pwr_status", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index); + AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index); } if (val != PSU_CABLE_PRESENT) { info->status |= ONLP_PSU_STATUS_UNPLUGGED; return ONLP_STATUS_OK; } - + if(mlnx_platform_info->psu_fixed == false) { + info->status |= ONLP_PSU_STATUS_PRESENT; + } ret = _psu_info_get(info); return ret; } - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c similarity index 75% rename from packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c rename to packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c index 95050cc0..1a11a2f3 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c @@ -23,8 +23,7 @@ * ***********************************************************/ #include - -#include /* For O_RDWR && open */ +#include #include #include #include @@ -32,17 +31,17 @@ #include #include #include -#include "platform_lib.h" +#include "mlnx_common_log.h" +#include "mlnx_common_int.h" #define MAX_SFP_PATH 64 #define SFP_SYSFS_VALUE_LEN 20 static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define NUM_OF_SFP_PORT 16 -#define SFP_PRESENT_STATUS "good" -#define SFP_NOT_PRESENT_STATUS "not_connected" + +int get_sfp_port_num(void); static int -msn2100_sfp_node_read_int(char *node_path, int *value) +mc_sfp_node_read_int(char *node_path, int *value) { int data_len = 0, ret = 0; char buf[SFP_SYSFS_VALUE_LEN] = {0}; @@ -50,7 +49,7 @@ msn2100_sfp_node_read_int(char *node_path, int *value) char sfp_present_status[16]; char sfp_not_present_status[16]; - if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { + if (mc_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { strcpy(sfp_present_status, "1"); strcpy(sfp_not_present_status, "0"); } else { @@ -72,17 +71,17 @@ msn2100_sfp_node_read_int(char *node_path, int *value) } static char* -msn2100_sfp_get_port_path(int port, char *node_name) +mc_sfp_get_port_path(int port, char *node_name) { if (node_name) - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); + sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); else sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); return sfp_node_path; } static char* -msn2100_sfp_convert_i2c_path(int port, int devaddr) +mc_sfp_convert_i2c_path(int port, int devaddr) { sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); return sfp_node_path; @@ -104,9 +103,11 @@ int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) { int p = 1; + mlnx_platform_info_t* platform_info = get_platform_info(); + AIM_BITMAP_CLR_ALL(bmap); - for (; p <= NUM_OF_SFP_PORT; p++) { + for (; p <= platform_info->sfp_num; p++) { AIM_BITMAP_SET(bmap, p); } @@ -122,9 +123,9 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present = -1; - char* path = msn2100_sfp_get_port_path(port, "_status"); + char* path = mc_sfp_get_port_path(port, "_status"); - if (msn2100_sfp_node_read_int(path, &present) != 0) { + if (mc_sfp_node_read_int(path, &present) != 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -137,8 +138,9 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { int ii = 1; int rc = 0; + mlnx_platform_info_t* platform_info = get_platform_info(); - for (;ii <= NUM_OF_SFP_PORT; ii++) { + for (;ii <= platform_info->sfp_num; ii++) { rc = onlp_sfpi_is_present(ii); AIM_BITMAP_MOD(dst, ii, (1 == rc) ? 1 : 0); } @@ -149,7 +151,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = msn2100_sfp_get_port_path(port, NULL); + char* path = mc_sfp_get_port_path(port, NULL); /* * Read the SFP eeprom into data[] @@ -170,7 +172,7 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - char* path = msn2100_sfp_convert_i2c_path(port, devaddr); + char* path = mc_sfp_convert_i2c_path(port, devaddr); uint8_t data; int fd; int nrd; @@ -193,16 +195,10 @@ onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) return data; } -int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - char* path = msn2100_sfp_convert_i2c_path(port, devaddr); + char* path = mc_sfp_convert_i2c_path(port, devaddr); uint16_t data; int fd; int nrd; @@ -227,33 +223,8 @@ onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) return data; } -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - int onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } - diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sysi.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sysi.c new file mode 100644 index 00000000..6fa3a415 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sysi.c @@ -0,0 +1,391 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mlnx_common_log.h" +#include "mlnx_common_int.h" +#include "mlnx_common/mlnx_common.h" + +mlnx_platform_info_t mlnx_platform_info; + +static char arr_cplddev_name[MAX_NUM_OF_CPLD][30] = +{ + "cpld_brd_version", + "cpld_mgmt_version", + "cpld_port_version" +}; + +mlnx_platform_info_t* get_platform_info() +{ + return &mlnx_platform_info; +} + +const char* onlp_sysi_platform_get() +{ + if (mc_get_platform_info(&mlnx_platform_info) < 0) { + AIM_LOG_ERROR("Unable to get paltform info!\n"); + return NULL; + } + else + return mlnx_platform_info.onl_platform_name; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int i, v[MAX_NUM_OF_CPLD]={0}; + mlnx_platform_info_t* platform_info = get_platform_info(); + + for (i=0; i < platform_info->cpld_num; i++) { + v[i] = 0; + if(onlp_file_read_int(v+i, "%s/%s", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + } + switch (platform_info->cpld_num) { + case 1: + pi->cpld_versions = aim_fstrdup("unified=%d", v[0]); /* TBD Currently not exist */ + break; + case 2: + pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d", v[0], v[1]); + break; + case 3: + pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d, port=%d", v[0], v[1], v[2]); + break; + case 0: + default: + AIM_LOG_ERROR("Incorrect CPLD Number %d\n", platform_info->cpld_num); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +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) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + for (i = 1; i <= mlnx_platform_info.thermal_num; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + for (i = 1; i <= mlnx_platform_info.led_num; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + for (i = 1; i <= mlnx_platform_info.psu_num; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + for (i = 1; i <= mlnx_platform_info.fan_num; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_onie_info_get(onlp_onie_info_t* onie) +{ + int rv = onlp_onie_read_json(onie, + "/lib/platform-config/current/onl/etc/onie/eeprom.json"); + if(rv >= 0) { + if(onie->platform_name) { + aim_free(onie->platform_name); + } + onie->platform_name = aim_strdup(mlnx_platform_info.onl_platform_name); + } + + return rv; +} + +int +onlp_sysi_platform_manage_leds_type1(void) +{ + int fan_number, psu_number; + onlp_led_mode_t mode, system_mode; + int min_fan_speed; + int psu_led_id[2] = { LED_PSU1, LED_PSU2 }; + int fan_problem = 0; + int psu_problem = 0; + + /* + * FAN Indicators + * + * Green - Fan is operating + * Red - No power or Fan failure + * Off - No power + * + */ + mode = ONLP_LED_MODE_GREEN; + for( fan_number = 1; fan_number<= mlnx_platform_info.fan_num; fan_number+=2) + { + /* each 2 fans had same led_fan */ + onlp_fan_info_t fi; + /* check fans */ + if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else if( (fi.status & ONLP_FAN_STATUS_PRESENT) == 0) { + if(mlnx_platform_info.fan_fixed == false) { + /* Not present */ + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + else if(fi.status & ONLP_FAN_STATUS_FAILED) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else + { + min_fan_speed = onlp_fani_get_min_rpm(fan_number); + if( fi.rpm < min_fan_speed) + { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + /* check fan i+1 */ + if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else if( (fi.status & 0x1) == 0) { + if(mlnx_platform_info.fan_fixed == false) { + /* Not present */ + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + else if(fi.status & ONLP_FAN_STATUS_FAILED) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else + { + min_fan_speed = onlp_fani_get_min_rpm(fan_number+1); + if( fi.rpm < min_fan_speed) + { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + } + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_FAN), mode); + + for (psu_number = 1; psu_number <= mlnx_platform_info.psu_num; psu_number++) + { + onlp_psu_info_t pi; + mode = ONLP_LED_MODE_GREEN; + if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { + mode = ONLP_LED_MODE_RED; + psu_problem = 1; + } + else { + if(mlnx_platform_info.psu_fixed) { + /* Fixed system, PSU always in. Check only cable plugged. */ + if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + mode = ONLP_LED_MODE_RED; + psu_problem = 1; + } + } + else { + if((pi.status & ONLP_PSU_STATUS_PRESENT) == 0) { + /* Not present */ + psu_problem = 1; + } + else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + psu_problem = 1; + } + } + } + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, psu_led_id[(psu_number-1)]), mode); + } + + /* Set System status LED green if no problem in FANs or PSUs */ + if (fan_problem || psu_problem) + system_mode = ONLP_LED_MODE_RED; + else + system_mode = ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_SYSTEM), system_mode); + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds_type2(void) +{ + int fan_number, psu_number; + onlp_led_mode_t mode, system_mode; + int min_fan_speed; + + int fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 }; + + int fan_problem = 0; + int psu_problem = 0; + + /* + * FAN Indicators + * + * Green - Fan is operating + * Red - No power or Fan failure + * Off - No power + * + */ + for( fan_number = 1; fan_number <= mlnx_platform_info.fan_num; fan_number+=2) + { + /* each 2 fans had same led_fan */ + onlp_fan_info_t fi; + /* check fans */ + mode = ONLP_LED_MODE_GREEN; + if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else if( (fi.status & ONLP_FAN_STATUS_PRESENT) == 0) { + if(mlnx_platform_info.fan_fixed == false) { + /* Not present */ + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + else if(fi.status & ONLP_FAN_STATUS_FAILED) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else + { + min_fan_speed = onlp_fani_get_min_rpm(fan_number); + if( fi.rpm < min_fan_speed) + { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + /* check fan i+1 */ + if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else if( (fi.status & 0x1) == 0) { + if(mlnx_platform_info.fan_fixed == false) { + /* Not present */ + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + else if(fi.status & ONLP_FAN_STATUS_FAILED) { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + else + { + min_fan_speed = onlp_fani_get_min_rpm(fan_number+1); + if( fi.rpm < min_fan_speed) + { + mode = ONLP_LED_MODE_RED; + fan_problem = 1; + } + } + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode); + } + + for (psu_number = 1; psu_number <= mlnx_platform_info.psu_num; psu_number++) + { + onlp_psu_info_t pi; + if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { + psu_problem = 1; + } + else { + if(mlnx_platform_info.psu_fixed) { + /* Fixed system, PSU always in. Check only cable plugged. */ + if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + mode = ONLP_LED_MODE_RED; + psu_problem = 1; + } + } + else { + if((pi.status & ONLP_PSU_STATUS_PRESENT) == 0) { + /* Not present */ + psu_problem = 1; + } + else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { + psu_problem = 1; + } + } + } + } + + if (psu_problem) + mode = ONLP_LED_MODE_RED; + else + mode = ONLP_LED_MODE_GREEN; + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_PSU), mode); + + /* Set System status LED green if no problem in FANs or PSUs */ + if (fan_problem || psu_problem) + system_mode = ONLP_LED_MODE_RED; + else + system_mode = ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), system_mode); + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + int res; + if(mlnx_platform_info.led_type == 1) + res=onlp_sysi_platform_manage_leds_type1(); + else + res=onlp_sysi_platform_manage_leds_type2(); + return res; +} diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c new file mode 100644 index 00000000..4727d3a5 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c @@ -0,0 +1,74 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include "mlnx_common/mlnx_common.h" + +#define prefix_path "/bsp/thermal" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rv, temp_base=1, local_id = 0; + int r_val; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = mlnx_platform_info->tinfo[local_id]; + + rv = onlp_file_read_int(&r_val, "%s/%s", prefix_path, mlnx_platform_info->thermal_fnames[local_id]); + if (rv < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->mcelsius = r_val / temp_base; + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ucli.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ucli.c new file mode 100644 index 00000000..296d3510 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ucli.c @@ -0,0 +1,49 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if MLNX_COMMON_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +mlnx_common_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(mlnx_common) +} + +/* */ +/* */ + +static ucli_module_t +mlnx_common_ucli_module__ = + { + "mlnx_common_ucli", + NULL, + mlnx_common_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +mlnx_common_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&mlnx_common_ucli_module__); + n = ucli_node_create("mlnx_common", NULL, &mlnx_common_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("mlnx_common")); + return n; +} + +#else +void* +mlnx_common_ucli_node_create(void) +{ + return NULL; +} +#endif diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_utils.c similarity index 94% rename from packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c rename to packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_utils.c index 5035bc48..6a45a7a6 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_utils.c @@ -32,8 +32,10 @@ #include #include #include +#include #include -#include "platform_lib.h" +#include "mlnx_common_log.h" +#include "mlnx_common_int.h" int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info) @@ -45,7 +47,7 @@ psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_i int index = 0, rv = 0, len = 0; rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, - IDPROM_PATH, "psu", psu_index); + IDPROM_PATH, "psu", psu_index); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -82,7 +84,7 @@ psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_i } int -onlp_get_kernel_ver() +mc_get_kernel_ver() { struct utsname buff; char ver[4]; diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_platform_common_int.h b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_platform_common_int.h new file mode 100644 index 00000000..314f1644 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_platform_common_int.h @@ -0,0 +1,17 @@ +/**************************************************************************//** + * + * mlnx_platform_common Internal Header + * + *****************************************************************************/ +#ifndef __MLNX_PLATFORM_COMMON_INT_H__ +#define __MLNX_PLATFORM_COMMON_INT_H__ + +#include + +#ifndef KERNEL_VERSION +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#endif + +int mpc_get_kernel_ver(void); + +#endif /* __MLNX_PLATFORM_COMMON_INT_H__ */ diff --git a/packages/platforms/mellanox/any/src/mlnx_common/utest/_make.mk b/packages/platforms/mellanox/any/src/mlnx_common/utest/_make.mk new file mode 100644 index 00000000..0eb8ffeb --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/utest/_make.mk @@ -0,0 +1,8 @@ +############################################################################### +# +# mlnx_common Unit Test Makefile. +# +############################################################################### +UMODULE := mlnx_common +UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/utest.mk diff --git a/packages/platforms/mellanox/any/src/mlnx_common/utest/main.c b/packages/platforms/mellanox/any/src/mlnx_common/utest/main.c new file mode 100644 index 00000000..2563add8 --- /dev/null +++ b/packages/platforms/mellanox/any/src/mlnx_common/utest/main.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include +#include +#include +#include + +int aim_main(int argc, char* argv[]) +{ + printf("mlnx_common Utest Is Empty\n"); + mlnx_common_config_show(&aim_pvs_stdout); + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/lib/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/lib/Makefile index 7ed38df4..ff8eab0d 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/lib/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/lib/Makefile @@ -26,7 +26,7 @@ include $(ONL)/make/config.amd64.mk MODULE := libonlp-x86-64-mlnx-msn2100 include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF x86_64_mlnx_msn2100 onlplib +DEPENDMODULES := AIM IOF mlnx_common x86_64_mlnx_msn2100 onlplib DEPENDMODULE_HEADERS := sff include $(BUILDER)/dependmodules.mk @@ -37,6 +37,7 @@ include $(BUILDER)/so.mk .DEFAULT_GOAL := $(SHAREDLIB) GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 GLOBAL_CFLAGS += -fPIC GLOBAL_LINK_LIBS += -lpthread diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/onlpdump/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/onlpdump/Makefile index 491f363d..31edf7c0 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/onlpdump/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/onlpdump/Makefile @@ -29,7 +29,7 @@ include $(ONL)/make/config.amd64.mk MODULE := onlpdump include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF onlp x86_64_mlnx_msn2100 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS +DEPENDMODULES := AIM IOF onlp mlnx_common x86_64_mlnx_msn2100 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS include $(BUILDER)/dependmodules.mk @@ -40,6 +40,7 @@ include $(BUILDER)/bin.mk GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc GLOBAL_LINK_LIBS += -lpthread -lm include $(BUILDER)/targets.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c index f1de974e..8f05fe8a 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c @@ -27,47 +27,20 @@ #include #include #include "platform_lib.h" - -#define PREFIX_PATH "/bsp/fan/" - -#define FAN_STATUS_OK 1 - -#define PERCENTAGE_MIN 60.0 -#define PERCENTAGE_MAX 100.0 -#define RPM_MAGIC_MIN 153.0 -#define RPM_MAGIC_MAX 255.0 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 +#include "mlnx_common/mlnx_common.h" #define FAN_RESERVED 0 #define FAN_1_ON_MAIN_BOARD 1 #define FAN_2_ON_MAIN_BOARD 2 #define FAN_3_ON_MAIN_BOARD 3 #define FAN_4_ON_MAIN_BOARD 4 -#define FAN_MODEL "MEC012579" + +/* No PSU with fan, set to bigger then last fan id*/ +#define FIRST_PSU_FAN_ID 5 static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; -typedef struct fan_path_S -{ - char status[LEN_FILE_NAME]; - char r_speed_get[LEN_FILE_NAME]; - char r_speed_set[LEN_FILE_NAME]; - char min[LEN_FILE_NAME]; - char max[LEN_FILE_NAME]; -}fan_path_T; - -#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ - { #prj"fan"#id"_status", \ - #prj"fan"#id"_speed_get", \ - #prj"fan"#id"_speed_set", \ - #prj"fan"#id"_min", \ - #prj"fan"#id"_max" } - -#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) - static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), @@ -77,19 +50,8 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD) }; -#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ - 0x0, \ - (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | \ - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_RPM), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - /* Static fan information */ -onlp_fan_info_t linfo[] = { +onlp_fan_info_t finfo[] = { { }, /* Not used */ MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), @@ -97,265 +59,18 @@ onlp_fan_info_t linfo[] = { MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4) }; -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -#define OPEN_READ_FILE(fullpath, data, nbytes, len) \ - if (onlp_file_read((uint8_t*)data, nbytes, &len, fullpath) < 0) \ - return ONLP_STATUS_E_INTERNAL; \ - else \ - AIM_LOG_VERBOSE("read data: %s\n", r_data); \ - -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) -{ - int len = 0, nbytes = 10; - float range = 0; - float temp = 0; - char r_data[10] = {0}; - char fullpath[65] = {0}; - const char fan_model[]=FAN_MODEL; - - /* Fixed system FAN is always present */ - info->status |= ONLP_FAN_STATUS_PRESENT; - - strncpy(info->model, fan_model, sizeof(info->model)); - - /* get fan speed */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - info->rpm = atoi(r_data); - - /* check failure */ - if (info->rpm <= 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) { - /* get fan min speed */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].min); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - min_fan_speed[local_id] = atoi(r_data); - - /* get fan max speed */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].max); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - max_fan_speed[local_id] = atoi(r_data); - - /* get speed percentage from rpm */ - range = max_fan_speed[local_id] - min_fan_speed[local_id]; - if (range > 0) { - temp = ((float)info->rpm - (float)min_fan_speed[local_id]) / range * 40.0 + 60.0; - if (temp < PERCENTAGE_MIN) { - temp = PERCENTAGE_MIN; - } - info->percentage = (int)temp; - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - - return ONLP_STATUS_OK; -} - /* * This function will be called prior to all of onlp_fani_* functions. */ int onlp_fani_init(void) { + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->min_fan_speed=min_fan_speed; + mlnx_platform_info->max_fan_speed=max_fan_speed; + mlnx_platform_info->finfo = finfo; + mlnx_platform_info->fan_fnames = fan_path; + mlnx_platform_info->fan_type = FAN_TYPE_NO_EEPROM; + mlnx_platform_info->first_psu_fan_id = FIRST_PSU_FAN_ID; return ONLP_STATUS_OK; } - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) -{ - int rc = 0; - int local_id = 0; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - *info = linfo[local_id]; - - switch (local_id) - { - case FAN_1_ON_MAIN_BOARD: - case FAN_2_ON_MAIN_BOARD: - case FAN_3_ON_MAIN_BOARD: - case FAN_4_ON_MAIN_BOARD: - rc =_onlp_fani_info_get_fan(local_id, info); - break; - default: - rc = ONLP_STATUS_E_INVALID; - break; - } - - return rc; -} - -/* - * This function sets the speed of the given fan in RPM. - * - * This function will only be called if the fan supprots the RPM_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - float temp = 0.0; - int rv = 0, local_id = 0, nbytes = 10; - char r_data[10] = {0}; - onlp_fan_info_t* info = NULL; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - info = &linfo[local_id]; - - if (0 == (ONLP_FAN_CAPS_SET_RPM & info->caps)) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* reject rpm=0% (rpm=0%, stop fan) */ - if (0 == rpm) { - return ONLP_STATUS_E_INVALID; - } - - /* Set fan speed - Converting percent to driver value. - Driver accept value in range between 153 and 255. - Value 153 is minimum rpm. - Value 255 is maximum rpm. - */ - if (local_id > sizeof(min_fan_speed)/sizeof(min_fan_speed[0])) { - return ONLP_STATUS_E_INTERNAL; - } - if (max_fan_speed[local_id] - min_fan_speed[local_id] < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (rpm < min_fan_speed[local_id] || rpm > max_fan_speed[local_id]) { - return ONLP_STATUS_E_PARAM; - } - - temp = (rpm - min_fan_speed[local_id]) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / - (max_fan_speed[local_id] - min_fan_speed[local_id]) + RPM_MAGIC_MIN; - - snprintf(r_data, sizeof(r_data), "%d", (int)temp); - nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * This function sets the fan speed of the given OID as a percentage. - * - * This will only be called if the OID has the PERCENTAGE_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_percentage_set(onlp_oid_t id, int p) -{ - float temp = 0.0; - int rv = 0, local_id = 0, nbytes = 10; - char r_data[10] = {0}; - onlp_fan_info_t* info = NULL; - - VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); - info = &linfo[local_id]; - - if (0 == (ONLP_FAN_CAPS_SET_PERCENTAGE & info->caps)) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* reject p=0% (p=0%, stop fan) */ - if (0 == p) { - return ONLP_STATUS_E_INVALID; - } - - if (p < PERCENTAGE_MIN || p > PERCENTAGE_MAX) { - return ONLP_STATUS_E_PARAM; - } - - /* Set fan speed - Converting percent to driver value. - Driver accept value in range between 153 and 255. - Value 153 is 60%. - Value 255 is 100%. - */ - temp = (p - PERCENTAGE_MIN) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / - (PERCENTAGE_MAX - PERCENTAGE_MIN) + RPM_MAGIC_MIN; - - snprintf(r_data, sizeof(r_data), "%d", (int)temp); - nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", - PREFIX_PATH, fan_path[local_id].r_speed_set); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * This function sets the fan speed of the given OID as per - * the predefined ONLP fan speed modes: off, slow, normal, fast, max. - * - * Interpretation of these modes is up to the platform. - * - */ -int -onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan direction of the given OID. - * - * This function is only relevant if the fan OID supports both direction - * capabilities. - * - * This function is optional unless the functionality is available. - */ -int -onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_fani_get_min_rpm(int id) -{ - int len = 0, nbytes = 10; - char r_data[10] = {0}; - - if (onlp_file_read((uint8_t*)r_data, nbytes, &len, "%s%s", PREFIX_PATH, fan_path[id].min) < 0) - return ONLP_STATUS_E_INTERNAL; - - return atoi(r_data); -} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c index b6e6e8ad..872e6a49 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c @@ -30,98 +30,17 @@ #include #include #include "platform_lib.h" +#include -#define prefix_path "/bsp/led/led_" -#define driver_value_len 50 -#define LED_MODE_OFF "none" -#define LED_MODE_GREEN "green" -#define LED_MODE_RED "red" -#define LED_MODE_BLUE "blue" -#define LED_MODE_GREEN_BLINK "green_blink" -#define LED_MODE_RED_BLINK "red_blink" -#define LED_MODE_BLUE_BLINK "blue_blink" -#define LED_MODE_AUTO "cpld_control" - -#define LED_BLINK_PERIOD "100" -#define LED_ON "1" -#define LED_OFF "0" -#define LED_BLINK_PERIOD_LEN 3 -#define LED_MODE_LEN 1 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -typedef struct led_light_mode_map { - enum onlp_led_id id; - char* driver_led_mode; - enum onlp_led_mode_e onlp_led_mode; -} led_light_mode_map_t; - -led_light_mode_map_t led_map[] = { -{LED_SYSTEM, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_SYSTEM, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_SYSTEM, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_SYSTEM, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_SYSTEM, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_SYSTEM, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_PSU1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_PSU1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_PSU1, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_PSU1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_PSU1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_PSU2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_PSU2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_PSU2, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_PSU2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_PSU2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_UID, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_UID, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, -{LED_UID, LED_MODE_BLUE_BLINK, ONLP_LED_MODE_BLUE_BLINKING}, -{LED_UID, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, -}; - -typedef struct led_colors { - enum onlp_led_id id; - const char* color1; - const char* color2; -} led_colors_t; - -static led_colors_t led_colors_map[] = { - {LED_SYSTEM, "green", "red"}, - {LED_FAN, "green", "red"}, - {LED_PSU1, "green", "red"}, - {LED_PSU2, "green", "red"}, - {LED_UID, "blue", NULL}, -}; - -static char file_names[][10] = /* must map with onlp_led_id */ +static char* file_names[] = /* must map with onlp_led_id */ { "reserved", "status", "fan", "psu1", "psu2", - "uid" + "uid" }; /* @@ -162,213 +81,14 @@ static onlp_led_info_t linfo[] = } }; -static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode) -{ - char *pos; - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - if ((pos=strchr(driver_led_mode, '\n')) != NULL) - *pos = '\0'; - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && - !strncmp(led_map[i].driver_led_mode, driver_led_mode, driver_value_len)) - { - return led_map[i].onlp_led_mode; - } - } - - return 0; -} - -static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) -{ - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) - { - return led_map[i].driver_led_mode; - } - } - - return LED_MODE_OFF; -} - -static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id = ONLP_OID_ID_GET(id); - char color[10]={0}; - int blinking = 0; - - switch (mode) { - case ONLP_LED_MODE_RED_BLINKING: - strcpy(color, "red"); - blinking = 1; - break; - case ONLP_LED_MODE_GREEN_BLINKING: - strcpy(color, "green"); - blinking = 1; - break; - case ONLP_LED_MODE_BLUE_BLINKING: - strcpy(color, "blue"); - blinking = 1; - break; - case ONLP_LED_MODE_YELLOW_BLINKING: - strcpy(color, "yellow"); - blinking = 1; - break; - case ONLP_LED_MODE_RED: - strcpy(color, "red"); - break; - case ONLP_LED_MODE_GREEN: - strcpy(color, "green"); - break; - case ONLP_LED_MODE_BLUE: - strcpy(color, "blue"); - break; - case ONLP_LED_MODE_YELLOW: - strcpy(color, "yellow"); - break; - default: - return ONLP_STATUS_E_PARAM; - } - - if (blinking) { - onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, - "%s%s_%s_delay_off", prefix_path, file_names[local_id], color); - onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, - "%s%s_%s_delay_on", prefix_path, file_names[local_id], color); - } - onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, - "%s%s_%s", prefix_path, file_names[local_id], color); - - return ONLP_STATUS_OK; -} - /* * This function will be called prior to any other onlp_ledi_* functions. */ int onlp_ledi_init(void) { - /* - * ONLPD calls it too early before all BSP insfrastructure is set - */ - + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->linfo = linfo; + mlnx_platform_info->led_fnames = file_names; return ONLP_STATUS_OK; } - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int len, local_id = 0; - uint8_t data[driver_value_len] = {0}; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - /* Get LED mode */ - if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { - char* cmd = aim_fstrdup("%s%s_state", prefix_path, file_names[local_id]); - if(system(cmd) != 0) { - aim_free(cmd); - return ONLP_STATUS_E_INTERNAL; - } - aim_free(cmd); - } - - if (onlp_file_read(data, sizeof(data), &len, "%s%s", - prefix_path, file_names[local_id]) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->mode = driver_to_onlp_led_mode(local_id, (char*)data); - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } - - return ONLP_STATUS_OK; -} - -/* - * Turn an LED on or off. - * - * This function will only be called if the LED OID supports the ONOFF - * capability. - * - * What 'on' means in terms of colors or modes for multimode LEDs is - * up to the platform to decide. This is intended as baseline toggle mechanism. - */ -int -onlp_ledi_set(onlp_oid_t id, int on_or_off) -{ - VALIDATE(id); - - if (!on_or_off) { - if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) - return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - else { - int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); - for (i = 0; i < nsize; i++) - { - if (id == led_colors_map[i].id) - break; - } - if (led_colors_map[i].color1) - onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, - "%s%s_%s", prefix_path, file_names[id], led_colors_map[i].color1); - } - } - - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function puts the LED into the given mode. It is a more functional - * interface for multimode LEDs. - * - * Only modes reported in the LED's capabilities will be attempted. - */ -int -onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id; - char* driver_led_mode; - int nbytes; - - VALIDATE(id); - - if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { - local_id = ONLP_OID_ID_GET(id); - driver_led_mode = onlp_to_driver_led_mode(local_id, mode); - nbytes = strnlen(driver_led_mode, driver_value_len); - if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, - "%s%s", prefix_path, file_names[local_id]) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - } else { - if (led_set_mode(id, mode) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - - return ONLP_STATUS_OK; -} - -/* - * Generic LED ioctl interface. - */ -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c deleted file mode 100644 index 5c7d11f4..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.c +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -int -onlp_get_kernel_ver() -{ - struct utsname buff; - char ver[4]; - char *p; - int i = 0; - - if (uname(&buff) != 0) - return ONLP_STATUS_E_INTERNAL; - - p = buff.release; - - while (*p) { - if (isdigit(*p)) { - ver[i] = strtol(p, &p, 10); - i++; - if (i >= 3) - break; - } else { - p++; - } - } - - return KERNEL_VERSION(ver[0], ver[1], ver[2]); -} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h index 357bf8c4..fd6ff537 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/platform_lib.h @@ -25,47 +25,13 @@ #ifndef __PLATFORM_LIB_H__ #define __PLATFORM_LIB_H__ -#include -#include #include "x86_64_mlnx_msn2100_log.h" -#define CHASSIS_LED_COUNT 5 +#define CHASSIS_LED_COUNT 5 #define CHASSIS_PSU_COUNT 2 #define CHASSIS_FAN_COUNT 4 #define CHASSIS_THERMAL_COUNT 7 - -#define PSU1_ID 1 -#define PSU2_ID 2 - -#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s" -#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" -#define IDPROM_PATH "/bsp/eeprom/%s%d_info" - -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -/* LED related data - */ -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SYSTEM, - LED_FAN, - LED_PSU1, - LED_PSU2, - LED_UID -}; - -typedef enum psu_type { - PSU_TYPE_UNKNOWN, - PSU_TYPE_AC_F2B, - PSU_TYPE_AC_B2F -} psu_type_t; - -psu_type_t get_psu_type(int id, char* modelname, int modelname_len); - -int onlp_fani_get_min_rpm(int id); -int onlp_get_kernel_ver(void); +#define SFP_PORT_COUNT 16 +#define CPLD_COUNT 2 #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c deleted file mode 100644 index e371e303..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c +++ /dev/null @@ -1,173 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT 1 -#define PSU_CABLE_PRESENT 1 - -#define PSU_NODE_MAX_INT_LEN 8 -#define PSU_NODE_MAX_PATH_LEN 64 - -#define PSU_MODEL "POW000167" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -psu_module_info_get(int id, char *node, int *value) -{ - int len, ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - - *value = 0; - - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, - PSU_MODULE_PREFIX, id, node); - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static int -psu_power_info_get(int id, char *node, int *value) -{ - int len, ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - - *value = 0; - - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, - PSU_POWER_PREFIX, id, node); - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -_psu_info_get(onlp_psu_info_t* info) -{ - int val = 0; - int index = ONLP_OID_ID_GET(info->hdr.id); - - /* Set capability */ - info->caps = ONLP_PSU_CAPS_AC; - - if (info->status & ONLP_PSU_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - /* Read voltage, current and power */ - if (psu_power_info_get(index, "volt", &val) == 0) { - info->mvout = val; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - if (psu_power_info_get(index, "curr", &val) == 0) { - info->miout = val; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - info->mpout = info->mvout * info->miout; - info->caps |= ONLP_PSU_CAPS_POUT; - - info->mpin = ((int)(info->mpout / 91)) * 100; - info->caps |= ONLP_PSU_CAPS_PIN; - - return ONLP_STATUS_OK; -} - -/* - * Get all information about the given PSU oid. - */ -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, - }, - { - { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, - } -}; - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int val = 0; - int index = ONLP_OID_ID_GET(id); - const char psu_model[]=PSU_MODEL; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - - /* Fixed system, PSU is always present */ - info->status |= ONLP_PSU_STATUS_PRESENT; - - strncpy(info->model, psu_model, sizeof(info->model)); - - /* Get the cable preset state */ - if (psu_module_info_get(index, "pwr_status", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index); - } - - if (val != PSU_CABLE_PRESENT) { - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - } - else { - info->status &= ~ONLP_PSU_STATUS_UNPLUGGED; - } - - _psu_info_get(info); - - return ONLP_STATUS_OK; -} - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c index c2c4a420..d0c181e4 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/sysi.c @@ -35,179 +35,32 @@ #include "platform_lib.h" #include "x86_64_mlnx_msn2100_int.h" #include "x86_64_mlnx_msn2100_log.h" +#include #define ONL_PLATFORM_NAME "x86-64-mlnx-msn2100-r0" -#define ONIE_PLATFORM_NAME "x86_64-mlnx_msn2100-r0" #define COMMAND_OUTPUT_BUFFER 256 -#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld" -#define NUM_OF_CPLD 2 -static char arr_cplddev_name[NUM_OF_CPLD][30] = +int mc_get_platform_info(mlnx_platform_info_t* mlnx_platform) { - "cpld_brd_version", - "cpld_mgmt_version" -}; - -const char* -onlp_sysi_platform_get(void) -{ - return ONL_PLATFORM_NAME; -} - -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", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d", v[0], v[1]); - - return ONLP_STATUS_OK; -} - -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) -{ - int i; - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - for (i = 1; i <= CHASSIS_LED_COUNT; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - for (i = 1; i <= CHASSIS_PSU_COUNT; i++) - { - *e++ = ONLP_PSU_ID_CREATE(i); - } - - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv = onlp_onie_read_json(onie, - "/lib/platform-config/current/onl/etc/onie/eeprom.json"); - if(rv >= 0) { - if(onie->platform_name) { - aim_free(onie->platform_name); - } - onie->platform_name = aim_strdup(ONIE_PLATFORM_NAME); - } - - return rv; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int fan_number, psu_number; - onlp_led_mode_t mode, system_mode; - int min_fan_speed; - enum onlp_led_id psu_led_id[2] = { LED_PSU1, LED_PSU2 }; - int fan_problem = 0; - int psu_problem = 0; - - /* - * FAN Indicators - * - * Green - Fan is operating - * Red - No power or Fan failure - * Off - No power - * - */ - mode = ONLP_LED_MODE_GREEN; - for( fan_number = 1; fan_number<= CHASSIS_FAN_COUNT; fan_number+=2) - { - /* each 2 fans had same led_fan */ - onlp_fan_info_t fi; - /* check fans */ - if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if(fi.status & ONLP_FAN_STATUS_FAILED) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else - { - min_fan_speed = onlp_fani_get_min_rpm(fan_number); - if( fi.rpm < min_fan_speed) - { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - } - /* check fan i+1 */ - if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { - mode = ONLP_LED_MODE_RED; - } - else if(fi.status & ONLP_FAN_STATUS_FAILED) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else - { - min_fan_speed = onlp_fani_get_min_rpm(fan_number+1); - if( fi.rpm < min_fan_speed) - { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - } - } - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_FAN), mode); - - for (psu_number = 1; psu_number <= CHASSIS_PSU_COUNT; psu_number++) - { - onlp_psu_info_t pi; - mode = ONLP_LED_MODE_GREEN; - if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { - mode = ONLP_LED_MODE_RED; - psu_problem = 1; - } - /* Fixed system, PSU always in. Check only cable plugged. */ - else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { - mode = ONLP_LED_MODE_RED; - psu_problem = 1; - } - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, psu_led_id[(psu_number-1)]), mode); - } - - /* Set System status LED green if no problem in FANs or PSUs */ - if (fan_problem || psu_problem) - system_mode = ONLP_LED_MODE_RED; - else - system_mode = ONLP_LED_MODE_GREEN; - - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_SYSTEM), system_mode); + strncpy(mlnx_platform->onl_platform_name, ONL_PLATFORM_NAME, PLATFORM_NAME_MAX_LEN); + mlnx_platform->sfp_num = SFP_PORT_COUNT; + mlnx_platform->led_num = CHASSIS_LED_COUNT; + mlnx_platform->psu_num = CHASSIS_PSU_COUNT; + mlnx_platform->fan_num = CHASSIS_FAN_COUNT; + mlnx_platform->thermal_num = CHASSIS_THERMAL_COUNT; + mlnx_platform->cpld_num = CPLD_COUNT; + mlnx_platform->psu_fixed = true; + mlnx_platform->fan_fixed = true; + mlnx_platform->psu_type = PSU_TYPE_1; + mlnx_platform->led_type = LED_TYPE_1; return ONLP_STATUS_OK; } + +int +onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c index faaa08c8..eb3126dc 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c @@ -29,41 +29,8 @@ #include #include #include "platform_lib.h" +#include "mlnx_common/mlnx_common.h" -#define prefix_path "/bsp/thermal" - -/* CPU thermal_threshold */ -typedef enum cpu_thermal_threshold_e { - CPU_THERMAL_THRESHOLD_WARNING_DEFAULT = 87000, - CPU_THERMAL_THRESHOLD_ERROR_DEFAULT = 100000, - CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 105000, -} cpu_thermal_threshold_t; - -/* Shortcut for CPU thermal threshold value. */ -#define CPU_THERMAL_THRESHOLD_INIT_DEFAULTS \ - { CPU_THERMAL_THRESHOLD_WARNING_DEFAULT, \ - CPU_THERMAL_THRESHOLD_ERROR_DEFAULT, \ - CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } - -/* Asic thermal_threshold */ -typedef enum asic_thermal_threshold_e { - ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT = 105000, - ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT = 115000, - ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 120000, -} asic_thermal_threshold_t; - -/* Shortcut for CPU thermal threshold value. */ -#define ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS \ - { ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT, \ - ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT, \ - ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) enum onlp_thermal_id { @@ -77,7 +44,7 @@ enum onlp_thermal_id THERMAL_PORT }; -static char* last_path[] = /* must map with onlp_thermal_id */ +static char* thermal_fnames[] = /* must map with onlp_thermal_id */ { "reserved", "cpu_core0", @@ -90,7 +57,7 @@ static char* last_path[] = /* must map with onlp_thermal_id */ }; /* Static values */ -static onlp_thermal_info_t linfo[] = { +static onlp_thermal_info_t tinfo[] = { { }, /* Not used */ { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0}, ONLP_THERMAL_STATUS_PRESENT, @@ -128,39 +95,9 @@ static onlp_thermal_info_t linfo[] = { int onlp_thermali_init(void) { - return ONLP_STATUS_OK; -} - -/* - * Retrieve the information structure for the given thermal OID. - * - * If the OID is invalid, return ONLP_E_STATUS_INVALID. - * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. - * Otherwise, return ONLP_STATUS_OK with the OID's information. - * - * Note -- it is expected that you fill out the information - * structure even if the sensor described by the OID is not present. - */ -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) -{ - int rv, len = 10, temp_base=1, local_id = 0; - char r_data[10] = {0}; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; - - rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, "%s/%s", - prefix_path, last_path[local_id]); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->mcelsius = atoi(r_data) / temp_base; - + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->tinfo=tinfo; + mlnx_platform_info->thermal_fnames=thermal_fnames; return ONLP_STATUS_OK; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/Makefile index 003238cf..dc1e7b86 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/Makefile @@ -1 +1 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/lib/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/lib/Makefile index 375c940e..14c80951 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/lib/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/lib/Makefile @@ -26,7 +26,7 @@ include $(ONL)/make/config.amd64.mk MODULE := libonlp-x86-64-mlnx-msn2410 include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF x86_64_mlnx_msn2410 onlplib +DEPENDMODULES := AIM IOF mlnx_common x86_64_mlnx_msn2410 onlplib DEPENDMODULE_HEADERS := sff include $(BUILDER)/dependmodules.mk @@ -37,6 +37,7 @@ include $(BUILDER)/so.mk .DEFAULT_GOAL := $(SHAREDLIB) GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 GLOBAL_CFLAGS += -fPIC GLOBAL_LINK_LIBS += -lpthread diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/onlpdump/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/onlpdump/Makefile index d2523a26..5adaf05b 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/onlpdump/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/onlpdump/Makefile @@ -29,7 +29,7 @@ include $(ONL)/make/config.amd64.mk MODULE := onlpdump include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF onlp x86_64_mlnx_msn2410 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS +DEPENDMODULES := AIM IOF onlp mlnx_common x86_64_mlnx_msn2410 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS include $(BUILDER)/dependmodules.mk @@ -40,6 +40,7 @@ include $(BUILDER)/bin.mk GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc GLOBAL_LINK_LIBS += -lpthread -lm include $(BUILDER)/targets.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c index e0f07471..9a47a312 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c @@ -27,22 +27,7 @@ #include #include #include "platform_lib.h" - -#define PREFIX_PATH "/bsp/fan/" -#define PREFIX_MODULE_PATH "/bsp/module/" - -#define FAN_STATUS_OK 1 - -#define PERCENTAGE_MIN 60.0 -#define PERCENTAGE_MAX 100.0 -#define RPM_MAGIC_MIN 153.0 -#define RPM_MAGIC_MAX 255.0 - -#define PSU_FAN_RPM_MIN 11700.0 -#define PSU_FAN_RPM_MAX 19500.0 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 +#include "mlnx_common/mlnx_common.h" #define FAN_RESERVED 0 #define FAN_1_ON_MAIN_BOARD 1 @@ -56,31 +41,11 @@ #define FAN_1_ON_PSU1 9 #define FAN_1_ON_PSU2 10 +#define FIRST_PSU_FAN_ID 9 + static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; -typedef struct fan_path_S -{ - char status[LEN_FILE_NAME]; - char r_speed_get[LEN_FILE_NAME]; - char r_speed_set[LEN_FILE_NAME]; - char min[LEN_FILE_NAME]; - char max[LEN_FILE_NAME]; -}fan_path_T; - -#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ - { #prj"fan"#id"_status", \ - #prj"fan"#id"_speed_get", \ - #prj"fan"#id"_speed_set", \ - #prj"fan"#id"_min", \ - #prj"fan"#id"_max" } - -#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) - -#define MAKE_FAN_PATH_ON_PSU(psu_id, fan_id) \ - {"psu"#psu_id"_status", \ - "psu"#psu_id"_fan"#fan_id"_speed_get", "", "", "",} - static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), @@ -96,29 +61,8 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ MAKE_FAN_PATH_ON_PSU(2, 1) }; -#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ - 0x0, \ - (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | \ - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_RPM), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id" Fan "#fan_id, 0 }, \ - 0x0, \ - (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - /* Static fan information */ -onlp_fan_info_t linfo[] = { +onlp_fan_info_t finfo[] = { { }, /* Not used */ MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), @@ -132,418 +76,18 @@ onlp_fan_info_t linfo[] = { MAKE_FAN_INFO_NODE_ON_PSU(2,1) }; -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -#define OPEN_READ_FILE(fullpath, data, nbytes, len) \ - if (onlp_file_read((uint8_t*)data, nbytes, &len, fullpath) < 0) \ - return ONLP_STATUS_E_INTERNAL; \ - else \ - AIM_LOG_VERBOSE("read data: %s\n", r_data); \ - - -static int -_onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) -{ - const char sanity_checker[] = "MLNX"; - const uint8_t sanity_offset = 8; - const uint8_t sanity_len = 4; - const uint8_t block1_start = 12; - const uint8_t block1_type = 1; - const uint8_t block2_start = 14; - const uint8_t block2_type = 5; - const uint8_t serial_offset = 8; - const uint8_t serial_len = 24; - const uint8_t part_len = 20; - const uint8_t fan_offset = 14; - const uint8_t multiplier = 16; - uint8_t data[256] = {0}; - uint8_t offset = 0; - uint8_t temp = 0; - int rv = 0; - int len = 0; - - /* We have 4 FRU with 2 fans(total 8 fans). - Eeprom is per FRU but not per fan. - So, need to convert fan ID to FRU ID.*/ - if (local_id % 2) { - local_id = local_id / 2 + 1; - } else { - local_id /= 2; - } - - rv = onlp_file_read(data, sizeof(data), &len, - IDPROM_PATH, "fan", local_id); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Sanity checker */ - if (strncmp(sanity_checker, (char*)&data[sanity_offset], sanity_len)) { - return ONLP_STATUS_E_INVALID; - } - - /* Checking eeprom block type with S/N and P/N */ - if (data[block1_start + 1] != block1_type) { - return ONLP_STATUS_E_INVALID; - } - - /* Reading serial number */ - offset = data[block1_start] * multiplier + serial_offset; - strncpy(info->serial, (char *)&data[offset], serial_len); - - /* Reading part number */ - offset += serial_len; - strncpy(info->model, (char *)&data[offset], part_len); - - /* Reading fan direction */ - if (data[block2_start + 1] != block2_type) { - return ONLP_STATUS_E_INVALID; - } - offset = data[block2_start] * multiplier + fan_offset; - temp = data[offset]; - switch (temp) { - case 1: - info->caps |= ONLP_FAN_CAPS_F2B; - break; - case 2: - info->caps |= ONLP_FAN_CAPS_B2F; - break; - default: - break; - } - - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) -{ - int len = 0, nbytes = 10; - float range = 0; - float temp = 0; - float fru_index = 0; - char r_data[10] = {0}; - char fullpath[65] = {0}; - - /* We have 4 FRU with 2 fans(total 8 fans). - Eeprom is per FRU but not per fan. - So, need to convert fan ID to FRU ID.*/ - if (local_id % 2) { - fru_index = local_id / 2 + 1; - } else { - fru_index = local_id / 2; - } - - /* get fan status - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[(int)fru_index].status); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - if (atoi(r_data) != FAN_STATUS_OK) { - info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - info->status |= ONLP_FAN_STATUS_PRESENT; - - /* get fan speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - info->rpm = atoi(r_data); - - /* check failure */ - if (info->rpm <= 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) { - /* get fan min speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].min); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - min_fan_speed[local_id] = atoi(r_data); - - /* get fan max speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].max); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - max_fan_speed[local_id] = atoi(r_data); - - /* get speed percentage from rpm */ - range = max_fan_speed[local_id] - min_fan_speed[local_id]; - if (range > 0) { - temp = ((float)info->rpm - (float)min_fan_speed[local_id]) / range * 40.0 + 60.0; - if (temp < PERCENTAGE_MIN) { - temp = PERCENTAGE_MIN; - } - info->percentage = (int)temp; - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - - return _onlp_fani_read_fan_eeprom(local_id, info); -} - -static int -_onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) -{ - int len = 0, nbytes = 10; - char r_data[10] = {0}; - char fullpath[80] = {0}; - float rpms_per_perc = 0.0; - float temp = 0.0; - - /* get fan status - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[local_id].status); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - if (atoi(r_data) != FAN_STATUS_OK) { - info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - info->status |= ONLP_FAN_STATUS_PRESENT; - - /* get fan speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - info->rpm = atoi(r_data); - - /* check failure */ - if (info->rpm <= 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - /* get speed percentage from rpm */ - rpms_per_perc = PSU_FAN_RPM_MIN / PERCENTAGE_MIN; - temp = (float)info->rpm / rpms_per_perc; - if (temp < PERCENTAGE_MIN) { - temp = PERCENTAGE_MIN; - } - info->percentage = (int)temp; - - /* Serial number and model for PSU fan is the same as for appropriate PSU */ - if (FAN_1_ON_PSU1 == local_id) { - if (0 != psu_read_eeprom(PSU1_ID, NULL, info)) - return ONLP_STATUS_E_INTERNAL; - } else if (FAN_1_ON_PSU2 == local_id) { - if (0 != psu_read_eeprom(PSU2_ID, NULL, info)) - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - /* * This function will be called prior to all of onlp_fani_* functions. */ int onlp_fani_init(void) { + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->min_fan_speed=min_fan_speed; + mlnx_platform_info->max_fan_speed=max_fan_speed; + mlnx_platform_info->finfo = finfo; + mlnx_platform_info->fan_fnames = fan_path; + mlnx_platform_info->fan_type = FAN_TYPE_EEPROM; + mlnx_platform_info->first_psu_fan_id = FIRST_PSU_FAN_ID; return ONLP_STATUS_OK; } - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) -{ - int rc = 0; - int local_id = 0; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - *info = linfo[local_id]; - - switch (local_id) - { - case FAN_1_ON_PSU1: - rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU1_ID, info); - break; - case FAN_1_ON_PSU2: - rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU2_ID, info); - break; - case FAN_1_ON_MAIN_BOARD: - case FAN_2_ON_MAIN_BOARD: - case FAN_3_ON_MAIN_BOARD: - case FAN_4_ON_MAIN_BOARD: - case FAN_5_ON_MAIN_BOARD: - case FAN_6_ON_MAIN_BOARD: - case FAN_7_ON_MAIN_BOARD: - case FAN_8_ON_MAIN_BOARD: - rc =_onlp_fani_info_get_fan(local_id, info); - break; - default: - rc = ONLP_STATUS_E_INVALID; - break; - } - - return rc; -} - -/* - * This function sets the speed of the given fan in RPM. - * - * This function will only be called if the fan supprots the RPM_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - float temp = 0.0; - int rv = 0, local_id = 0, nbytes = 10; - char r_data[10] = {0}; - onlp_fan_info_t* info = NULL; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - info = &linfo[local_id]; - - if (0 == (ONLP_FAN_CAPS_SET_RPM & info->caps)) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* reject rpm=0% (rpm=0%, stop fan) */ - if (0 == rpm) { - return ONLP_STATUS_E_INVALID; - } - - /* Set fan speed - Converting percent to driver value. - Driver accept value in range between 153 and 255. - Value 153 is minimum rpm. - Value 255 is maximum rpm. - */ - if (local_id > sizeof(min_fan_speed)/sizeof(min_fan_speed[0])) { - return ONLP_STATUS_E_INTERNAL; - } - if (max_fan_speed[local_id] - min_fan_speed[local_id] < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (rpm < min_fan_speed[local_id] || rpm > max_fan_speed[local_id]) { - return ONLP_STATUS_E_PARAM; - } - - temp = (rpm - min_fan_speed[local_id]) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / - (max_fan_speed[local_id] - min_fan_speed[local_id]) + RPM_MAGIC_MIN; - - snprintf(r_data, sizeof(r_data), "%d", (int)temp); - nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * This function sets the fan speed of the given OID as a percentage. - * - * This will only be called if the OID has the PERCENTAGE_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_percentage_set(onlp_oid_t id, int p) -{ - float temp = 0.0; - int rv = 0, local_id = 0, nbytes = 10; - char r_data[10] = {0}; - onlp_fan_info_t* info = NULL; - - VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); - info = &linfo[local_id]; - - if (0 == (ONLP_FAN_CAPS_SET_PERCENTAGE & info->caps)) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* reject p=0% (p=0%, stop fan) */ - if (0 == p) { - return ONLP_STATUS_E_INVALID; - } - - if (p < PERCENTAGE_MIN || p > PERCENTAGE_MAX) { - return ONLP_STATUS_E_PARAM; - } - - /* Set fan speed - Converting percent to driver value. - Driver accept value in range between 153 and 255. - Value 153 is 60%. - Value 255 is 100%. - */ - temp = (p - PERCENTAGE_MIN) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / - (PERCENTAGE_MAX - PERCENTAGE_MIN) + RPM_MAGIC_MIN; - - snprintf(r_data, sizeof(r_data), "%d", (int)temp); - nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * This function sets the fan speed of the given OID as per - * the predefined ONLP fan speed modes: off, slow, normal, fast, max. - * - * Interpretation of these modes is up to the platform. - * - */ -int -onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan direction of the given OID. - * - * This function is only relevant if the fan OID supports both direction - * capabilities. - * - * This function is optional unless the functionality is available. - */ -int -onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_fani_get_min_rpm(int id) -{ - int len = 0, nbytes = 10; - char r_data[10] = {0}; - - if (onlp_file_read((uint8_t*)r_data, nbytes, &len, "%s%s", PREFIX_PATH, fan_path[id].min) < 0) - return ONLP_STATUS_E_INTERNAL; - - return atoi(r_data); -} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c index 74386ff0..7fdb1f37 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c @@ -30,101 +30,9 @@ #include #include #include "platform_lib.h" +#include -#define prefix_path "/bsp/led/led_" -#define driver_value_len 50 - -#define LED_MODE_OFF "none" -#define LED_MODE_GREEN "green" -#define LED_MODE_RED "red" -#define LED_MODE_BLUE "blue" -#define LED_MODE_GREEN_BLINK "green_blink" -#define LED_MODE_RED_BLINK "red_blink" -#define LED_MODE_BLUE_BLINK "blue_blink" -#define LED_MODE_AUTO "cpld_control" - -#define LED_BLINK_PERIOD "100" -#define LED_ON "1" -#define LED_OFF "0" -#define LED_BLINK_PERIOD_LEN 3 -#define LED_MODE_LEN 1 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -typedef struct led_light_mode_map { - enum onlp_led_id id; - char* driver_led_mode; - enum onlp_led_mode_e onlp_led_mode; -} led_light_mode_map_t; - -led_light_mode_map_t led_map[] = { -{LED_SYSTEM, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_SYSTEM, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_SYSTEM, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_SYSTEM, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_SYSTEM, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_SYSTEM, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN1, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN2, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN3, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN3, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN3, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN3, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN3, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN3, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN4, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN4, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN4, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN4, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN4, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN4, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_PSU, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_PSU, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_PSU, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_PSU, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_PSU, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_PSU, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} -}; - -typedef struct led_colors { - enum onlp_led_id id; - const char* color1; - const char* color2; -} led_colors_t; - -static led_colors_t led_colors_map[] = { - {LED_SYSTEM, "green", "red"}, - {LED_FAN1, "green", "red"}, - {LED_FAN2, "green", "red"}, - {LED_FAN3, "green", "red"}, - {LED_FAN4, "green", "red"}, - {LED_PSU, "green", "red"}, -}; - -static char file_names[][10] = /* must map with onlp_led_id */ +static char* file_names[] = /* must map with onlp_led_id */ { "reserved", "status", @@ -179,213 +87,11 @@ static onlp_led_info_t linfo[] = } }; -static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode) -{ - char *pos; - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - if ((pos=strchr(driver_led_mode, '\n')) != NULL) - *pos = '\0'; - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && - !strncmp(led_map[i].driver_led_mode, driver_led_mode, driver_value_len)) - { - return led_map[i].onlp_led_mode; - } - } - - return 0; -} - -static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) -{ - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) - { - return led_map[i].driver_led_mode; - } - } - - return LED_MODE_OFF; -} - -static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id = ONLP_OID_ID_GET(id); - char color[10]={0}; - int blinking = 0; - - switch (mode) { - case ONLP_LED_MODE_RED_BLINKING: - strcpy(color, "red"); - blinking = 1; - break; - case ONLP_LED_MODE_GREEN_BLINKING: - strcpy(color, "green"); - blinking = 1; - break; - case ONLP_LED_MODE_BLUE_BLINKING: - strcpy(color, "blue"); - blinking = 1; - break; - case ONLP_LED_MODE_YELLOW_BLINKING: - strcpy(color, "yellow"); - blinking = 1; - break; - case ONLP_LED_MODE_RED: - strcpy(color, "red"); - break; - case ONLP_LED_MODE_GREEN: - strcpy(color, "green"); - break; - case ONLP_LED_MODE_BLUE: - strcpy(color, "blue"); - break; - case ONLP_LED_MODE_YELLOW: - strcpy(color, "yellow"); - break; - default: - return ONLP_STATUS_E_PARAM; - } - - if (blinking) { - onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, - "%s%s_%s_delay_off", prefix_path, file_names[local_id], color); - onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, - "%s%s_%s_delay_on", prefix_path, file_names[local_id], color); - } - onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, - "%s%s_%s", prefix_path, file_names[local_id], color); - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ int onlp_ledi_init(void) { - /* - * ONLPD calls it too early before all BSP insfrastructure is set - */ - + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->linfo = linfo; + mlnx_platform_info->led_fnames = file_names; return ONLP_STATUS_OK; } - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int len, local_id = 0; - uint8_t data[driver_value_len] = {0}; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - /* Get LED mode */ - if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { - char* cmd = aim_fstrdup("%s%s_state", prefix_path, file_names[local_id]); - if(system(cmd) != 0) { - aim_free(cmd); - return ONLP_STATUS_E_INTERNAL; - } - aim_free(cmd); - } - - if (onlp_file_read(data, sizeof(data), &len, "%s%s", - prefix_path, file_names[local_id]) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->mode = driver_to_onlp_led_mode(local_id, (char*)data); - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } - - return ONLP_STATUS_OK; -} - -/* - * Turn an LED on or off. - * - * This function will only be called if the LED OID supports the ONOFF - * capability. - * - * What 'on' means in terms of colors or modes for multimode LEDs is - * up to the platform to decide. This is intended as baseline toggle mechanism. - */ -int -onlp_ledi_set(onlp_oid_t id, int on_or_off) -{ - VALIDATE(id); - - if (!on_or_off) { - if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) - return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - else { - int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); - for (i = 0; i < nsize; i++) - { - if (id == led_colors_map[i].id) - break; - } - if (led_colors_map[i].color1) - onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, - "%s%s_%s", prefix_path, file_names[id], led_colors_map[i].color1); - } - } - - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function puts the LED into the given mode. It is a more functional - * interface for multimode LEDs. - * - * Only modes reported in the LED's capabilities will be attempted. - */ -int -onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id; - char* driver_led_mode; - int nbytes; - - VALIDATE(id); - - if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { - local_id = ONLP_OID_ID_GET(id); - driver_led_mode = onlp_to_driver_led_mode(local_id, mode); - nbytes = strnlen(driver_led_mode, driver_value_len); - if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, - "%s%s", prefix_path, file_names[local_id]) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - } else { - if (led_set_mode(id, mode) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - - return ONLP_STATUS_OK; -} - -/* - * Generic LED ioctl interface. - */ -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c deleted file mode 100644 index 5035bc48..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -int -psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info) -{ - const char sanity_check[] = "MLNX"; - const uint8_t serial_len = 24; - char data[256] = {0}; - bool sanity_found = false; - int index = 0, rv = 0, len = 0; - - rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, - IDPROM_PATH, "psu", psu_index); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Looking for sanity checker */ - while (index < sizeof(data) - sizeof(sanity_check) - 1) { - if (!strncmp(&data[index], sanity_check, sizeof(sanity_check) - 1)) { - sanity_found = true; - break; - } - index++; - } - if (false == sanity_found) { - return ONLP_STATUS_E_INVALID; - } - - /* Serial number */ - index += strlen(sanity_check); - if (psu_info) { - strncpy(psu_info->serial, &data[index], sizeof(psu_info->serial)); - } else if (fan_info) { - strncpy(fan_info->serial, &data[index], sizeof(fan_info->serial)); - } - - /* Part number */ - index += serial_len; - if (psu_info) { - strncpy(psu_info->model, &data[index], sizeof(psu_info->model)); - } else if (fan_info) { - strncpy(fan_info->model, &data[index], sizeof(fan_info->model)); - } - - return ONLP_STATUS_OK; -} - -int -onlp_get_kernel_ver() -{ - struct utsname buff; - char ver[4]; - char *p; - int i = 0; - - if (uname(&buff) != 0) - return ONLP_STATUS_E_INTERNAL; - - p = buff.release; - - while (*p) { - if (isdigit(*p)) { - ver[i] = strtol(p, &p, 10); - i++; - if (i >= 3) - break; - } else { - p++; - } - } - - return KERNEL_VERSION(ver[0], ver[1], ver[2]); -} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h index 80b9faa8..1895605c 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.h @@ -25,8 +25,6 @@ #ifndef __PLATFORM_LIB_H__ #define __PLATFORM_LIB_H__ -#include -#include #include "x86_64_mlnx_msn2410_log.h" #define CHASSIS_PSU_COUNT 2 @@ -34,43 +32,8 @@ #define CHASSIS_TOTAL_THERMAL_COUNT 8 #define CHASSIS_FAN_COUNT (CHASSIS_TOTAL_FAN_COUNT - CHASSIS_PSU_COUNT) #define CHASSIS_THERMAL_COUNT (CHASSIS_TOTAL_THERMAL_COUNT - CHASSIS_PSU_COUNT) - -#define PSU1_ID 1 -#define PSU2_ID 2 - -#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s" -#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" -#define IDPROM_PATH "/bsp/eeprom/%s%d_info" - -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -/* LED related data - */ -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SYSTEM, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_PSU, -}; - -typedef enum psu_type { - PSU_TYPE_UNKNOWN, - PSU_TYPE_AC_F2B, - PSU_TYPE_AC_B2F -} psu_type_t; - -psu_type_t get_psu_type(int id, char* modelname, int modelname_len); - -int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, - onlp_fan_info_t* fan_info); - -int onlp_fani_get_min_rpm(int id); -int onlp_get_kernel_ver(void); +#define CHASSIS_LED_COUNT 6 +#define SFP_PORT_COUNT 56 +#define CPLD_COUNT 3 #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c deleted file mode 100644 index e2c3f56d..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sfpi.c +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define MAX_SFP_PATH 64 -#define SFP_SYSFS_VALUE_LEN 20 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define NUM_OF_SFP_PORT 56 -#define SFP_PRESENT_STATUS "good" -#define SFP_NOT_PRESENT_STATUS "not_connected" - -static int -msn2410_sfp_node_read_int(char *node_path, int *value) -{ - int data_len = 0, ret = 0; - char buf[SFP_SYSFS_VALUE_LEN] = {0}; - *value = -1; - char sfp_present_status[16]; - char sfp_not_present_status[16]; - - if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { - strcpy(sfp_present_status, "1"); - strcpy(sfp_not_present_status, "0"); - } else { - strcpy(sfp_present_status, "good"); - strcpy(sfp_not_present_status, "not_connected"); - } - - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path); - - if (ret == 0) { - if (!strncmp(buf, sfp_present_status, strlen(sfp_present_status))) { - *value = 1; - } else if (!strncmp(buf, sfp_not_present_status, strlen(sfp_not_present_status))) { - *value = 0; - } - } - - return ret; -} - -static char* -msn2410_sfp_get_port_path(int port, char *node_name) -{ - if (node_name) - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); - else - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); - return sfp_node_path; -} - -static char* -sn2410_sfp_convert_i2c_path(int port, int devaddr) -{ - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); - return sfp_node_path; -} - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {1, 32} - */ - int p = 1; - AIM_BITMAP_CLR_ALL(bmap); - - for (; p <= NUM_OF_SFP_PORT; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - /* - * Return 1 if present. - * Return 0 if not present. - * Return < 0 if error. - */ - int present = -1; - char* path = msn2410_sfp_get_port_path(port, "_status"); - - if (msn2410_sfp_node_read_int(path, &present) != 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int ii = 1; - int rc = 0; - - for (;ii <= NUM_OF_SFP_PORT; ii++) { - rc = onlp_sfpi_is_present(ii); - AIM_BITMAP_MOD(dst, ii, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char* path = msn2410_sfp_get_port_path(port, NULL); - - /* - * Read the SFP eeprom into data[] - * - * Return MISSING if SFP is missing. - * Return OK if eeprom is read - */ - memset(data, 0, 256); - - if (onlplib_sfp_eeprom_read_file(path, data) != 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - char* path = sn2410_sfp_convert_i2c_path(port, devaddr); - uint8_t data; - int fd; - int nrd; - - if (!path) - return ONLP_STATUS_E_MISSING; - - fd = open(path, O_RDONLY); - if (fd < 0) - return ONLP_STATUS_E_MISSING; - - lseek(fd, addr, SEEK_SET); - nrd = read(fd, &data, 1); - close(fd); - - if (nrd != 1) { - AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); - return ONLP_STATUS_E_INTERNAL; - } - return data; -} - -int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) -{ - char* path = sn2410_sfp_convert_i2c_path(port, devaddr); - uint16_t data; - int fd; - int nrd; - - if (!path){ - return ONLP_STATUS_E_MISSING; - } - - fd = open(path, O_RDONLY); - if (fd < 0) { - return ONLP_STATUS_E_MISSING; - } - - lseek(fd, addr, SEEK_SET); - nrd = read(fd, &data, 2); - close(fd); - - if (nrd != 2) { - AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); - return ONLP_STATUS_E_INTERNAL; - } - return data; -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c index 0e9f2549..6ee04ede 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/sysi.c @@ -35,205 +35,54 @@ #include "platform_lib.h" #include "x86_64_mlnx_msn2410_int.h" #include "x86_64_mlnx_msn2410_log.h" +#include -#define ONL_PLATFORM_NAME "x86-64-mlnx-msn2410-r0" -#define ONIE_PLATFORM_NAME "x86-64-mlnx_msn2410-r0" - -#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 6 +static const char* __ONL_PLATFORM_NAME = NULL; #define COMMAND_OUTPUT_BUFFER 256 -#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld" -#define NUM_OF_CPLD 3 -static char arr_cplddev_name[NUM_OF_CPLD][30] = +int mc_get_platform_info(mlnx_platform_info_t* mlnx_platform) { - "cpld_brd_version", - "cpld_mgmt_version", - "cpld_port_version" -}; - -const char* -onlp_sysi_platform_get(void) -{ - return ONL_PLATFORM_NAME; -} - -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", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d, port=%d", v[0], v[1], v[2]); - - return ONLP_STATUS_OK; -} - -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) -{ - int i; - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - - /* 8 Thermal sensors on the chassis */ - for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* 6 LEDs on the chassis */ - for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* 2 PSUs on the chassis */ - for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_PSU_ID_CREATE(i); - } - - /* 8 Fans and 2 PSU fans on the chassis */ - for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv = onlp_onie_read_json(onie, - "/lib/platform-config/current/onl/etc/onie/eeprom.json"); - if(rv >= 0) { - if(onie->platform_name) { - aim_free(onie->platform_name); - } - onie->platform_name = aim_strdup(ONIE_PLATFORM_NAME); - } - - return rv; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int fan_number, psu_number; - onlp_led_mode_t mode, system_mode; - int min_fan_speed; - enum onlp_led_id fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 }; - int fan_problem = 0; - int psu_problem = 0; - - /* - * FAN Indicators - * - * Green - Fan is operating - * Red - No power or Fan failure - * Off - No power - * - */ - for( fan_number = 1; fan_number <= CHASSIS_FAN_COUNT; fan_number+=2) - { - /* each 2 fans had same led_fan */ - onlp_fan_info_t fi; - /* check fans */ - mode = ONLP_LED_MODE_GREEN; - if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if( (fi.status & ONLP_FAN_STATUS_PRESENT) == 0) { - /* Not present */ - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if(fi.status & ONLP_FAN_STATUS_FAILED) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else - { - min_fan_speed = onlp_fani_get_min_rpm(fan_number); - if( fi.rpm < min_fan_speed) - { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - } - /* check fan i+1 */ - if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if( (fi.status & 0x1) == 0) { - /* Not present */ - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if(fi.status & ONLP_FAN_STATUS_FAILED) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else - { - min_fan_speed = onlp_fani_get_min_rpm(fan_number+1); - if( fi.rpm < min_fan_speed) - { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - } - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode); + if (!__ONL_PLATFORM_NAME) { + strncpy(mlnx_platform->onl_platform_name, "x86-64-mlnx-msn2410-all", PLATFORM_NAME_MAX_LEN); } - - for (psu_number = 1; psu_number <= CHASSIS_PSU_COUNT; psu_number++) - { - onlp_psu_info_t pi; - if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { - psu_problem = 1; - } - else if((pi.status & ONLP_PSU_STATUS_PRESENT) == 0) { - /* Not present */ - psu_problem = 1; - } - else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { - psu_problem = 1; - } + else { + strncpy(mlnx_platform->onl_platform_name, __ONL_PLATFORM_NAME, PLATFORM_NAME_MAX_LEN); } - - if (psu_problem) - mode = ONLP_LED_MODE_RED; - else - mode = ONLP_LED_MODE_GREEN; - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_PSU), mode); - - /* Set System status LED green if no problem in FANs or PSUs */ - if (fan_problem || psu_problem) - system_mode = ONLP_LED_MODE_RED; - else - system_mode = ONLP_LED_MODE_GREEN; - - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), system_mode); + mlnx_platform->sfp_num = SFP_PORT_COUNT; + mlnx_platform->led_num = CHASSIS_LED_COUNT; + mlnx_platform->psu_num = CHASSIS_PSU_COUNT; + mlnx_platform->fan_num = CHASSIS_FAN_COUNT; + mlnx_platform->thermal_num = CHASSIS_THERMAL_COUNT; + mlnx_platform->cpld_num = CPLD_COUNT; + mlnx_platform->psu_fixed = false; + mlnx_platform->fan_fixed = false; + mlnx_platform->psu_type = PSU_TYPE_2; + mlnx_platform->led_type = LED_TYPE_2; return ONLP_STATUS_OK; } +int +onlp_sysi_platform_set(const char* platform) +{ + mlnx_platform_info_t* mlnx_platform; + + if(!strcmp(platform, "x86-64-mlnx-msn2410-r0")) { + __ONL_PLATFORM_NAME = "x86-64-mlnx_msn2410-r0"; + mlnx_platform = get_platform_info(); + mc_get_platform_info(mlnx_platform); + return ONLP_STATUS_OK; + } + if(!strcmp(platform, "x86-64-mlnx-msn2410-all")) { + __ONL_PLATFORM_NAME = "x86-64-mlnx-msn2410-all"; + return ONLP_STATUS_OK; + } + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c index 7b563eec..82b44635 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c @@ -29,45 +29,7 @@ #include #include #include "platform_lib.h" - -#define prefix_path "/bsp/thermal" - -/** CPU thermal_threshold */ -typedef enum cpu_thermal_threshold_e { - CPU_THERMAL_THRESHOLD_WARNING_DEFAULT = 87000, - CPU_THERMAL_THRESHOLD_ERROR_DEFAULT = 100000, - CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 105000, -} cpu_thermal_threshold_t; - -/** - * Shortcut for CPU thermal threshold value. - */ -#define CPU_THERMAL_THRESHOLD_INIT_DEFAULTS \ - { CPU_THERMAL_THRESHOLD_WARNING_DEFAULT, \ - CPU_THERMAL_THRESHOLD_ERROR_DEFAULT, \ - CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } - -/** Asic thermal_threshold */ -typedef enum asic_thermal_threshold_e { - ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT = 105000, - ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT = 115000, - ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 120000, -} asic_thermal_threshold_t; - -/** - * Shortcut for CPU thermal threshold value. - */ -#define ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS \ - { ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT, \ - ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT, \ - ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) +#include "mlnx_common/mlnx_common.h" enum onlp_thermal_id { @@ -82,7 +44,7 @@ enum onlp_thermal_id THERMAL_ON_PSU2, }; -static char* last_path[] = /* must map with onlp_thermal_id */ +static char* thermal_fnames[] = /* must map with onlp_thermal_id */ { "reserved", "cpu_core0", @@ -96,7 +58,7 @@ static char* last_path[] = /* must map with onlp_thermal_id */ }; /* Static values */ -static onlp_thermal_info_t linfo[] = { +static onlp_thermal_info_t tinfo[] = { { }, /* Not used */ { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0}, ONLP_THERMAL_STATUS_PRESENT, @@ -138,39 +100,9 @@ static onlp_thermal_info_t linfo[] = { int onlp_thermali_init(void) { - return ONLP_STATUS_OK; -} - -/* - * Retrieve the information structure for the given thermal OID. - * - * If the OID is invalid, return ONLP_E_STATUS_INVALID. - * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. - * Otherwise, return ONLP_STATUS_OK with the OID's information. - * - * Note -- it is expected that you fill out the information - * structure even if the sensor described by the OID is not present. - */ -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) -{ - int rv, len = 10, temp_base=1, local_id = 0; - char r_data[10] = {0}; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; - - rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, - "%s/%s", prefix_path, last_path[local_id]); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->mcelsius = atoi(r_data) / temp_base; - + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->tinfo=tinfo; + mlnx_platform_info->thermal_fnames=thermal_fnames; return ONLP_STATUS_OK; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/lib/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/lib/Makefile index 023532c4..002f4816 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/lib/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/lib/Makefile @@ -26,7 +26,7 @@ include $(ONL)/make/config.amd64.mk MODULE := libonlp-x86-64-mlnx-msn2700 include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF x86_64_mlnx_msn2700 onlplib +DEPENDMODULES := AIM IOF mlnx_common x86_64_mlnx_msn2700 onlplib DEPENDMODULE_HEADERS := sff include $(BUILDER)/dependmodules.mk @@ -37,6 +37,7 @@ include $(BUILDER)/so.mk .DEFAULT_GOAL := $(SHAREDLIB) GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 GLOBAL_CFLAGS += -fPIC GLOBAL_LINK_LIBS += -lpthread diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/onlpdump/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/onlpdump/Makefile index 7087c1be..24d431c7 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/onlpdump/Makefile +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/onlpdump/Makefile @@ -29,7 +29,7 @@ include $(ONL)/make/config.amd64.mk MODULE := onlpdump include $(BUILDER)/standardinit.mk -DEPENDMODULES := AIM IOF onlp x86_64_mlnx_msn2700 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS +DEPENDMODULES := AIM IOF onlp mlnx_common x86_64_mlnx_msn2700 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS include $(BUILDER)/dependmodules.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c index 9abef68f..69914db2 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c @@ -27,22 +27,7 @@ #include #include #include "platform_lib.h" - -#define PREFIX_PATH "/bsp/fan/" -#define PREFIX_MODULE_PATH "/bsp/module/" - -#define FAN_STATUS_OK 1 - -#define PERCENTAGE_MIN 60.0 -#define PERCENTAGE_MAX 100.0 -#define RPM_MAGIC_MIN 153.0 -#define RPM_MAGIC_MAX 255.0 - -#define PSU_FAN_RPM_MIN 11700.0 -#define PSU_FAN_RPM_MAX 19500.0 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 +#include "mlnx_common/mlnx_common.h" #define FAN_RESERVED 0 #define FAN_1_ON_MAIN_BOARD 1 @@ -56,31 +41,11 @@ #define FAN_1_ON_PSU1 9 #define FAN_1_ON_PSU2 10 +#define FIRST_PSU_FAN_ID 9 + static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; -typedef struct fan_path_S -{ - char status[LEN_FILE_NAME]; - char r_speed_get[LEN_FILE_NAME]; - char r_speed_set[LEN_FILE_NAME]; - char min[LEN_FILE_NAME]; - char max[LEN_FILE_NAME]; -}fan_path_T; - -#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ - { #prj"fan"#id"_status", \ - #prj"fan"#id"_speed_get", \ - #prj"fan"#id"_speed_set", \ - #prj"fan"#id"_min", \ - #prj"fan"#id"_max" } - -#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) - -#define MAKE_FAN_PATH_ON_PSU(psu_id, fan_id) \ - {"psu"#psu_id"_status", \ - "psu"#psu_id"_fan"#fan_id"_speed_get", "", "", "",} - static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), @@ -96,29 +61,8 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ MAKE_FAN_PATH_ON_PSU(2, 1) }; -#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ - 0x0, \ - (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | \ - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_RPM), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id" Fan "#fan_id, 0 }, \ - 0x0, \ - (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - /* Static fan information */ -onlp_fan_info_t linfo[] = { +onlp_fan_info_t finfo[] = { { }, /* Not used */ MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), @@ -132,418 +76,18 @@ onlp_fan_info_t linfo[] = { MAKE_FAN_INFO_NODE_ON_PSU(2,1) }; -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -#define OPEN_READ_FILE(fullpath, data, nbytes, len) \ - if (onlp_file_read((uint8_t*)data, nbytes, &len, fullpath) < 0) \ - return ONLP_STATUS_E_INTERNAL; \ - else \ - AIM_LOG_VERBOSE("read data: %s\n", r_data); \ - - -static int -_onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) -{ - const char sanity_checker[] = "MLNX"; - const uint8_t sanity_offset = 8; - const uint8_t sanity_len = 4; - const uint8_t block1_start = 12; - const uint8_t block1_type = 1; - const uint8_t block2_start = 14; - const uint8_t block2_type = 5; - const uint8_t serial_offset = 8; - const uint8_t serial_len = 24; - const uint8_t part_len = 20; - const uint8_t fan_offset = 14; - const uint8_t multiplier = 16; - uint8_t data[256] = {0}; - uint8_t offset = 0; - uint8_t temp = 0; - int rv = 0; - int len = 0; - - /* We have 4 FRU with 2 fans(total 8 fans). - Eeprom is per FRU but not per fan. - So, need to convert fan ID to FRU ID.*/ - if (local_id % 2) { - local_id = local_id / 2 + 1; - } else { - local_id /= 2; - } - - rv = onlp_file_read(data, sizeof(data), &len, - IDPROM_PATH, "fan", local_id); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Sanity checker */ - if (strncmp(sanity_checker, (char*)&data[sanity_offset], sanity_len)) { - return ONLP_STATUS_E_INVALID; - } - - /* Checking eeprom block type with S/N and P/N */ - if (data[block1_start + 1] != block1_type) { - return ONLP_STATUS_E_INVALID; - } - - /* Reading serial number */ - offset = data[block1_start] * multiplier + serial_offset; - strncpy(info->serial, (char *)&data[offset], serial_len); - - /* Reading part number */ - offset += serial_len; - strncpy(info->model, (char *)&data[offset], part_len); - - /* Reading fan direction */ - if (data[block2_start + 1] != block2_type) { - return ONLP_STATUS_E_INVALID; - } - offset = data[block2_start] * multiplier + fan_offset; - temp = data[offset]; - switch (temp) { - case 1: - info->caps |= ONLP_FAN_CAPS_F2B; - break; - case 2: - info->caps |= ONLP_FAN_CAPS_B2F; - break; - default: - break; - } - - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) -{ - int len = 0, nbytes = 10; - float range = 0; - float temp = 0; - float fru_index = 0; - char r_data[10] = {0}; - char fullpath[65] = {0}; - - /* We have 4 FRU with 2 fans(total 8 fans). - Eeprom is per FRU but not per fan. - So, need to convert fan ID to FRU ID.*/ - if (local_id % 2) { - fru_index = local_id / 2 + 1; - } else { - fru_index = local_id / 2; - } - - /* get fan status - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[(int)fru_index].status); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - if (atoi(r_data) != FAN_STATUS_OK) { - info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - info->status |= ONLP_FAN_STATUS_PRESENT; - - /* get fan speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - info->rpm = atoi(r_data); - - /* check failure */ - if (info->rpm <= 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) { - /* get fan min speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].min); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - min_fan_speed[local_id] = atoi(r_data); - - /* get fan max speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].max); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - max_fan_speed[local_id] = atoi(r_data); - - /* get speed percentage from rpm */ - range = max_fan_speed[local_id] - min_fan_speed[local_id]; - if (range > 0) { - temp = ((float)info->rpm - (float)min_fan_speed[local_id]) / range * 40.0 + 60.0; - if (temp < PERCENTAGE_MIN) { - temp = PERCENTAGE_MIN; - } - info->percentage = (int)temp; - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - - return _onlp_fani_read_fan_eeprom(local_id, info); -} - -static int -_onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) -{ - int len = 0, nbytes = 10; - char r_data[10] = {0}; - char fullpath[80] = {0}; - float rpms_per_perc = 0.0; - float temp = 0.0; - - /* get fan status - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_MODULE_PATH, fan_path[local_id].status); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - if (atoi(r_data) != FAN_STATUS_OK) { - info->status &= ~ONLP_FAN_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - info->status |= ONLP_FAN_STATUS_PRESENT; - - /* get fan speed - */ - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, fan_path[local_id].r_speed_get); - OPEN_READ_FILE(fullpath, r_data, nbytes, len); - info->rpm = atoi(r_data); - - /* check failure */ - if (info->rpm <= 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - /* get speed percentage from rpm */ - rpms_per_perc = PSU_FAN_RPM_MIN / PERCENTAGE_MIN; - temp = (float)info->rpm / rpms_per_perc; - if (temp < PERCENTAGE_MIN) { - temp = PERCENTAGE_MIN; - } - info->percentage = (int)temp; - - /* Serial number and model for PSU fan is the same as for appropriate PSU */ - if (FAN_1_ON_PSU1 == local_id) { - if (0 != psu_read_eeprom(PSU1_ID, NULL, info)) - return ONLP_STATUS_E_INTERNAL; - } else if (FAN_1_ON_PSU2 == local_id) { - if (0 != psu_read_eeprom(PSU2_ID, NULL, info)) - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - /* * This function will be called prior to all of onlp_fani_* functions. */ int onlp_fani_init(void) { + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->min_fan_speed=min_fan_speed; + mlnx_platform_info->max_fan_speed=max_fan_speed; + mlnx_platform_info->finfo = finfo; + mlnx_platform_info->fan_fnames = fan_path; + mlnx_platform_info->fan_type = FAN_TYPE_EEPROM; + mlnx_platform_info->first_psu_fan_id = FIRST_PSU_FAN_ID; return ONLP_STATUS_OK; } - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) -{ - int rc = 0; - int local_id = 0; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - *info = linfo[local_id]; - - switch (local_id) - { - case FAN_1_ON_PSU1: - rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU1_ID, info); - break; - case FAN_1_ON_PSU2: - rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU2_ID, info); - break; - case FAN_1_ON_MAIN_BOARD: - case FAN_2_ON_MAIN_BOARD: - case FAN_3_ON_MAIN_BOARD: - case FAN_4_ON_MAIN_BOARD: - case FAN_5_ON_MAIN_BOARD: - case FAN_6_ON_MAIN_BOARD: - case FAN_7_ON_MAIN_BOARD: - case FAN_8_ON_MAIN_BOARD: - rc =_onlp_fani_info_get_fan(local_id, info); - break; - default: - rc = ONLP_STATUS_E_INVALID; - break; - } - - return rc; -} - -/* - * This function sets the speed of the given fan in RPM. - * - * This function will only be called if the fan supprots the RPM_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - float temp = 0.0; - int rv = 0, local_id = 0, nbytes = 10; - char r_data[10] = {0}; - onlp_fan_info_t* info = NULL; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - info = &linfo[local_id]; - - if (0 == (ONLP_FAN_CAPS_SET_RPM & info->caps)) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* reject rpm=0% (rpm=0%, stop fan) */ - if (0 == rpm) { - return ONLP_STATUS_E_INVALID; - } - - /* Set fan speed - Converting percent to driver value. - Driver accept value in range between 153 and 255. - Value 153 is minimum rpm. - Value 255 is maximum rpm. - */ - if (local_id > sizeof(min_fan_speed)/sizeof(min_fan_speed[0])) { - return ONLP_STATUS_E_INTERNAL; - } - if (max_fan_speed[local_id] - min_fan_speed[local_id] < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (rpm < min_fan_speed[local_id] || rpm > max_fan_speed[local_id]) { - return ONLP_STATUS_E_PARAM; - } - - temp = (rpm - min_fan_speed[local_id]) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / - (max_fan_speed[local_id] - min_fan_speed[local_id]) + RPM_MAGIC_MIN; - - snprintf(r_data, sizeof(r_data), "%d", (int)temp); - nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * This function sets the fan speed of the given OID as a percentage. - * - * This will only be called if the OID has the PERCENTAGE_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_percentage_set(onlp_oid_t id, int p) -{ - float temp = 0.0; - int rv = 0, local_id = 0, nbytes = 10; - char r_data[10] = {0}; - onlp_fan_info_t* info = NULL; - - VALIDATE(id); - local_id = ONLP_OID_ID_GET(id); - info = &linfo[local_id]; - - if (0 == (ONLP_FAN_CAPS_SET_PERCENTAGE & info->caps)) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* reject p=0% (p=0%, stop fan) */ - if (0 == p) { - return ONLP_STATUS_E_INVALID; - } - - if (p < PERCENTAGE_MIN || p > PERCENTAGE_MAX) { - return ONLP_STATUS_E_PARAM; - } - - /* Set fan speed - Converting percent to driver value. - Driver accept value in range between 153 and 255. - Value 153 is 60%. - Value 255 is 100%. - */ - temp = (p - PERCENTAGE_MIN) * (RPM_MAGIC_MAX - RPM_MAGIC_MIN) / - (PERCENTAGE_MAX - PERCENTAGE_MIN) + RPM_MAGIC_MIN; - - snprintf(r_data, sizeof(r_data), "%d", (int)temp); - nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * This function sets the fan speed of the given OID as per - * the predefined ONLP fan speed modes: off, slow, normal, fast, max. - * - * Interpretation of these modes is up to the platform. - * - */ -int -onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan direction of the given OID. - * - * This function is only relevant if the fan OID supports both direction - * capabilities. - * - * This function is optional unless the functionality is available. - */ -int -onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_fani_get_min_rpm(int id) -{ - int len = 0, nbytes = 10; - char r_data[10] = {0}; - - if (onlp_file_read((uint8_t*)r_data, nbytes, &len, "%s%s", PREFIX_PATH, fan_path[id].min) < 0) - return ONLP_STATUS_E_INTERNAL; - - return atoi(r_data); -} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c index 74386ff0..7fdb1f37 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c @@ -30,101 +30,9 @@ #include #include #include "platform_lib.h" +#include -#define prefix_path "/bsp/led/led_" -#define driver_value_len 50 - -#define LED_MODE_OFF "none" -#define LED_MODE_GREEN "green" -#define LED_MODE_RED "red" -#define LED_MODE_BLUE "blue" -#define LED_MODE_GREEN_BLINK "green_blink" -#define LED_MODE_RED_BLINK "red_blink" -#define LED_MODE_BLUE_BLINK "blue_blink" -#define LED_MODE_AUTO "cpld_control" - -#define LED_BLINK_PERIOD "100" -#define LED_ON "1" -#define LED_OFF "0" -#define LED_BLINK_PERIOD_LEN 3 -#define LED_MODE_LEN 1 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -typedef struct led_light_mode_map { - enum onlp_led_id id; - char* driver_led_mode; - enum onlp_led_mode_e onlp_led_mode; -} led_light_mode_map_t; - -led_light_mode_map_t led_map[] = { -{LED_SYSTEM, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_SYSTEM, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_SYSTEM, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_SYSTEM, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_SYSTEM, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_SYSTEM, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN1, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN1, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN1, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN1, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN2, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN2, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN2, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN2, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN3, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN3, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN3, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN3, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN3, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN3, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_FAN4, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_FAN4, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_FAN4, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_FAN4, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_FAN4, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_FAN4, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - -{LED_PSU, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_PSU, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_PSU, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_PSU, LED_MODE_RED_BLINK, ONLP_LED_MODE_RED_BLINKING}, -{LED_PSU, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING}, -{LED_PSU, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} -}; - -typedef struct led_colors { - enum onlp_led_id id; - const char* color1; - const char* color2; -} led_colors_t; - -static led_colors_t led_colors_map[] = { - {LED_SYSTEM, "green", "red"}, - {LED_FAN1, "green", "red"}, - {LED_FAN2, "green", "red"}, - {LED_FAN3, "green", "red"}, - {LED_FAN4, "green", "red"}, - {LED_PSU, "green", "red"}, -}; - -static char file_names[][10] = /* must map with onlp_led_id */ +static char* file_names[] = /* must map with onlp_led_id */ { "reserved", "status", @@ -179,213 +87,11 @@ static onlp_led_info_t linfo[] = } }; -static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode) -{ - char *pos; - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - if ((pos=strchr(driver_led_mode, '\n')) != NULL) - *pos = '\0'; - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && - !strncmp(led_map[i].driver_led_mode, driver_led_mode, driver_value_len)) - { - return led_map[i].onlp_led_mode; - } - } - - return 0; -} - -static char* onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) -{ - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) - { - return led_map[i].driver_led_mode; - } - } - - return LED_MODE_OFF; -} - -static int led_set_mode(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id = ONLP_OID_ID_GET(id); - char color[10]={0}; - int blinking = 0; - - switch (mode) { - case ONLP_LED_MODE_RED_BLINKING: - strcpy(color, "red"); - blinking = 1; - break; - case ONLP_LED_MODE_GREEN_BLINKING: - strcpy(color, "green"); - blinking = 1; - break; - case ONLP_LED_MODE_BLUE_BLINKING: - strcpy(color, "blue"); - blinking = 1; - break; - case ONLP_LED_MODE_YELLOW_BLINKING: - strcpy(color, "yellow"); - blinking = 1; - break; - case ONLP_LED_MODE_RED: - strcpy(color, "red"); - break; - case ONLP_LED_MODE_GREEN: - strcpy(color, "green"); - break; - case ONLP_LED_MODE_BLUE: - strcpy(color, "blue"); - break; - case ONLP_LED_MODE_YELLOW: - strcpy(color, "yellow"); - break; - default: - return ONLP_STATUS_E_PARAM; - } - - if (blinking) { - onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, - "%s%s_%s_delay_off", prefix_path, file_names[local_id], color); - onlp_file_write((uint8_t*)LED_BLINK_PERIOD, LED_BLINK_PERIOD_LEN, - "%s%s_%s_delay_on", prefix_path, file_names[local_id], color); - } - onlp_file_write((uint8_t*)LED_ON, LED_MODE_LEN, - "%s%s_%s", prefix_path, file_names[local_id], color); - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ int onlp_ledi_init(void) { - /* - * ONLPD calls it too early before all BSP insfrastructure is set - */ - + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->linfo = linfo; + mlnx_platform_info->led_fnames = file_names; return ONLP_STATUS_OK; } - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int len, local_id = 0; - uint8_t data[driver_value_len] = {0}; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - /* Get LED mode */ - if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { - char* cmd = aim_fstrdup("%s%s_state", prefix_path, file_names[local_id]); - if(system(cmd) != 0) { - aim_free(cmd); - return ONLP_STATUS_E_INTERNAL; - } - aim_free(cmd); - } - - if (onlp_file_read(data, sizeof(data), &len, "%s%s", - prefix_path, file_names[local_id]) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->mode = driver_to_onlp_led_mode(local_id, (char*)data); - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } - - return ONLP_STATUS_OK; -} - -/* - * Turn an LED on or off. - * - * This function will only be called if the LED OID supports the ONOFF - * capability. - * - * What 'on' means in terms of colors or modes for multimode LEDs is - * up to the platform to decide. This is intended as baseline toggle mechanism. - */ -int -onlp_ledi_set(onlp_oid_t id, int on_or_off) -{ - VALIDATE(id); - - if (!on_or_off) { - if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) - return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - else { - int i, nsize = sizeof(led_colors_map)/sizeof(led_colors_map[0]); - for (i = 0; i < nsize; i++) - { - if (id == led_colors_map[i].id) - break; - } - if (led_colors_map[i].color1) - onlp_file_write((uint8_t*)LED_OFF, LED_MODE_LEN, - "%s%s_%s", prefix_path, file_names[id], led_colors_map[i].color1); - } - } - - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function puts the LED into the given mode. It is a more functional - * interface for multimode LEDs. - * - * Only modes reported in the LED's capabilities will be attempted. - */ -int -onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id; - char* driver_led_mode; - int nbytes; - - VALIDATE(id); - - if (onlp_get_kernel_ver() < KERNEL_VERSION(4,9,30)) { - local_id = ONLP_OID_ID_GET(id); - driver_led_mode = onlp_to_driver_led_mode(local_id, mode); - nbytes = strnlen(driver_led_mode, driver_value_len); - if (onlp_file_write((uint8_t*)driver_led_mode, nbytes, - "%s%s", prefix_path, file_names[local_id]) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - } else { - if (led_set_mode(id, mode) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - - return ONLP_STATUS_OK; -} - -/* - * Generic LED ioctl interface. - */ -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h index 66581253..99bea7dc 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.h @@ -25,8 +25,6 @@ #ifndef __PLATFORM_LIB_H__ #define __PLATFORM_LIB_H__ -#include -#include #include "x86_64_mlnx_msn2700_log.h" #define CHASSIS_PSU_COUNT 2 @@ -34,43 +32,8 @@ #define CHASSIS_TOTAL_THERMAL_COUNT 8 #define CHASSIS_FAN_COUNT (CHASSIS_TOTAL_FAN_COUNT - CHASSIS_PSU_COUNT) #define CHASSIS_THERMAL_COUNT (CHASSIS_TOTAL_THERMAL_COUNT - CHASSIS_PSU_COUNT) - -#define PSU1_ID 1 -#define PSU2_ID 2 - -#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s" -#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" -#define IDPROM_PATH "/bsp/eeprom/%s%d_info" - -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -/* LED related data - */ -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SYSTEM, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_PSU, -}; - -typedef enum psu_type { - PSU_TYPE_UNKNOWN, - PSU_TYPE_AC_F2B, - PSU_TYPE_AC_B2F -} psu_type_t; - -psu_type_t get_psu_type(int id, char* modelname, int modelname_len); - -int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, - onlp_fan_info_t* fan_info); - -int onlp_fani_get_min_rpm(int id); -int onlp_get_kernel_ver(void); +#define CPLD_COUNT 3 +#define SFP_PORT_COUNT 32 +#define CHASSIS_LED_COUNT 6 #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c deleted file mode 100644 index f5555b60..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT 1 -#define PSU_CABLE_PRESENT 1 - -#define PSU_NODE_MAX_INT_LEN 8 -#define PSU_NODE_MAX_PATH_LEN 64 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -psu_module_info_get(int id, char *node, int *value) -{ - int len, ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - - *value = 0; - - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, - PSU_MODULE_PREFIX, id, node); - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static int -psu_power_info_get(int id, char *node, int *value) -{ - int len, ret = 0; - char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - - *value = 0; - - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, - PSU_POWER_PREFIX, id, node); - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -_psu_info_get(onlp_psu_info_t* info) -{ - int val = 0; - int index = ONLP_OID_ID_GET(info->hdr.id); - - /* Set capability - */ - info->caps = ONLP_PSU_CAPS_AC; - - if (info->status & ONLP_PSU_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - /* Set the associated oid_table */ - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); - - /* Read voltage, current and power */ - if (psu_power_info_get(index, "volt_in", &val) == 0 && - 0 != val) { - info->mvin = val; - info->caps |= ONLP_PSU_CAPS_VIN; - - if (psu_power_info_get(index, "volt", &val) == 0) { - info->mvout = val; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - if (psu_power_info_get(index, "curr_in", &val) == 0) { - info->miin = val; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - if (psu_power_info_get(index, "curr", &val) == 0) { - info->miout = val; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - if (psu_power_info_get(index, "power_in", &val) == 0) { - info->mpin = val; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - if (psu_power_info_get(index, "power", &val) == 0) { - info->mpout = val; - info->caps |= ONLP_PSU_CAPS_POUT; - } - } else { - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - return psu_read_eeprom(index, info, NULL); -} - -/* - * Get all information about the given PSU oid. - */ -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, - }, - { - { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, - } -}; - -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); - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - - /* Get the present state */ - if (psu_module_info_get(index, "status", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index); - } - - if (val != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; - } - else - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get the cable preset state */ - if (psu_module_info_get(index, "pwr_status", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index); - } - - if (val != PSU_CABLE_PRESENT) { - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; - } - - ret = _psu_info_get(info); - - return ret; -} - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c deleted file mode 100644 index 65cd8893..00000000 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sfpi.c +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define MAX_SFP_PATH 64 -#define SFP_SYSFS_VALUE_LEN 20 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define NUM_OF_SFP_PORT 32 -#define SFP_PRESENT_STATUS "good" -#define SFP_NOT_PRESENT_STATUS "not_connected" - -static int -sn2700_sfp_node_read_int(char *node_path, int *value) -{ - int data_len = 0, ret = 0; - char buf[SFP_SYSFS_VALUE_LEN] = {0}; - *value = -1; - char sfp_present_status[16]; - char sfp_not_present_status[16]; - - if (onlp_get_kernel_ver() >= KERNEL_VERSION(4,9,30)) { - strcpy(sfp_present_status, "1"); - strcpy(sfp_not_present_status, "0"); - } else { - strcpy(sfp_present_status, "good"); - strcpy(sfp_not_present_status, "not_connected"); - } - - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &data_len, node_path); - - if (ret == 0) { - if (!strncmp(buf, sfp_present_status, strlen(sfp_present_status))) { - *value = 1; - } else if (!strncmp(buf, sfp_not_present_status, strlen(sfp_not_present_status))) { - *value = 0; - } - } - - return ret; -} - -static char* -sn2700_sfp_get_port_path(int port, char *node_name) -{ - if (node_name) - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); - else - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); - return sfp_node_path; -} - -static char* -sn2700_sfp_convert_i2c_path(int port, int devaddr) -{ - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); - return sfp_node_path; -} - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {1, 32} - */ - int p = 1; - AIM_BITMAP_CLR_ALL(bmap); - - for (; p <= NUM_OF_SFP_PORT; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - /* - * Return 1 if present. - * Return 0 if not present. - * Return < 0 if error. - */ - int present = -1; - char* path = sn2700_sfp_get_port_path(port, "_status"); - - if (sn2700_sfp_node_read_int(path, &present) != 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int ii = 1; - int rc = 0; - - for (;ii <= NUM_OF_SFP_PORT; ii++) { - rc = onlp_sfpi_is_present(ii); - AIM_BITMAP_MOD(dst, ii, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char* path = sn2700_sfp_get_port_path(port, NULL); - - /* - * Read the SFP eeprom into data[] - * - * Return MISSING if SFP is missing. - * Return OK if eeprom is read - */ - memset(data, 0, 256); - - if (onlplib_sfp_eeprom_read_file(path, data) != 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - char* path = sn2700_sfp_convert_i2c_path(port, devaddr); - uint8_t data; - int fd; - int nrd; - - if (!path) - return ONLP_STATUS_E_MISSING; - - fd = open(path, O_RDONLY); - if (fd < 0) - return ONLP_STATUS_E_MISSING; - - lseek(fd, addr, SEEK_SET); - nrd = read(fd, &data, 1); - close(fd); - - if (nrd != 1) { - AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); - return ONLP_STATUS_E_INTERNAL; - } - return data; -} - -int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) -{ - char* path = sn2700_sfp_convert_i2c_path(port, devaddr); - uint16_t data; - int fd; - int nrd; - - if (!path){ - return ONLP_STATUS_E_MISSING; - } - - fd = open(path, O_RDONLY); - if (fd < 0) { - return ONLP_STATUS_E_MISSING; - } - - lseek(fd, addr, SEEK_SET); - nrd = read(fd, &data, 2); - close(fd); - - if (nrd != 2) { - AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path); - return ONLP_STATUS_E_INTERNAL; - } - return data; -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c index 7b267507..fd56b98a 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/sysi.c @@ -35,205 +35,54 @@ #include "platform_lib.h" #include "x86_64_mlnx_msn2700_int.h" #include "x86_64_mlnx_msn2700_log.h" +#include -#define ONL_PLATFORM_NAME "x86-64-mlnx-msn2700-r0" -#define ONIE_PLATFORM_NAME "x86_64-mlnx_msn2700-r0" - -#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 6 +static const char* __ONL_PLATFORM_NAME = NULL; #define COMMAND_OUTPUT_BUFFER 256 -#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld" -#define NUM_OF_CPLD 3 -static char arr_cplddev_name[NUM_OF_CPLD][30] = +int mc_get_platform_info(mlnx_platform_info_t* mlnx_platform) { - "cpld_brd_version", - "cpld_mgmt_version", - "cpld_port_version" -}; - -const char* -onlp_sysi_platform_get(void) -{ - return ONL_PLATFORM_NAME; -} - -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", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d, port=%d", v[0], v[1], v[2]); - - return ONLP_STATUS_OK; -} - -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) -{ - int i; - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - - /* 8 Thermal sensors on the chassis */ - for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* 6 LEDs on the chassis */ - for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* 2 PSUs on the chassis */ - for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_PSU_ID_CREATE(i); - } - - /* 8 Fans and 2 PSU fans on the chassis */ - for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv = onlp_onie_read_json(onie, - "/lib/platform-config/current/onl/etc/onie/eeprom.json"); - if(rv >= 0) { - if(onie->platform_name) { - aim_free(onie->platform_name); - } - onie->platform_name = aim_strdup(ONIE_PLATFORM_NAME); - } - - return rv; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int fan_number, psu_number; - onlp_led_mode_t mode, system_mode; - int min_fan_speed; - enum onlp_led_id fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 }; - int fan_problem = 0; - int psu_problem = 0; - - /* - * FAN Indicators - * - * Green - Fan is operating - * Red - No power or Fan failure - * Off - No power - * - */ - for( fan_number = 1; fan_number <= CHASSIS_FAN_COUNT; fan_number+=2) - { - /* each 2 fans had same led_fan */ - onlp_fan_info_t fi; - /* check fan i */ - mode = ONLP_LED_MODE_GREEN; - if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if( (fi.status & ONLP_FAN_STATUS_PRESENT) == 0) { - /* Not present */ - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if(fi.status & ONLP_FAN_STATUS_FAILED) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else - { - min_fan_speed = onlp_fani_get_min_rpm(fan_number); - if( fi.rpm < min_fan_speed) - { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - } - /* check fan i+1 */ - if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if( (fi.status & 0x1) == 0) { - /* Not present */ - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else if(fi.status & ONLP_FAN_STATUS_FAILED) { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - else - { - min_fan_speed = onlp_fani_get_min_rpm(fan_number+1); - if( fi.rpm < min_fan_speed) - { - mode = ONLP_LED_MODE_RED; - fan_problem = 1; - } - } - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode); + if (!__ONL_PLATFORM_NAME) { + strncpy(mlnx_platform->onl_platform_name, "x86-64-mlnx-msn2700-all", PLATFORM_NAME_MAX_LEN); } - - for (psu_number = 1; psu_number <= CHASSIS_PSU_COUNT; psu_number++) - { - onlp_psu_info_t pi; - if(onlp_psui_info_get(ONLP_PSU_ID_CREATE(psu_number), &pi) < 0) { - psu_problem = 1; - } - else if((pi.status & ONLP_PSU_STATUS_PRESENT) == 0) { - /* Not present */ - psu_problem = 1; - } - else if(pi.status & ONLP_PSU_STATUS_UNPLUGGED) { - psu_problem = 1; - } + else { + strncpy(mlnx_platform->onl_platform_name, __ONL_PLATFORM_NAME, PLATFORM_NAME_MAX_LEN); } - - if (psu_problem) - mode = ONLP_LED_MODE_RED; - else - mode = ONLP_LED_MODE_GREEN; - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, LED_PSU), mode); - - /* Set System status LED green if no problem in FANs or PSUs */ - if (fan_problem || psu_problem) - system_mode = ONLP_LED_MODE_RED; - else - system_mode = ONLP_LED_MODE_GREEN; - - onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), system_mode); + mlnx_platform->sfp_num = SFP_PORT_COUNT; + mlnx_platform->led_num = CHASSIS_LED_COUNT; + mlnx_platform->psu_num = CHASSIS_PSU_COUNT; + mlnx_platform->fan_num = CHASSIS_FAN_COUNT; + mlnx_platform->thermal_num = CHASSIS_THERMAL_COUNT; + mlnx_platform->cpld_num = CPLD_COUNT; + mlnx_platform->psu_fixed = false; + mlnx_platform->fan_fixed = false; + mlnx_platform->psu_type = PSU_TYPE_2; + mlnx_platform->led_type = LED_TYPE_2; return ONLP_STATUS_OK; } +int +onlp_sysi_platform_set(const char* platform) +{ + mlnx_platform_info_t* mlnx_platform; + + if(!strcmp(platform, "x86-64-mlnx-msn2700-r0")) { + __ONL_PLATFORM_NAME = "x86-64-mlnx_msn2700-r0"; + mlnx_platform = get_platform_info(); + mc_get_platform_info(mlnx_platform); + return ONLP_STATUS_OK; + } + if(!strcmp(platform, "x86-64-mlnx-msn2700-all")) { + __ONL_PLATFORM_NAME = "x86-64-mlnx-msn2700-all"; + return ONLP_STATUS_OK; + } + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c index 698be008..82b44635 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c @@ -29,45 +29,7 @@ #include #include #include "platform_lib.h" - -#define prefix_path "/bsp/thermal" - -/** CPU thermal_threshold */ -typedef enum cpu_thermal_threshold_e { - CPU_THERMAL_THRESHOLD_WARNING_DEFAULT = 87000, - CPU_THERMAL_THRESHOLD_ERROR_DEFAULT = 100000, - CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 105000, -} cpu_thermal_threshold_t; - -/** - * Shortcut for CPU thermal threshold value. - */ -#define CPU_THERMAL_THRESHOLD_INIT_DEFAULTS \ - { CPU_THERMAL_THRESHOLD_WARNING_DEFAULT, \ - CPU_THERMAL_THRESHOLD_ERROR_DEFAULT, \ - CPU_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } - -/** Asic thermal_threshold */ -typedef enum asic_thermal_threshold_e { - ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT = 105000, - ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT = 115000, - ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT = 120000, -} asic_thermal_threshold_t; - -/** - * Shortcut for CPU thermal threshold value. - */ -#define ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS \ - { ASIC_THERMAL_THRESHOLD_WARNING_DEFAULT, \ - ASIC_THERMAL_THRESHOLD_ERROR_DEFAULT, \ - ASIC_THERMAL_THRESHOLD_SHUTDOWN_DEFAULT } - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) +#include "mlnx_common/mlnx_common.h" enum onlp_thermal_id { @@ -82,7 +44,7 @@ enum onlp_thermal_id THERMAL_ON_PSU2, }; -static char* last_path[] = /* must map with onlp_thermal_id */ +static char* thermal_fnames[] = /* must map with onlp_thermal_id */ { "reserved", "cpu_core0", @@ -96,7 +58,7 @@ static char* last_path[] = /* must map with onlp_thermal_id */ }; /* Static values */ -static onlp_thermal_info_t linfo[] = { +static onlp_thermal_info_t tinfo[] = { { }, /* Not used */ { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0}, ONLP_THERMAL_STATUS_PRESENT, @@ -138,39 +100,9 @@ static onlp_thermal_info_t linfo[] = { int onlp_thermali_init(void) { - return ONLP_STATUS_OK; -} - -/* - * Retrieve the information structure for the given thermal OID. - * - * If the OID is invalid, return ONLP_E_STATUS_INVALID. - * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. - * Otherwise, return ONLP_STATUS_OK with the OID's information. - * - * Note -- it is expected that you fill out the information - * structure even if the sensor described by the OID is not present. - */ -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) -{ - int rv, len = 10, temp_base=1, local_id = 0; - char r_data[10] = {0}; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; - - rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, "%s/%s", - prefix_path, last_path[local_id]); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->mcelsius = atoi(r_data) / temp_base; - + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->tinfo=tinfo; + mlnx_platform_info->thermal_fnames=thermal_fnames; return ONLP_STATUS_OK; } From f4fad36ecaabebeb20554641f5745a48edea8e59 Mon Sep 17 00:00:00 2001 From: Nataliya Yakuts Date: Mon, 26 Mar 2018 15:00:26 +0000 Subject: [PATCH 196/244] MSN2740 platform support Signed-off-by: Nataliya Yakuts Reviewed-by: Michael Shych --- .../x86-64/x86-64-mlnx-msn2740/Makefile | 1 + .../x86-64-mlnx-msn2740/modules/Makefile | 1 + .../x86-64-mlnx-msn2740/modules/PKG.yml | 1 + .../x86-64/x86-64-mlnx-msn2740/onlp/Makefile | 1 + .../x86-64/x86-64-mlnx-msn2740/onlp/PKG.yml | 1 + .../x86-64-mlnx-msn2740/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++++++ .../lib/libonlp-x86-64-mlnx-msn2740-r0.mk | 9 ++ .../builds/lib/libonlp-x86-64-mlnx-msn2740.mk | 9 ++ .../onlp/builds/lib/x86_64_mlnx_msn2740.mk | 9 ++ .../onlp/builds/onlpdump/Makefile | 45 ++++++ .../onlp/builds/onlpdump/onlpdump.mk | 9 ++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 ++ .../onlp/builds/src/README | 5 + .../onlp/builds/src/module/auto/make.mk | 8 + .../src/module/auto/x86_64_mlnx_msn2740.yml | 50 +++++++ .../x86_64_mlnx_msn2740/x86_64_mlnx_msn2740.x | 12 ++ .../x86_64_mlnx_msn2740_config.h | 137 ++++++++++++++++++ .../x86_64_mlnx_msn2740_dox.h | 26 ++++ .../x86_64_mlnx_msn2740_porting.h | 107 ++++++++++++++ .../onlp/builds/src/module/make.mk | 9 ++ .../onlp/builds/src/module/src/Makefile | 8 + .../onlp/builds/src/module/src/fani.c | 81 +++++++++++ .../onlp/builds/src/module/src/ledi.c | 97 +++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 ++ .../onlp/builds/src/module/src/platform_lib.h | 39 +++++ .../onlp/builds/src/module/src/sysi.c | 88 +++++++++++ .../onlp/builds/src/module/src/thermali.c | 116 +++++++++++++++ .../module/src/x86_64_mlnx_msn2740_config.c | 80 ++++++++++ .../module/src/x86_64_mlnx_msn2740_enums.c | 9 ++ .../src/module/src/x86_64_mlnx_msn2740_int.h | 12 ++ .../src/module/src/x86_64_mlnx_msn2740_log.c | 17 +++ .../src/module/src/x86_64_mlnx_msn2740_log.h | 12 ++ .../module/src/x86_64_mlnx_msn2740_module.c | 24 +++ .../src/module/src/x86_64_mlnx_msn2740_ucli.c | 49 +++++++ .../onlp/builds/src/x86_64_mlnx_msn2740.mk | 12 ++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/x86-64-mlnx-msn2740-r0.yml | 36 +++++ .../python/x86_64_mlnx_msn2740_r0/__init__.py | 17 +++ 42 files changed, 1206 insertions(+) create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/PKG.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/PKG.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740-r0.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/x86_64_mlnx_msn2740.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/onlpdump.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/.module create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/README create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/x86_64_mlnx_msn2740.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740.x create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_config.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_dox.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_porting.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/make.mk create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/Makefile create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/ledi.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/make.mk create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/platform_lib.h create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/sysi.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_config.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_enums.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_int.h create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.h create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_module.c create mode 100755 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_ucli.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/x86_64_mlnx_msn2740.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/PKG.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/lib/x86-64-mlnx-msn2740-r0.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/python/x86_64_mlnx_msn2740_r0/__init__.py diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/PKG.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/PKG.yml new file mode 100644 index 00000000..f1575509 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=mellanox BASENAME=x86-64-mlnx-msn2740 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/PKG.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/PKG.yml new file mode 100644 index 00000000..84fd2de2 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-mlnx-msn2740 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/Makefile new file mode 100644 index 00000000..41006cf5 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-mlnx-msn2740 +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF mlnx_common x86_64_mlnx_msn2740 onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-mlnx-msn2740.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740-r0.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740-r0.mk new file mode 100644 index 00000000..9544b21f --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740-r0.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2740-r0 module. +# +# Autogenerated 2015-12-23 23:45:22.249911 +# +############################################################################### +libonlp-x86-64-mlnx-msn2740-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740.mk new file mode 100644 index 00000000..fea561f3 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/libonlp-x86-64-mlnx-msn2740.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2740 module. +# +# Autogenerated 2016-10-13 22:58:39.095824 +# +############################################################################### +libonlp-x86-64-mlnx-msn2740_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/x86_64_mlnx_msn2740.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/x86_64_mlnx_msn2740.mk new file mode 100644 index 00000000..3d1837c4 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/lib/x86_64_mlnx_msn2740.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the x86_64_mlnx_msn2740 module. +# +# Autogenerated 2015-12-23 23:45:22.262891 +# +############################################################################### +x86_64_mlnx_msn2740_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..174fe7e1 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp mlnx_common x86_64_mlnx_msn2740 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/onlpdump.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/onlpdump.mk new file mode 100644 index 00000000..106c5270 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/onlpdump/onlpdump.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the onlpdump module. +# +# Autogenerated 2016-10-13 22:58:37.393320 +# +############################################################################### +onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/.module b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/.module new file mode 100644 index 00000000..acb589d6 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_mlnx_msn2740 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/Makefile new file mode 100644 index 00000000..694d205e --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_mlnx_msn2740 +AUTOMODULE := x86_64_mlnx_msn2740 +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/README b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/README new file mode 100644 index 00000000..9b10af05 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/README @@ -0,0 +1,5 @@ +############################################################################### +# +# x86_64_mlnx_msn2740 README +# +############################################################################### diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/make.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..6eb0710b --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,8 @@ +############################################################################### +# +# x86_64_mlnx_msn2740 Autogeneration +# +############################################################################### +x86_64_mlnx_msn2740_AUTO_DEFS := module/auto/x86_64_mlnx_msn2740.yml +x86_64_mlnx_msn2740_AUTO_DIRS := module/inc/x86_64_mlnx_msn2740 module/src +include $(BUILDER)/auto.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/x86_64_mlnx_msn2740.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/x86_64_mlnx_msn2740.yml new file mode 100644 index 00000000..351b604f --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/auto/x86_64_mlnx_msn2740.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_mlnx_msn2740 Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: x86_64_mlnx_msn2740_CONFIG_PORTING_STDLIB +- X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_MLNX_MSN2740_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_mlnx_msn2740_config + + portingmacro: + x86_64_mlnx_msn2740: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740.x b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740.x new file mode 100644 index 00000000..6afa4de3 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740.x @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_config.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_config.h new file mode 100644 index 00000000..b5355e36 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_mlnx_msn2740 Configuration Header + * + * @addtogroup x86_64_mlnx_msn2740-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2740_CONFIG_H__ +#define __X86_64_MLNX_MSN2740_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_MLNX_MSN2740_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING +#define X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT +#define X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB +#define X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI +#define X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_mlnx_msn2740_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_mlnx_msn2740_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_mlnx_msn2740_config_settings table. */ +extern x86_64_mlnx_msn2740_config_settings_t x86_64_mlnx_msn2740_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_mlnx_msn2740_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_mlnx_msn2740_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_mlnx_msn2740_porting.h" + +#endif /* __X86_64_MLNX_MSN2740_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_dox.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_dox.h new file mode 100644 index 00000000..98d6fdce --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_mlnx_msn2740 Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2740_DOX_H__ +#define __X86_64_MLNX_MSN2740_DOX_H__ + +/** + * @defgroup x86_64_mlnx_msn2740 x86_64_mlnx_msn2740 - x86_64_mlnx_msn2740 Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_mlnx_msn2740-x86_64_mlnx_msn2740 Public Interface + * @defgroup x86_64_mlnx_msn2740-config Compile Time Configuration + * @defgroup x86_64_mlnx_msn2740-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_MLNX_MSN2740_DOX_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_porting.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_porting.h new file mode 100644 index 00000000..877af460 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/inc/x86_64_mlnx_msn2740/x86_64_mlnx_msn2740_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_mlnx_msn2740 Porting Macros. + * + * @addtogroup x86_64_mlnx_msn2740-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2740_PORTING_H__ +#define __X86_64_MLNX_MSN2740_PORTING_H__ + + +/* */ +#if X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_MLNX_MSN2740_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_MLNX_MSN2740_MALLOC GLOBAL_MALLOC + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_MALLOC malloc + #else + #error The macro X86_64_MLNX_MSN2740_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_FREE + #if defined(GLOBAL_FREE) + #define X86_64_MLNX_MSN2740_FREE GLOBAL_FREE + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_FREE free + #else + #error The macro X86_64_MLNX_MSN2740_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_MLNX_MSN2740_MEMSET GLOBAL_MEMSET + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_MEMSET memset + #else + #error The macro X86_64_MLNX_MSN2740_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_MLNX_MSN2740_MEMCPY GLOBAL_MEMCPY + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_MEMCPY memcpy + #else + #error The macro X86_64_MLNX_MSN2740_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_MLNX_MSN2740_STRNCPY GLOBAL_STRNCPY + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_STRNCPY strncpy + #else + #error The macro X86_64_MLNX_MSN2740_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_MLNX_MSN2740_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_VSNPRINTF vsnprintf + #else + #error The macro X86_64_MLNX_MSN2740_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_MLNX_MSN2740_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_SNPRINTF snprintf + #else + #error The macro X86_64_MLNX_MSN2740_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2740_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_MLNX_MSN2740_STRLEN GLOBAL_STRLEN + #elif X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2740_STRLEN strlen + #else + #error The macro X86_64_MLNX_MSN2740_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_MLNX_MSN2740_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/make.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..3e6697a9 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_mlnx_msn2740_INCLUDES := -I $(THIS_DIR)inc +x86_64_mlnx_msn2740_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_mlnx_msn2740_DEPENDMODULE_ENTRIES := init:x86_64_mlnx_msn2740 ucli:x86_64_mlnx_msn2740 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/Makefile new file mode 100755 index 00000000..6fdb0564 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/Makefile @@ -0,0 +1,8 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_mlnx_msn2740_ucli.c diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/fani.c new file mode 100755 index 00000000..7e57fcb6 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/fani.c @@ -0,0 +1,81 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" +#include "mlnx_common/mlnx_common.h" + +#define FAN_RESERVED 0 +#define FAN_1_ON_MAIN_BOARD 1 +#define FAN_2_ON_MAIN_BOARD 2 +#define FAN_3_ON_MAIN_BOARD 3 +#define FAN_4_ON_MAIN_BOARD 4 +#define FAN_1_ON_PSU1 5 +#define FAN_1_ON_PSU2 6 + +#define FIRST_PSU_FAN_ID 5 + +static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; +static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; + +static fan_path_T fan_path[] = /* must map with onlp_fan_id */ +{ + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_PSU(1 ,1), + MAKE_FAN_PATH_ON_PSU(2, 1) +}; + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1) +}; + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->min_fan_speed=min_fan_speed; + mlnx_platform_info->max_fan_speed=max_fan_speed; + mlnx_platform_info->finfo = finfo; + mlnx_platform_info->fan_fnames = fan_path; + mlnx_platform_info->fan_type = FAN_TYPE_NO_EEPROM; + mlnx_platform_info->first_psu_fan_id = FIRST_PSU_FAN_ID; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..7fdb1f37 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,97 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include + +static char* file_names[] = /* must map with onlp_led_id */ +{ + "reserved", + "status", + "fan1", + "fan2", + "fan3", + "fan4", + "psu" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYSTEM), "Chassis LED 1 (SYSTEM LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN1), "Chassis LED 2 (FAN1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN2), "Chassis LED 3 (FAN2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN3), "Chassis LED 4 (FAN3 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN4), "Chassis LED 5 (FAN4 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU), "Chassis LED 6 (PSU LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + } +}; + +int +onlp_ledi_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->linfo = linfo; + mlnx_platform_info->led_fnames = file_names; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/make.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/make.mk new file mode 100755 index 00000000..700f8d78 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_mlnx_msn2740 +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..e09b220b --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,39 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_mlnx_msn2740_log.h" + +#define CHASSIS_PSU_COUNT 2 +#define CHASSIS_TOTAL_FAN_COUNT 6 +#define CHASSIS_TOTAL_THERMAL_COUNT 9 +#define CHASSIS_FAN_COUNT (CHASSIS_TOTAL_FAN_COUNT - CHASSIS_PSU_COUNT) +#define CHASSIS_THERMAL_COUNT (CHASSIS_TOTAL_THERMAL_COUNT - CHASSIS_PSU_COUNT) +#define CPLD_COUNT 2 +#define SFP_PORT_COUNT 32 +#define CHASSIS_LED_COUNT 6 + +#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..3e806c26 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,88 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_mlnx_msn2740_int.h" +#include "x86_64_mlnx_msn2740_log.h" +#include + +static const char* __ONL_PLATFORM_NAME = NULL; + +#define COMMAND_OUTPUT_BUFFER 256 + +int mc_get_platform_info(mlnx_platform_info_t* mlnx_platform) +{ + if (!__ONL_PLATFORM_NAME) { + strncpy(mlnx_platform->onl_platform_name, "x86-64-mlnx-msn2740-all", PLATFORM_NAME_MAX_LEN); + } + else { + strncpy(mlnx_platform->onl_platform_name, __ONL_PLATFORM_NAME, PLATFORM_NAME_MAX_LEN); + } + mlnx_platform->sfp_num = SFP_PORT_COUNT; + mlnx_platform->led_num = CHASSIS_LED_COUNT; + mlnx_platform->psu_num = CHASSIS_PSU_COUNT; + mlnx_platform->fan_num = CHASSIS_FAN_COUNT; + mlnx_platform->thermal_num = CHASSIS_THERMAL_COUNT; + mlnx_platform->cpld_num = CPLD_COUNT; + mlnx_platform->psu_fixed = false; + mlnx_platform->fan_fixed = false; + mlnx_platform->psu_type = PSU_TYPE_2; + mlnx_platform->led_type = LED_TYPE_2; + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_set(const char* platform) +{ + mlnx_platform_info_t* mlnx_platform; + + if(!strcmp(platform, "x86-64-mlnx-msn2740-r0")) { + __ONL_PLATFORM_NAME = "x86-64-mlnx_msn2740-r0"; + mlnx_platform = get_platform_info(); + mc_get_platform_info(mlnx_platform); + return ONLP_STATUS_OK; + } + if(!strcmp(platform, "x86-64-mlnx-msn2740-all")) { + __ONL_PLATFORM_NAME = "x86-64-mlnx-msn2740-all"; + return ONLP_STATUS_OK; + } + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c new file mode 100755 index 00000000..7011410d --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,116 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "mlnx_common/mlnx_common.h" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE_0, + THERMAL_CPU_CORE_1, + THERMAL_CPU_CORE_2, + THERMAL_CPU_CORE_3, + THERMAL_ASIC, + THERMAL_BOARD_AMB, + THERMAL_PORT, + THERMAL_ON_PSU1, + THERMAL_ON_PSU2, +}; + +static char* thermal_fnames[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "cpu_core0", + "cpu_core1", + "cpu_core2", + "cpu_core3", + "asic", + "board_amb", + "port_amb", + "psu1", + "psu2" +}; + +/* Static values */ +static onlp_thermal_info_t tinfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_1), "CPU Core 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_1), "CPU Core 3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + + { { ONLP_THERMAL_ID_CREATE(THERMAL_ASIC), "Asic Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_BOARD_AMB), "Board AMB Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_PORT), "Port AMB Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->tinfo=tinfo; + mlnx_platform_info->thermal_fnames=thermal_fnames; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_config.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_config.c new file mode 100755 index 00000000..0e36b019 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(_x) #_x +#define __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(_x) __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(_x) +x86_64_mlnx_msn2740_config_settings_t x86_64_mlnx_msn2740_config_settings[] = +{ +#ifdef X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_INCLUDE_LOGGING(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_PORTING_STDLIB(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_INCLUDE_UCLI(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_MLNX_MSN2740_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_VALUE +#undef __X86_64_MLNX_MSN2740_CONFIG_STRINGIFY_NAME + +const char* +x86_64_mlnx_msn2740_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_mlnx_msn2740_config_settings[i].name; i++) { + if(strcmp(x86_64_mlnx_msn2740_config_settings[i].name, setting)) { + return x86_64_mlnx_msn2740_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_mlnx_msn2740_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_mlnx_msn2740_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_mlnx_msn2740_config_settings[i].name, x86_64_mlnx_msn2740_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_enums.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_enums.c new file mode 100755 index 00000000..c3941c2e --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_enums.c @@ -0,0 +1,9 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_int.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_int.h new file mode 100755 index 00000000..af3aad73 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_mlnx_msn2740 Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2740_INT_H__ +#define __X86_64_MLNX_MSN2740_INT_H__ + +#include + + +#endif /* __X86_64_MLNX_MSN2740_INT_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.c new file mode 100755 index 00000000..84e8bb16 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.c @@ -0,0 +1,17 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_mlnx_msn2740_log.h" +/* + * x86_64_mlnx_msn2740 log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_MLNX_MSN2740_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_MLNX_MSN2740_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_MLNX_MSN2740_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.h new file mode 100755 index 00000000..63666c33 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2740_LOG_H__ +#define __X86_64_MLNX_MSN2740_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_mlnx_msn2740 +#include + +#endif /* __X86_64_MLNX_MSN2740_LOG_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_module.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_module.c new file mode 100755 index 00000000..b930872a --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_mlnx_msn2740_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_mlnx_msn2740_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_mlnx_msn2740_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_ucli.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_ucli.c new file mode 100755 index 00000000..e0fc13bb --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/x86_64_mlnx_msn2740_ucli.c @@ -0,0 +1,49 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_mlnx_msn2740_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_mlnx_msn2740_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_mlnx_msn2740) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_mlnx_msn2740_ucli_module__ = + { + "x86_64_mlnx_msn2740_ucli", + NULL, + x86_64_mlnx_msn2740_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_mlnx_msn2740_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_mlnx_msn2740_ucli_module__); + n = ucli_node_create("x86_64_mlnx_msn2740", NULL, &x86_64_mlnx_msn2740_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_mlnx_msn2740")); + return n; +} + +#else +void* +x86_64_mlnx_msn2740_ucli_node_create(void) +{ + return NULL; +} +#endif diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/x86_64_mlnx_msn2740.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/x86_64_mlnx_msn2740.mk new file mode 100644 index 00000000..8e7f42b3 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/x86_64_mlnx_msn2740.mk @@ -0,0 +1,12 @@ + +############################################################################### +# +# Inclusive Makefile for the x86_64_mlnx_msn2740 module. +# +# Autogenerated 2015-12-23 23:45:56.754200 +# +############################################################################### +x86_64_mlnx_msn2740_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(x86_64_mlnx_msn2740_BASEDIR)/module/make.mk +include $(x86_64_mlnx_msn2740_BASEDIR)/module/auto/make.mk +include $(x86_64_mlnx_msn2740_BASEDIR)/module/src/make.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/PKG.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/PKG.yml new file mode 100644 index 00000000..c2a7179f --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=mellanox BASENAME=x86-64-mlnx-msn2740 REVISION=r0 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/lib/x86-64-mlnx-msn2740-r0.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/lib/x86-64-mlnx-msn2740-r0.yml new file mode 100644 index 00000000..f5c24ef2 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/lib/x86-64-mlnx-msn2740-r0.yml @@ -0,0 +1,36 @@ +--- + +###################################################################### +# +# platform-config for Mellanox 2740 +# +###################################################################### + +x86-64-mlnx-msn2740-r0: + + grub: + + serial: >- + --unit=0 + --speed=115200 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-4-9 + + args: >- + nopat + console=ttyS0,115200n8 + rd_NO_MD + rd_NO_LUKS + acpi_enforce_resources=lax + acpi=noirq + i2c-ismt.enable=0 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/python/x86_64_mlnx_msn2740_r0/__init__.py b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/python/x86_64_mlnx_msn2740_r0/__init__.py new file mode 100644 index 00000000..5e2bc914 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/platform-config/r0/src/python/x86_64_mlnx_msn2740_r0/__init__.py @@ -0,0 +1,17 @@ +from onl.platform.base import * +from onl.platform.mellanox import * + +class OnlPlatform_x86_64_mlnx_msn2740_r0(OnlPlatformMellanox, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-mlnx-msn2740-r0' + MODEL="MSN2740" + SYS_OBJECT_ID=".2740.1" + + def baseconfig(self): + # load modules + import os + # necessary if there are issues with the install + # os.system("/usr/bin/apt-get install") + os.system("/etc/mlnx/mlnx-hw-management start") + self.syseeprom_export(); + return True From 8b06acb96a8d21c70442a6923bed301007bce298 Mon Sep 17 00:00:00 2001 From: Nataliya Yakuts Date: Mon, 26 Mar 2018 16:41:46 +0000 Subject: [PATCH 197/244] MSN2010 platform support Signed-off-by: Nataliya Yakuts Reviewed-by: Michael Shych --- .../x86-64/x86-64-mlnx-msn2010/Makefile | 1 + .../x86-64-mlnx-msn2010/modules/Makefile | 1 + .../x86-64-mlnx-msn2010/modules/PKG.yml | 1 + .../x86-64/x86-64-mlnx-msn2010/onlp/Makefile | 1 + .../x86-64/x86-64-mlnx-msn2010/onlp/PKG.yml | 1 + .../x86-64-mlnx-msn2010/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++++++ .../lib/libonlp-x86-64-mlnx-msn2010-r0.mk | 9 ++ .../builds/lib/libonlp-x86-64-mlnx-msn2010.mk | 9 ++ .../onlp/builds/lib/x86_64_mlnx_msn2010.mk | 9 ++ .../onlp/builds/onlpdump/Makefile | 45 ++++++ .../onlp/builds/onlpdump/onlpdump.mk | 9 ++ .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 ++ .../onlp/builds/src/README | 5 + .../onlp/builds/src/module/auto/make.mk | 8 + .../src/module/auto/x86_64_mlnx_msn2010.yml | 50 +++++++ .../x86_64_mlnx_msn2010/x86_64_mlnx_msn2010.x | 12 ++ .../x86_64_mlnx_msn2010_config.h | 137 ++++++++++++++++++ .../x86_64_mlnx_msn2010_dox.h | 26 ++++ .../x86_64_mlnx_msn2010_porting.h | 107 ++++++++++++++ .../onlp/builds/src/module/make.mk | 9 ++ .../onlp/builds/src/module/src/Makefile | 8 + .../onlp/builds/src/module/src/fani.c | 75 ++++++++++ .../onlp/builds/src/module/src/ledi.c | 93 ++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 ++ .../onlp/builds/src/module/src/platform_lib.h | 37 +++++ .../onlp/builds/src/module/src/sysi.c | 65 +++++++++ .../onlp/builds/src/module/src/thermali.c | 101 +++++++++++++ .../module/src/x86_64_mlnx_msn2010_config.c | 80 ++++++++++ .../module/src/x86_64_mlnx_msn2010_enums.c | 9 ++ .../src/module/src/x86_64_mlnx_msn2010_int.h | 13 ++ .../src/module/src/x86_64_mlnx_msn2010_log.c | 17 +++ .../src/module/src/x86_64_mlnx_msn2010_log.h | 12 ++ .../module/src/x86_64_mlnx_msn2010_module.c | 24 +++ .../src/module/src/x86_64_mlnx_msn2010_ucli.c | 49 +++++++ .../onlp/builds/src/x86_64_mlnx_msn2010.mk | 12 ++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/x86-64-mlnx-msn2010-r0.yml | 36 +++++ .../python/x86_64_mlnx_msn2010_r0/__init__.py | 17 +++ 42 files changed, 1157 insertions(+) create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/PKG.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/PKG.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010-r0.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/x86_64_mlnx_msn2010.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/onlpdump.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/.module create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/README create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/x86_64_mlnx_msn2010.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010.x create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_config.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_dox.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_porting.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/make.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_config.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_enums.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_int.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.h create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_module.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_ucli.c create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/x86_64_mlnx_msn2010.mk create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/Makefile create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/PKG.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/lib/x86-64-mlnx-msn2010-r0.yml create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/python/x86_64_mlnx_msn2010_r0/__init__.py diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/PKG.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/PKG.yml new file mode 100644 index 00000000..ef88bf5d --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=mellanox BASENAME=x86-64-mlnx-msn2010 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/PKG.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/PKG.yml new file mode 100644 index 00000000..2ebfc601 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-mlnx-msn2010 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/Makefile new file mode 100644 index 00000000..f6019894 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-mlnx-msn2010 +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF mlnx_common x86_64_mlnx_msn2010 onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-mlnx-msn2010.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -I$(mlnx_common_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010-r0.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010-r0.mk new file mode 100644 index 00000000..9e270365 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010-r0.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2010-r0 module. +# +# Autogenerated 2015-12-23 23:45:22.249911 +# +############################################################################### +libonlp-x86-64-mlnx-msn2010-r0_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010.mk new file mode 100644 index 00000000..dd7ef562 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/libonlp-x86-64-mlnx-msn2010.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-mlnx-msn2010 module. +# +# Autogenerated 2016-10-13 22:58:39.095824 +# +############################################################################### +libonlp-x86-64-mlnx-msn2010_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/x86_64_mlnx_msn2010.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/x86_64_mlnx_msn2010.mk new file mode 100644 index 00000000..b17980f9 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/lib/x86_64_mlnx_msn2010.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the x86_64_mlnx_msn2010 module. +# +# Autogenerated 2015-12-23 23:45:22.262891 +# +############################################################################### +x86_64_mlnx_msn2010_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..b6a3ffd5 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp mlnx_common x86_64_mlnx_msn2010 onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/onlpdump.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/onlpdump.mk new file mode 100644 index 00000000..106c5270 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/onlpdump/onlpdump.mk @@ -0,0 +1,9 @@ + +############################################################################### +# +# Inclusive Makefile for the onlpdump module. +# +# Autogenerated 2016-10-13 22:58:37.393320 +# +############################################################################### +onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/.module b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/.module new file mode 100644 index 00000000..d39d9cbd --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_mlnx_msn2010 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/Makefile new file mode 100644 index 00000000..149e1065 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_mlnx_msn2010 +AUTOMODULE := x86_64_mlnx_msn2010 +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/README b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/README new file mode 100644 index 00000000..c494aa19 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/README @@ -0,0 +1,5 @@ +############################################################################### +# +# x86_64_mlnx_msn2010 README +# +############################################################################### diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/make.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..44d4a9cf --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,8 @@ +############################################################################### +# +# x86_64_mlnx_msn2010 Autogeneration +# +############################################################################### +x86_64_mlnx_msn2010_AUTO_DEFS := module/auto/x86_64_mlnx_msn2010.yml +x86_64_mlnx_msn2010_AUTO_DIRS := module/inc/x86_64_mlnx_msn2010 module/src +include $(BUILDER)/auto.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/x86_64_mlnx_msn2010.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/x86_64_mlnx_msn2010.yml new file mode 100644 index 00000000..f3a99008 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/auto/x86_64_mlnx_msn2010.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_mlnx_msn2010 Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: x86_64_mlnx_msn2010_CONFIG_PORTING_STDLIB +- X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_MLNX_MSN2010_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_mlnx_msn2010_config + + portingmacro: + x86_64_mlnx_msn2010: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010.x b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010.x new file mode 100644 index 00000000..ea769079 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010.x @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_config.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_config.h new file mode 100644 index 00000000..61007f5f --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_mlnx_msn2010 Configuration Header + * + * @addtogroup x86_64_mlnx_msn2010-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2010_CONFIG_H__ +#define __X86_64_MLNX_MSN2010_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_MLNX_MSN2010_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING +#define X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT +#define X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB +#define X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI +#define X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_mlnx_msn2010_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_mlnx_msn2010_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_mlnx_msn2010_config_settings table. */ +extern x86_64_mlnx_msn2010_config_settings_t x86_64_mlnx_msn2010_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_mlnx_msn2010_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_mlnx_msn2010_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_mlnx_msn2010_porting.h" + +#endif /* __X86_64_MLNX_MSN2010_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_dox.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_dox.h new file mode 100644 index 00000000..a977d260 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_mlnx_msn2010 Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2010_DOX_H__ +#define __X86_64_MLNX_MSN2010_DOX_H__ + +/** + * @defgroup x86_64_mlnx_msn2010 x86_64_mlnx_msn2010 - x86_64_mlnx_msn2010 Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_mlnx_msn2010-x86_64_mlnx_msn2010 Public Interface + * @defgroup x86_64_mlnx_msn2010-config Compile Time Configuration + * @defgroup x86_64_mlnx_msn2010-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_MLNX_MSN2010_DOX_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_porting.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_porting.h new file mode 100644 index 00000000..54d120e7 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/inc/x86_64_mlnx_msn2010/x86_64_mlnx_msn2010_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_mlnx_msn2010 Porting Macros. + * + * @addtogroup x86_64_mlnx_msn2010-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2010_PORTING_H__ +#define __X86_64_MLNX_MSN2010_PORTING_H__ + + +/* */ +#if X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_MLNX_MSN2010_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_MLNX_MSN2010_MALLOC GLOBAL_MALLOC + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_MALLOC malloc + #else + #error The macro X86_64_MLNX_MSN2010_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_FREE + #if defined(GLOBAL_FREE) + #define X86_64_MLNX_MSN2010_FREE GLOBAL_FREE + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_FREE free + #else + #error The macro X86_64_MLNX_MSN2010_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_MLNX_MSN2010_MEMSET GLOBAL_MEMSET + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_MEMSET memset + #else + #error The macro X86_64_MLNX_MSN2010_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_MLNX_MSN2010_MEMCPY GLOBAL_MEMCPY + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_MEMCPY memcpy + #else + #error The macro X86_64_MLNX_MSN2010_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_MLNX_MSN2010_STRNCPY GLOBAL_STRNCPY + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_STRNCPY strncpy + #else + #error The macro X86_64_MLNX_MSN2010_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_MLNX_MSN2010_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_VSNPRINTF vsnprintf + #else + #error The macro X86_64_MLNX_MSN2010_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_MLNX_MSN2010_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_SNPRINTF snprintf + #else + #error The macro X86_64_MLNX_MSN2010_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_MLNX_MSN2010_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_MLNX_MSN2010_STRLEN GLOBAL_STRLEN + #elif X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB == 1 + #define X86_64_MLNX_MSN2010_STRLEN strlen + #else + #error The macro X86_64_MLNX_MSN2010_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_MLNX_MSN2010_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/make.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..e46c3c7f --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_mlnx_msn2010_INCLUDES := -I $(THIS_DIR)inc +x86_64_mlnx_msn2010_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_mlnx_msn2010_DEPENDMODULE_ENTRIES := init:x86_64_mlnx_msn2010 ucli:x86_64_mlnx_msn2010 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..067dfc12 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/Makefile @@ -0,0 +1,8 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_mlnx_msn2010_ucli.c diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..a4924279 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/fani.c @@ -0,0 +1,75 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" +#include "mlnx_common/mlnx_common.h" + +#define FAN_RESERVED 0 +#define FAN_1_ON_MAIN_BOARD 1 +#define FAN_2_ON_MAIN_BOARD 2 +#define FAN_3_ON_MAIN_BOARD 3 +#define FAN_4_ON_MAIN_BOARD 4 +/* No PSU with fan, set to bigger then last fan id*/ +#define FIRST_PSU_FAN_ID 5 + +static int min_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; +static int max_fan_speed[CHASSIS_FAN_COUNT+1] = {0}; + +fan_path_T fan_path[] = /* must map with onlp_fan_id */ +{ + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD), + MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD) +}; + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4) +}; + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->min_fan_speed = min_fan_speed; + mlnx_platform_info->max_fan_speed = max_fan_speed; + mlnx_platform_info->finfo = finfo; + mlnx_platform_info->fan_fnames = fan_path; + mlnx_platform_info->fan_type = FAN_TYPE_NO_EEPROM; + mlnx_platform_info->first_psu_fan_id = FIRST_PSU_FAN_ID; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..f3e77d8f --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,93 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include + +static char* file_names[] = /* must map with onlp_led_id */ +{ + "reserved", + "status", + "fan", + "psu1", + "psu2", + "uid" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYSTEM), "Chassis LED 1 (SYSTEM LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 2 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 3 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | + ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_UID), "Chassis LED 5 (UID LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING | + ONLP_LED_CAPS_AUTO, + } +}; + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->linfo = linfo; + mlnx_platform_info->led_fnames = file_names; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/make.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..c0e5304a --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_mlnx_msn2010 +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..28bcdca4 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,37 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_mlnx_msn2010_log.h" + +#define CHASSIS_LED_COUNT 5 +#define CHASSIS_PSU_COUNT 2 +#define CHASSIS_FAN_COUNT 4 +#define CHASSIS_THERMAL_COUNT 7 +#define SFP_PORT_COUNT 22 +#define CPLD_COUNT 2 + +#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/sysi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..006f1d46 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,65 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_mlnx_msn2010_int.h" +#include "x86_64_mlnx_msn2010_log.h" +#include + +#define ONL_PLATFORM_NAME "x86-64-mlnx-msn2010-r0" + +#define COMMAND_OUTPUT_BUFFER 256 + +int mc_get_platform_info(mlnx_platform_info_t* mlnx_platform) +{ + strncpy(mlnx_platform->onl_platform_name, ONL_PLATFORM_NAME, PLATFORM_NAME_MAX_LEN); + mlnx_platform->sfp_num = SFP_PORT_COUNT; + mlnx_platform->led_num = CHASSIS_LED_COUNT; + mlnx_platform->psu_num = CHASSIS_PSU_COUNT; + mlnx_platform->fan_num = CHASSIS_FAN_COUNT; + mlnx_platform->thermal_num = CHASSIS_THERMAL_COUNT; + mlnx_platform->cpld_num = CPLD_COUNT; + mlnx_platform->psu_fixed = true; + mlnx_platform->fan_fixed = true; + mlnx_platform->psu_type = PSU_TYPE_1; + mlnx_platform->led_type = LED_TYPE_1; + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_init(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..db4d6393 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,101 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "mlnx_common/mlnx_common.h" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE_0, + THERMAL_CPU_CORE_1, + THERMAL_CPU_CORE_2, + THERMAL_CPU_CORE_3, + THERMAL_ASIC, + THERMAL_BOARD_AMB, + THERMAL_PORT +}; + +static char* thermal_fnames[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "cpu_core0", + "cpu_core1", + "cpu_core2", + "cpu_core3", + "asic", + "board_amb", + "port_amb" +}; + +/* Static values */ +static onlp_thermal_info_t tinfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_1), "CPU Core 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_ASIC), "Asic Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_BOARD_AMB), "Board AMB Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_PORT), "Port AMB Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->tinfo=tinfo; + mlnx_platform_info->thermal_fnames=thermal_fnames; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_config.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_config.c new file mode 100644 index 00000000..b82b5f18 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(_x) #_x +#define __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(_x) __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(_x) +x86_64_mlnx_msn2010_config_settings_t x86_64_mlnx_msn2010_config_settings[] = +{ +#ifdef X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_INCLUDE_LOGGING(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_PORTING_STDLIB(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_INCLUDE_UCLI(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME(X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE(X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_MLNX_MSN2010_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_VALUE +#undef __X86_64_MLNX_MSN2010_CONFIG_STRINGIFY_NAME + +const char* +x86_64_mlnx_msn2010_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_mlnx_msn2010_config_settings[i].name; i++) { + if(strcmp(x86_64_mlnx_msn2010_config_settings[i].name, setting)) { + return x86_64_mlnx_msn2010_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_mlnx_msn2010_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_mlnx_msn2010_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_mlnx_msn2010_config_settings[i].name, x86_64_mlnx_msn2010_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_enums.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_enums.c new file mode 100644 index 00000000..dff01184 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_enums.c @@ -0,0 +1,9 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_int.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_int.h new file mode 100644 index 00000000..26f652c2 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_int.h @@ -0,0 +1,13 @@ +/**************************************************************************//** + * + * x86_64_mlnx_msn + Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2010_INT_H__ +#define __X86_64_MLNX_MSN2010_INT_H__ + +#include + + +#endif /* __X86_64_MLNX_MSN2010_INT_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.c new file mode 100644 index 00000000..322b19a6 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.c @@ -0,0 +1,17 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_mlnx_msn2010_log.h" +/* + * x86_64_mlnx_msn2010 log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_MLNX_MSN2010_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_MLNX_MSN2010_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_MLNX_MSN2010_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.h b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.h new file mode 100644 index 00000000..47588686 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_MLNX_MSN2010_LOG_H__ +#define __X86_64_MLNX_MSN2010_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_mlnx_msn2010 +#include + +#endif /* __X86_64_MLNX_MSN2010_LOG_H__ */ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_module.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_module.c new file mode 100644 index 00000000..8a514e22 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_mlnx_msn2010_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_mlnx_msn2010_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_mlnx_msn2010_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_ucli.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_ucli.c new file mode 100644 index 00000000..027ec2e3 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/x86_64_mlnx_msn2010_ucli.c @@ -0,0 +1,49 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_mlnx_msn2010_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_mlnx_msn2010_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_mlnx_msn2010) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_mlnx_msn2010_ucli_module__ = + { + "x86_64_mlnx_msn2010_ucli", + NULL, + x86_64_mlnx_msn2010_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_mlnx_msn2010_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_mlnx_msn2010_ucli_module__); + n = ucli_node_create("x86_64_mlnx_msn2010", NULL, &x86_64_mlnx_msn2010_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_mlnx_msn2010")); + return n; +} + +#else +void* +x86_64_mlnx_msn2010_ucli_node_create(void) +{ + return NULL; +} +#endif diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/x86_64_mlnx_msn2010.mk b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/x86_64_mlnx_msn2010.mk new file mode 100644 index 00000000..0e5e04a7 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/x86_64_mlnx_msn2010.mk @@ -0,0 +1,12 @@ + +############################################################################### +# +# Inclusive Makefile for the x86_64_mlnx_msn2010 module. +# +# Autogenerated 2015-12-23 23:45:56.754200 +# +############################################################################### +x86_64_mlnx_msn2010_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(x86_64_mlnx_msn2010_BASEDIR)/module/make.mk +include $(x86_64_mlnx_msn2010_BASEDIR)/module/auto/make.mk +include $(x86_64_mlnx_msn2010_BASEDIR)/module/src/make.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/Makefile b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/PKG.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/PKG.yml new file mode 100644 index 00000000..e4ba4962 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=mellanox BASENAME=x86-64-mlnx-msn2010 REVISION=r0 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/lib/x86-64-mlnx-msn2010-r0.yml b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/lib/x86-64-mlnx-msn2010-r0.yml new file mode 100644 index 00000000..0e6e343a --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/lib/x86-64-mlnx-msn2010-r0.yml @@ -0,0 +1,36 @@ +--- + +###################################################################### +# +# platform-config for Mellanox msn2010 +# +###################################################################### + +x86-64-mlnx-msn2010-r0: + + grub: + + serial: >- + --unit=0 + --speed=115200 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-4-9 + + args: >- + nopat + console=ttyS0,115200n8 + rd_NO_MD + rd_NO_LUKS + acpi_enforce_resources=lax + acpi=noirq + i2c-ismt.enable=0 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/python/x86_64_mlnx_msn2010_r0/__init__.py b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/python/x86_64_mlnx_msn2010_r0/__init__.py new file mode 100644 index 00000000..e5a57671 --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/platform-config/r0/src/python/x86_64_mlnx_msn2010_r0/__init__.py @@ -0,0 +1,17 @@ +from onl.platform.base import * +from onl.platform.mellanox import * + +class OnlPlatform_x86_64_mlnx_msn2010_r0(OnlPlatformMellanox, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-mlnx-msn2010-r0' + MODEL="SN2010" + SYS_OBJECT_ID=".2010.1" + + def baseconfig(self): + # load modules + import os + # necessary if there are issues with the install + # os.system("/usr/bin/apt-get install") + os.system("/etc/mlnx/mlnx-hw-management start") + self.syseeprom_export(); + return True From 23333f6692ed3a37804cdee33cb42e3fd06d049d Mon Sep 17 00:00:00 2001 From: roy_lee Date: Tue, 27 Mar 2018 09:12:35 +0800 Subject: [PATCH 198/244] Change console to be ttyS0. Fix compilation error on sfpi.c. Signed-off-by: roy_lee --- .../onlp/builds/src/module/src/sfpi.c | 2 +- .../r0/src/lib/x86-64-accton-as7326-56x-r0.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c index a73e8602..2481b5d7 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c @@ -29,7 +29,7 @@ #include "x86_64_accton_as7326_56x_int.h" #include "x86_64_accton_as7326_56x_log.h" -#define PORT_BUS_INDEX(port) sfp_map(port) +#define PORT_BUS_INDEX(port) sfp_map[port] #define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" #define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml index b1927c8e..1ef9c173 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/lib/x86-64-accton-as7326-56x-r0.yml @@ -11,7 +11,7 @@ x86-64-accton-as7326-56x-r0: grub: serial: >- - --port=0x2f8 + --port=0x3f8 --speed=115200 --word=8 --parity=no @@ -22,9 +22,9 @@ x86-64-accton-as7326-56x-r0: args: >- nopat - console=ttyS1,115200n8 + console=ttyS0,115200n8 - ##network + ##network: ## interfaces: ## ma1: ## name: ~ From 2ce2ba37cc92c37e4b96a8cbdbc0621445688469 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Tue, 27 Mar 2018 14:29:23 +0800 Subject: [PATCH 199/244] 1. change i2c bus index for 4 SFP+'s eeprom. 2. Correct IDEEPROM and PSU sysfs path. 3. change to OnlPlatformPortConfig_48x25_8x100. 4. fix port 57&58's present bit. Signed-off-by: roy_lee --- .../builds/x86-64-accton-as7326-56x-cpld.c | 4 ++-- .../onlp/builds/src/module/src/platform_lib.h | 6 +++--- .../onlp/builds/src/module/src/psui.c | 1 - .../onlp/builds/src/module/src/sfpi.c | 4 ++-- .../x86_64_accton_as7326_56x_r0/__init__.py | 16 ++++++++-------- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c index 2274c4a9..ac018c04 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c @@ -671,7 +671,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, break; case MODULE_PRESENT_57 ... MODULE_PRESENT_58: reg = 0x12; - mask = 0x1 << (( MODULE_PRESENT_58 - attr->index)+2); + mask = 0x1 << ((attr->index - MODULE_PRESENT_57)+2); break; case MODULE_PRESENT_49 ... MODULE_PRESENT_56: /*QSFP*/ reg = 0x13 ; @@ -717,7 +717,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return 0; } - if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_56) { + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_58) { revert = 1; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h index d54311e0..e5ff56b4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.h @@ -46,8 +46,8 @@ #define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node #define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node -#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/17-0051/" -#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/13-0053/" +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/17-0051/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/13-0053/" #define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node #define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node @@ -55,7 +55,7 @@ #define FAN_BOARD_PATH "/sys/bus/i2c/devices/11-0066/" #define FAN_NODE(node) FAN_BOARD_PATH#node -#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/0-0056/eeprom" +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom" int onlp_file_write_integer(char *filename, int value); int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c index 77074bb8..66b343b8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/psui.c @@ -55,7 +55,6 @@ psu_status_info_get(int id, char *node, int *value) else if (PSU2_ID == id) { sprintf(path, "%s%s", PSU2_AC_HWMON_PREFIX, node); } - if (onlp_file_read_int(value, path) < 0) { AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); return ONLP_STATUS_E_INTERNAL; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c index 2481b5d7..4aead529 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c @@ -42,8 +42,8 @@ const int sfp_map[] = { 42,41,44,43,47,45,46,50, - 48,49,51,52,53,56,55,54, - 58,57,59,60,61,63,62,64, + 48,49,52,51,53,56,55,54, + 58,57,60,59,61,63,62,64, 66,68,65,67,69,71,72,70, 74,73,76,75,77,79,78,80, 81,82,84,85,83,87,88,86, /*port 41~48*/ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py index 1efb26e0..24e9a914 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py @@ -2,7 +2,7 @@ from onl.platform.base import * from onl.platform.accton import * class OnlPlatform_x86_64_accton_as7326_56x_r0(OnlPlatformAccton, - OnlPlatformPortConfig_48x25_6x100): + OnlPlatformPortConfig_48x25_8x100): PLATFORM='x86-64-accton-as7326-56x-r0' MODEL="AS7326-56X" @@ -66,28 +66,28 @@ class OnlPlatform_x86_64_accton_as7326_56x_r0(OnlPlatformAccton, sfp_map = [ 42,41,44,43,47,45,46,50, - 48,49,51,52,53,56,55,54, - 58,57,59,60,61,63,62,64, + 48,49,52,51,53,56,55,54, + 58,57,60,59,61,63,62,64, 66,68,65,67,69,71,72,70, 74,73,76,75,77,79,78,80, 81,82,84,85,83,87,88,86, #port 41~48 25,26,27,28,29,30,31,32, #port 49~56 QSFP 22,23] #port 57~58 SFP+ from CPU NIF. - # initialize SFP+ port 1~54 and 57+58. + # initialize SFP+ port 1~56 and 57+58. for port in range(1, 49): bus = sfp_map[port-1] self.new_i2c_device('optoe2', 0x50, bus) - self.new_i2c_device('optoe2', 0x50, sfp[56]) - self.new_i2c_device('optoe2', 0x50, sfp[57]) + self.new_i2c_device('optoe2', 0x50, sfp_map[57-1]) + self.new_i2c_device('optoe2', 0x50, sfp_map[58-1]) # initialize QSFP port 49~56 - for port in range(49, 58): + for port in range(49, 57): bus = sfp_map[port-1] self.new_i2c_device('optoe1', 0x50, bus) - for port in range(1, len(sfp)+1): + for port in range(1, len(sfp_map)): bus = sfp_map[port-1] subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, bus), shell=True) From 15d3c14c92f12dfaa4a7a57fdf58f8dc2ca1a15e Mon Sep 17 00:00:00 2001 From: Michael Shych Date: Tue, 27 Mar 2018 20:22:45 +0000 Subject: [PATCH 200/244] 4 new kernel patches for Mellanox drivers. 1. Patch 0009... introduces new module mlxreg-io, which exposes the registers of the programmable devices, equipped on Melanox systems to sysfs. These are the registers, which are used for system resets operation, system reset causes monitoring, select operation and version info. 2. Patch 0010... adds verification for low aggregation register mask offset. Only non-zero offset is considered as valid. 3. Patch 0011... adds new OEM system types to mlx-platform; fix for interrupt burst; support for dynamic base i2c bus number allocation. 4. Patch 0012... adds support for extended length of read and write transactions with new CPLD logic; adds support for extended length of read and write transactions. Signed-off-by: Michael Shych --- .../configs/x86_64-all/x86_64-all.config | 1 + ...x-introduce-mlxreg-io-driver-and-add.patch | 685 ++++++++++++++++++ ...x-mlxreg-hotplug-driver-add-check-fo.patch | 53 ++ ...atform-x86-mlx-platform-new-features.patch | 472 ++++++++++++ ...sses-Add-capabilities-to-i2c-mlxcpld.patch | 199 +++++ .../base/any/kernels/4.9-lts/patches/series | 4 + 6 files changed, 1414 insertions(+) create mode 100644 packages/base/any/kernels/4.9-lts/patches/0009-platform-mellonox-introduce-mlxreg-io-driver-and-add.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0010-platform-mellanox-mlxreg-hotplug-driver-add-check-fo.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0011-platform-x86-mlx-platform-new-features.patch create mode 100644 packages/base/any/kernels/4.9-lts/patches/0012-i2c-busses-Add-capabilities-to-i2c-mlxcpld.patch diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index b25358ec..90778fc2 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -3526,6 +3526,7 @@ CONFIG_MLX_PLATFORM=y # CONFIG_CHROME_PLATFORMS is not set CONFIG_MELLANOX_PLATFORM=y CONFIG_MLXREG_HOTPLUG=y +CONFIG_MLXREG_IO=y # # Hardware Spinlock drivers diff --git a/packages/base/any/kernels/4.9-lts/patches/0009-platform-mellonox-introduce-mlxreg-io-driver-and-add.patch b/packages/base/any/kernels/4.9-lts/patches/0009-platform-mellonox-introduce-mlxreg-io-driver-and-add.patch new file mode 100644 index 00000000..db22b149 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0009-platform-mellonox-introduce-mlxreg-io-driver-and-add.patch @@ -0,0 +1,685 @@ +From 2c7476ab57dd42d8cba6c417ff32a77252964858 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Thu, 16 Nov 2017 17:22:56 +0000 +Subject: [v4.9 backport 38/38] platform: mellonox: introduce mlxreg-io driver + and add driver activation to mlx-platform + +Patch introduces new module mlxreg-io, which exposes the registers of the +programmable devices, equipped on Melanox systems to sysfs. These are the +registers, which are used for system resets operation, system reset causes +monitoring, select operation and version info. + +Signed-off-by: Vadim Pasternak +--- + drivers/leds/leds-mlxreg.c | 10 +- + drivers/platform/mellanox/Kconfig | 11 ++ + drivers/platform/mellanox/Makefile | 1 + + drivers/platform/mellanox/mlxreg-io.c | 211 ++++++++++++++++++++++++++++++++++ + drivers/platform/x86/mlx-platform.c | 193 +++++++++++++++++++++++++++++-- + include/linux/platform_data/mlxreg.h | 6 +- + 6 files changed, 418 insertions(+), 14 deletions(-) + create mode 100644 drivers/platform/mellanox/mlxreg-io.c + +diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c +index a932f20..036c214 100644 +--- a/drivers/leds/leds-mlxreg.c ++++ b/drivers/leds/leds-mlxreg.c +@@ -79,7 +79,7 @@ struct mlxreg_led_data { + */ + struct mlxreg_led_priv_data { + struct platform_device *pdev; +- struct mlxreg_core_led_platform_data *pdata; ++ struct mlxreg_core_platform_data *pdata; + struct mutex access_lock; /* protect IO operations */ + }; + +@@ -87,7 +87,7 @@ static int + mlxreg_led_store_hw(struct mlxreg_led_data *led_data, u8 vset) + { + struct mlxreg_led_priv_data *priv = led_data->data_parent; +- struct mlxreg_core_led_platform_data *led_pdata = priv->pdata; ++ struct mlxreg_core_platform_data *led_pdata = priv->pdata; + struct mlxreg_core_data *data = led_data->data; + u32 regval; + u32 nib; +@@ -125,7 +125,7 @@ static enum led_brightness + mlxreg_led_get_hw(struct mlxreg_led_data *led_data) + { + struct mlxreg_led_priv_data *priv = led_data->data_parent; +- struct mlxreg_core_led_platform_data *led_pdata = priv->pdata; ++ struct mlxreg_core_platform_data *led_pdata = priv->pdata; + struct mlxreg_core_data *data = led_data->data; + u32 regval; + int ret; +@@ -212,7 +212,7 @@ mlxreg_led_blink_set(struct led_classdev *cled, unsigned long *delay_on, + + static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) + { +- struct mlxreg_core_led_platform_data *led_pdata = priv->pdata; ++ struct mlxreg_core_platform_data *led_pdata = priv->pdata; + struct mlxreg_core_data *data = led_pdata->data; + struct mlxreg_led_data *led_data; + struct led_classdev *led_cdev; +@@ -266,7 +266,7 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) + + static int mlxreg_led_probe(struct platform_device *pdev) + { +- struct mlxreg_core_led_platform_data *led_pdata; ++ struct mlxreg_core_platform_data *led_pdata; + struct mlxreg_led_priv_data *priv; + + led_pdata = dev_get_platdata(&pdev->dev); +diff --git a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig +index b197cc1..5c6dc29 100644 +--- a/drivers/platform/mellanox/Kconfig ++++ b/drivers/platform/mellanox/Kconfig +@@ -22,4 +22,15 @@ config MLXREG_HOTPLUG + This driver handles hot-plug events for the power suppliers, power + cables and fans on the wide range Mellanox IB and Ethernet systems. + ++config MLXREG_IO ++ tristate "Mellanox platform register driver support" ++ depends on REGMAP ++ depends on HWMON ++ ---help--- ++ This driver allows access to Mellanox programmable device register ++ space trough sysfs interface. The set of registers for sysfs access ++ are defined per system type bases and includes the registers related ++ to system resets operation, system reset causes monitoring and some ++ kinds of mux selection. ++ + endif # MELLANOX_PLATFORM +diff --git a/drivers/platform/mellanox/Makefile b/drivers/platform/mellanox/Makefile +index f58d089..b9a2692 100644 +--- a/drivers/platform/mellanox/Makefile ++++ b/drivers/platform/mellanox/Makefile +@@ -1 +1,2 @@ + obj-$(CONFIG_MLXREG_HOTPLUG) += mlxreg-hotplug.o ++obj-$(CONFIG_MLXREG_IO) += mlxreg-io.o +diff --git a/drivers/platform/mellanox/mlxreg-io.c b/drivers/platform/mellanox/mlxreg-io.c +new file mode 100644 +index 0000000..f7434ca +--- /dev/null ++++ b/drivers/platform/mellanox/mlxreg-io.c +@@ -0,0 +1,211 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Attribute parameters. */ ++#define MLXREG_IO_ATT_SIZE 10 ++#define MLXREG_IO_ATT_NUM 48 ++ ++/** ++ * struct mlxreg_io_priv_data - driver's private data: ++ * ++ * @pdev: platform device; ++ * @pdata: platform data; ++ * @hwmon: hwmon device; ++ * @mlxreg_io_attr: sysfs attributes array; ++ * @mlxreg_io_dev_attr: sysfs sensor device attribute array; ++ * @group: sysfs attribute group; ++ * @groups: list of sysfs attribute group for hwmon registration; ++ */ ++struct mlxreg_io_priv_data { ++ struct platform_device *pdev; ++ struct mlxreg_core_platform_data *pdata; ++ struct device *hwmon; ++ struct attribute *mlxreg_io_attr[MLXREG_IO_ATT_NUM + 1]; ++ struct sensor_device_attribute mlxreg_io_dev_attr[MLXREG_IO_ATT_NUM]; ++ struct attribute_group group; ++ const struct attribute_group *groups[2]; ++}; ++ ++static ssize_t ++mlxreg_io_attr_show(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ struct mlxreg_io_priv_data *priv = dev_get_drvdata(dev); ++ int index = to_sensor_dev_attr(attr)->index; ++ struct mlxreg_core_data *data = priv->pdata->data + index; ++ u32 regval = 0; ++ int ret; ++ ++ ret = regmap_read(priv->pdata->regmap, data->reg, ®val); ++ if (ret) ++ goto access_error; ++ ++ if (!data->bit) ++ regval = !!(regval & ~data->mask); ++ ++ return sprintf(buf, "%u\n", regval); ++ ++access_error: ++ return ret; ++} ++ ++static ssize_t ++mlxreg_io_attr_store(struct device *dev, struct device_attribute *attr, ++ const char *buf, size_t len) ++{ ++ struct mlxreg_io_priv_data *priv = dev_get_drvdata(dev); ++ int index = to_sensor_dev_attr(attr)->index; ++ struct mlxreg_core_data *data = priv->pdata->data + index; ++ u32 val, regval; ++ int ret; ++ ++ ret = kstrtou32(buf, MLXREG_IO_ATT_SIZE, &val); ++ if (ret) ++ return ret; ++ ++ ret = regmap_read(priv->pdata->regmap, data->reg, ®val); ++ if (ret) ++ goto access_error; ++ ++ regval &= data->mask; ++ ++ val = !!val; ++ if (val) ++ regval |= ~data->mask; ++ else ++ regval &= data->mask; ++ ++ ret = regmap_write(priv->pdata->regmap, data->reg, regval); ++ if (ret) ++ goto access_error; ++ ++ return len; ++ ++access_error: ++ dev_err(&priv->pdev->dev, "Bus access error\n"); ++ return ret; ++} ++ ++static int mlxreg_io_attr_init(struct mlxreg_io_priv_data *priv) ++{ ++ int i; ++ ++ priv->group.attrs = devm_kzalloc(&priv->pdev->dev, ++ priv->pdata->counter * ++ sizeof(struct attribute *), ++ GFP_KERNEL); ++ if (!priv->group.attrs) ++ return -ENOMEM; ++ ++ for (i = 0; i < priv->pdata->counter; i++) { ++ priv->mlxreg_io_attr[i] = ++ &priv->mlxreg_io_dev_attr[i].dev_attr.attr; ++ ++ /* Set attribute name as a label. */ ++ priv->mlxreg_io_attr[i]->name = ++ devm_kasprintf(&priv->pdev->dev, GFP_KERNEL, ++ priv->pdata->data[i].label); ++ ++ if (!priv->mlxreg_io_attr[i]->name) { ++ dev_err(&priv->pdev->dev, "Memory allocation failed for sysfs attribute %d.\n", ++ i + 1); ++ return -ENOMEM; ++ } ++ ++ priv->mlxreg_io_dev_attr[i].dev_attr.attr.mode = ++ priv->pdata->data[i].mode; ++ switch (priv->pdata->data[i].mode) { ++ case 0200: ++ priv->mlxreg_io_dev_attr[i].dev_attr.store = ++ mlxreg_io_attr_store; ++ break; ++ ++ case 0444: ++ priv->mlxreg_io_dev_attr[i].dev_attr.show = ++ mlxreg_io_attr_show; ++ break; ++ ++ case 0644: ++ priv->mlxreg_io_dev_attr[i].dev_attr.show = ++ mlxreg_io_attr_show; ++ priv->mlxreg_io_dev_attr[i].dev_attr.store = ++ mlxreg_io_attr_store; ++ break; ++ ++ default: ++ dev_err(&priv->pdev->dev, "Bad access mode %u for attribute %s.\n", ++ priv->pdata->data[i].mode, ++ priv->mlxreg_io_attr[i]->name); ++ return -EINVAL; ++ } ++ ++ priv->mlxreg_io_dev_attr[i].dev_attr.attr.name = ++ priv->mlxreg_io_attr[i]->name; ++ priv->mlxreg_io_dev_attr[i].index = i; ++ sysfs_attr_init(&priv->mlxreg_io_dev_attr[i].dev_attr.attr); ++ } ++ ++ priv->group.attrs = priv->mlxreg_io_attr; ++ priv->groups[0] = &priv->group; ++ priv->groups[1] = NULL; ++ ++ return 0; ++} ++ ++static int mlxreg_io_probe(struct platform_device *pdev) ++{ ++ struct mlxreg_io_priv_data *priv; ++ int err; ++ ++ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ priv->pdata = dev_get_platdata(&pdev->dev); ++ if (!priv->pdata) { ++ dev_err(&pdev->dev, "Failed to get platform data.\n"); ++ return -EINVAL; ++ } ++ ++ priv->pdev = pdev; ++ ++ err = mlxreg_io_attr_init(priv); ++ if (err) { ++ dev_err(&priv->pdev->dev, "Failed to allocate attributes: %d\n", ++ err); ++ return err; ++ } ++ ++ priv->hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, ++ "mlxreg_io", priv, priv->groups); ++ if (IS_ERR(priv->hwmon)) { ++ dev_err(&pdev->dev, "Failed to register hwmon device %ld\n", ++ PTR_ERR(priv->hwmon)); ++ return PTR_ERR(priv->hwmon); ++ } ++ ++ dev_set_drvdata(&pdev->dev, priv); ++ ++ return 0; ++} ++ ++static struct platform_driver mlxreg_io_driver = { ++ .driver = { ++ .name = "mlxreg-io", ++ }, ++ .probe = mlxreg_io_probe, ++}; ++ ++module_platform_driver(mlxreg_io_driver); ++ ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox regmap I/O access driver"); ++MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_ALIAS("platform:mlxreg-io"); +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +index 49721c2..61cbe35 100644 +--- a/drivers/platform/x86/mlx-platform.c ++++ b/drivers/platform/x86/mlx-platform.c +@@ -47,16 +47,31 @@ + /* LPC bus IO offsets */ + #define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR 0x2000 + #define MLXPLAT_CPLD_LPC_REG_BASE_ADRR 0x2500 ++#define MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF 0x00 ++#define MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF 0x01 ++#define MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF 0x1d + #define MLXPLAT_CPLD_LPC_REG_LED1_OFF 0x20 + #define MLXPLAT_CPLD_LPC_REG_LED2_OFF 0x21 + #define MLXPLAT_CPLD_LPC_REG_LED3_OFF 0x22 + #define MLXPLAT_CPLD_LPC_REG_LED4_OFF 0x23 + #define MLXPLAT_CPLD_LPC_REG_LED5_OFF 0x24 ++#define MLXPLAT_CPLD_LPC_REG_GP1_OFF 0x30 ++#define MLXPLAT_CPLD_LPC_REG_WP1_OFF 0x31 ++#define MLXPLAT_CPLD_LPC_REG_GP2_OFF 0x32 ++#define MLXPLAT_CPLD_LPC_REG_WP2_OFF 0x33 + #define MLXPLAT_CPLD_LPC_REG_AGGR_OFF 0x3a ++#define MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF 0x3b + #define MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF 0x40 ++#define MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF 0x41 + #define MLXPLAT_CPLD_LPC_REG_PSU_OFF 0x58 ++#define MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF 0x59 ++#define MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF 0x5a + #define MLXPLAT_CPLD_LPC_REG_PWR_OFF 0x64 ++#define MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF 0x65 ++#define MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF 0x66 + #define MLXPLAT_CPLD_LPC_REG_FAN_OFF 0x88 ++#define MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF 0x89 ++#define MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF 0x8a + #define MLXPLAT_CPLD_LPC_IO_RANGE 0x100 + #define MLXPLAT_CPLD_LPC_I2C_CH1_OFF 0xdb + #define MLXPLAT_CPLD_LPC_I2C_CH2_OFF 0xda +@@ -100,12 +115,14 @@ + * @pdev_mux - array of mux platform devices + * @pdev_hotplug - hotplug platform devices + * @pdev_led - led platform devices ++ * @pdev_io_regs - register access platform devices + */ + struct mlxplat_priv { + struct platform_device *pdev_i2c; + struct platform_device *pdev_mux[MLXPLAT_CPLD_LPC_MUX_DEVS]; + struct platform_device *pdev_hotplug; + struct platform_device *pdev_led; ++ struct platform_device *pdev_io_regs; + }; + + /* Regions for LPC I2C controller and LPC base register space */ +@@ -643,7 +660,7 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = { + }, + }; + +-static struct mlxreg_core_led_platform_data mlxplat_default_led_data = { ++static struct mlxreg_core_platform_data mlxplat_default_led_data = { + .data = mlxplat_mlxcpld_default_led_data, + .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_led_data), + }; +@@ -697,7 +714,7 @@ static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_led_data[] = { + }, + }; + +-static struct mlxreg_core_led_platform_data mlxplat_msn21xx_led_data = { ++static struct mlxreg_core_platform_data mlxplat_msn21xx_led_data = { + .data = mlxplat_mlxcpld_msn21xx_led_data, + .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_led_data), + }; +@@ -786,11 +803,105 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_led_data[] = { + }, + }; + +-static struct mlxreg_core_led_platform_data mlxplat_default_ng_led_data = { ++static struct mlxreg_core_platform_data mlxplat_default_ng_led_data = { + .data = mlxplat_mlxcpld_default_ng_led_data, + .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_led_data), + }; + ++static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg) ++{ ++ switch (reg) { ++ case MLXPLAT_CPLD_LPC_REG_LED1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED3_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED4_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED5_OFF: ++ case MLXPLAT_CPLD_LPC_REG_GP1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_WP1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_GP2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_WP2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF: ++ return true; ++ } ++ return false; ++} ++ ++static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg) ++{ ++ switch (reg) { ++ case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF: ++ case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF: ++ case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED3_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED4_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED5_OFF: ++ case MLXPLAT_CPLD_LPC_REG_GP1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_WP1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_GP2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_WP2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF: ++ return true; ++ } ++ return false; ++} ++ ++static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg) ++{ ++ switch (reg) { ++ case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF: ++ case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF: ++ case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED3_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED4_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED5_OFF: ++ case MLXPLAT_CPLD_LPC_REG_GP1_OFF: ++ case MLXPLAT_CPLD_LPC_REG_GP2_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF: ++ case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF: ++ return true; ++ } ++ return false; ++} ++ ++static const struct reg_default mlxplat_mlxcpld_regmap_default[] = { ++ { MLXPLAT_CPLD_LPC_REG_WP1_OFF, 0x00 }, ++ { MLXPLAT_CPLD_LPC_REG_WP2_OFF, 0x00 }, ++}; ++ + static int + mlxplat_mlxcpld_reg_read(void *context, unsigned int reg, unsigned int *val) + { +@@ -809,6 +920,12 @@ const struct regmap_config mlxplat_mlxcpld_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 255, ++ .cache_type = REGCACHE_FLAT, ++ .writeable_reg = mlxplat_mlxcpld_writeable_reg, ++ .readable_reg = mlxplat_mlxcpld_readable_reg, ++ .volatile_reg = mlxplat_mlxcpld_volatile_reg, ++ .reg_defaults = mlxplat_mlxcpld_regmap_default, ++ .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_default), + .reg_read = mlxplat_mlxcpld_reg_read, + .reg_write = mlxplat_mlxcpld_reg_write, + }; +@@ -817,9 +934,38 @@ static struct resource mlxplat_mlxcpld_resources[] = { + [0] = DEFINE_RES_IRQ_NAMED(17, "mlxreg-hotplug"), + }; + +-struct platform_device *mlxplat_dev; +-struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug; +-struct mlxreg_core_led_platform_data *mlxplat_led; ++static struct mlxreg_core_data mlxplat_mlxcpld_default_regs_io_data[] = { ++ { "cpld1_version", MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF, 0x00, ++ GENMASK(7, 0), 0444 }, ++ { "cpld2_version", MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF, 0x00, ++ GENMASK(7, 0), 0444 }, ++ { "cause_long_pb", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(0), 0x00, 0444 }, ++ { "cause_short_pb", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(1), 0x00, 0444 }, ++ { "cause_pwr_aux", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(2), 0x00, 0444 }, ++ { "cause_pwr_fail", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(3), 0x00, 0444 }, ++ { "psu1_on", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(0), ++ 0x00, 0200 }, ++ { "psu2_on", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(1), ++ 0x00, 0200 }, ++ { "pwr_cycle", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(2), ++ 0x00, 0200 }, ++ { "select_iio", MLXPLAT_CPLD_LPC_REG_GP2_OFF, GENMASK(7, 0) & ~BIT(6), ++ 0x00, 0644 }, ++}; ++ ++static struct mlxreg_core_platform_data mlxplat_default_regs_io_data = { ++ .data = mlxplat_mlxcpld_default_regs_io_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_regs_io_data), ++}; ++ ++static struct platform_device *mlxplat_dev; ++static struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug; ++static struct mlxreg_core_platform_data *mlxplat_led; ++static struct mlxreg_core_platform_data *mlxplat_regs_io; + + static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) + { +@@ -832,6 +978,7 @@ static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) + } + mlxplat_hotplug = &mlxplat_mlxcpld_default_data; + mlxplat_led = &mlxplat_default_led_data; ++ mlxplat_regs_io = &mlxplat_default_regs_io_data; + + return 1; + }; +@@ -847,6 +994,7 @@ static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) + } + mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data; + mlxplat_led = &mlxplat_msn21xx_led_data; ++ mlxplat_regs_io = &mlxplat_default_regs_io_data; + + return 1; + }; +@@ -862,6 +1010,7 @@ static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi) + } + mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data; + mlxplat_led = &mlxplat_default_led_data; ++ mlxplat_regs_io = &mlxplat_default_regs_io_data; + + return 1; + }; +@@ -877,6 +1026,7 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) + } + mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data; + mlxplat_led = &mlxplat_default_ng_led_data; ++ mlxplat_regs_io = &mlxplat_default_regs_io_data; + + return 1; + }; +@@ -892,6 +1042,7 @@ static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) + } + mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data; + mlxplat_led = &mlxplat_msn21xx_led_data; ++ mlxplat_regs_io = &mlxplat_default_regs_io_data; + + return 1; + }; +@@ -974,7 +1125,7 @@ static int __init mlxplat_init(void) + { + struct mlxplat_priv *priv; + void __iomem *base; +- int i, err = 0; ++ int i, j, err = 0; + + if (!dmi_check_system(mlxplat_dmi_table)) + return -ENODEV; +@@ -1023,6 +1174,15 @@ static int __init mlxplat_init(void) + if (IS_ERR(mlxplat_hotplug->regmap)) + goto fail_platform_mux_register; + ++ /* Set default registers. */ ++ for (j = 0; j < mlxplat_mlxcpld_regmap_config.num_reg_defaults; j++) { ++ err = regmap_write(mlxplat_hotplug->regmap, ++ mlxplat_mlxcpld_regmap_default[j].reg, ++ mlxplat_mlxcpld_regmap_default[j].def); ++ if (err) ++ goto fail_platform_mux_register; ++ } ++ + priv->pdev_hotplug = platform_device_register_resndata( + &mlxplat_dev->dev, "mlxreg-hotplug", + PLATFORM_DEVID_NONE, +@@ -1044,8 +1204,26 @@ static int __init mlxplat_init(void) + goto fail_platform_hotplug_register; + } + ++ mlxplat_regs_io->regmap = mlxplat_hotplug->regmap; ++ priv->pdev_io_regs = platform_device_register_resndata( ++ &mlxplat_dev->dev, "mlxreg-io", ++ PLATFORM_DEVID_NONE, NULL, 0, ++ mlxplat_regs_io, sizeof(*mlxplat_regs_io)); ++ if (IS_ERR(priv->pdev_io_regs)) { ++ err = PTR_ERR(priv->pdev_io_regs); ++ goto fail_platform_led_register; ++ } ++ ++ /* Sync registers with hardware. */ ++ regcache_mark_dirty(mlxplat_hotplug->regmap); ++ err = regcache_sync(mlxplat_hotplug->regmap); ++ if (err) ++ goto fail_platform_led_register; ++ + return 0; + ++fail_platform_led_register: ++ platform_device_unregister(priv->pdev_led); + fail_platform_hotplug_register: + platform_device_unregister(priv->pdev_hotplug); + fail_platform_mux_register: +@@ -1064,6 +1242,7 @@ static void __exit mlxplat_exit(void) + struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev); + int i; + ++ platform_device_unregister(priv->pdev_io_regs); + platform_device_unregister(priv->pdev_led); + platform_device_unregister(priv->pdev_hotplug); + +diff --git a/include/linux/platform_data/mlxreg.h b/include/linux/platform_data/mlxreg.h +index dd471c5..c25623b 100644 +--- a/include/linux/platform_data/mlxreg.h ++++ b/include/linux/platform_data/mlxreg.h +@@ -61,6 +61,7 @@ struct mlxreg_hotplug_device { + * @label: attribute register offset; + * @reg: attribute register; + * @mask: attribute access mask; ++ * @mode: access mode; + * @bit: attribute effective bit; + * @np - pointer to node platform associated with attribute; + * @hpdev - hotplug device data; +@@ -72,6 +73,7 @@ struct mlxreg_core_data { + u32 reg; + u32 mask; + u32 bit; ++ umode_t mode; + struct device_node *np; + struct mlxreg_hotplug_device hpdev; + u8 health_cntr; +@@ -104,13 +106,13 @@ struct mlxreg_core_item { + }; + + /** +- * struct mlxreg_core_led_platform_data - led platform data: ++ * struct mlxreg_core_platform_data - platform data: + * + * @led_data: led private data; + * @regmap: register map of parent device; + * @counter: number of led instances; + */ +-struct mlxreg_core_led_platform_data { ++struct mlxreg_core_platform_data { + struct mlxreg_core_data *data; + void *regmap; + int counter; +-- +2.1.4 + diff --git a/packages/base/any/kernels/4.9-lts/patches/0010-platform-mellanox-mlxreg-hotplug-driver-add-check-fo.patch b/packages/base/any/kernels/4.9-lts/patches/0010-platform-mellanox-mlxreg-hotplug-driver-add-check-fo.patch new file mode 100644 index 00000000..ef29d134 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0010-platform-mellanox-mlxreg-hotplug-driver-add-check-fo.patch @@ -0,0 +1,53 @@ +From c794f8ffa6521c47bfbff813e7f713561d7da7bd Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Mon, 11 Dec 2017 19:02:19 +0000 +Subject: [v4.9 backport 09/29] platform/mellanox: mlxreg-hotplug driver add + check for low aggregation register mask + +It adds verification for low aggregation register mask offset. Only +non-zero offset is considered as valid. + +Signed-off-by: Vadim Pasternak +--- + drivers/platform/mellanox/mlxreg-hotplug.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c +index 94fdb6b..ba9241e 100644 +--- a/drivers/platform/mellanox/mlxreg-hotplug.c ++++ b/drivers/platform/mellanox/mlxreg-hotplug.c +@@ -550,10 +550,13 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) + goto access_error; + + /* Keep low aggregation initial status as zero and unmask events. */ +- ret = regmap_write(priv->regmap, pdata->cell_low + +- MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask_low); +- if (ret) +- goto access_error; ++ if (pdata->cell_low) { ++ ret = regmap_write(priv->regmap, pdata->cell_low + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, ++ pdata->mask_low); ++ if (ret) ++ goto access_error; ++ } + + /* Invoke work handler for initializing hot plug devices setting. */ + mlxreg_hotplug_work_handler(&priv->dwork_irq.work); +@@ -582,9 +585,10 @@ static void mlxreg_hotplug_unset_irq(struct mlxreg_hotplug_priv_data *priv) + disable_irq(priv->irq); + cancel_delayed_work_sync(&priv->dwork_irq); + +- /* Mask low aggregation event. */ +- regmap_write(priv->regmap, pdata->cell_low + +- MLXREG_HOTPLUG_AGGR_MASK_OFF, 0); ++ /* Mask low aggregation event, if defined. */ ++ if (pdata->cell_low) ++ regmap_write(priv->regmap, pdata->cell_low + ++ MLXREG_HOTPLUG_AGGR_MASK_OFF, 0); + + /* Mask aggregation event. */ + regmap_write(priv->regmap, pdata->cell + MLXREG_HOTPLUG_AGGR_MASK_OFF, +-- +2.1.4 + diff --git a/packages/base/any/kernels/4.9-lts/patches/0011-platform-x86-mlx-platform-new-features.patch b/packages/base/any/kernels/4.9-lts/patches/0011-platform-x86-mlx-platform-new-features.patch new file mode 100644 index 00000000..f2d4e116 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0011-platform-x86-mlx-platform-new-features.patch @@ -0,0 +1,472 @@ +diff --git a/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c b/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c +index 3bc6cf8..07cc7ea 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/qsfp_sysfs.c +@@ -33,6 +33,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -49,7 +50,8 @@ + #define MLXSW_QSFP_MAX_NUM 64 + #define MLXSW_QSFP_MIN_REQ_LEN 4 + #define MLXSW_QSFP_STATUS_VALID_TIME (120 * HZ) +-#define MLXSW_QSFP_MAX_CPLD_NUM 1 ++#define MLXSW_QSFP_MAX_CPLD_NUM 3 ++#define MLXSW_QSFP_MIN_CPLD_NUM 1 + + static const u8 mlxsw_qsfp_page_number[] = { 0xa0, 0x00, 0x01, 0x02, 0x03 }; + static const u16 mlxsw_qsfp_page_shift[] = { 0x00, 0x80, 0x80, 0x80, 0x80 }; +@@ -85,6 +87,8 @@ struct mlxsw_qsfp { + struct device_attribute *cpld_dev_attrs; + }; + ++static int mlxsw_qsfp_cpld_num = MLXSW_QSFP_MIN_CPLD_NUM; ++ + static int + mlxsw_qsfp_query_module_eeprom(struct mlxsw_qsfp *mlxsw_qsfp, u8 index, + loff_t off, size_t count, int page, char *buf) +@@ -210,11 +214,11 @@ mlxsw_qsfp_cpld_show(struct device *dev, struct device_attribute *attr, + u32 version, i; + int err; + +- for (i = 0; i < MLXSW_QSFP_MAX_CPLD_NUM; i++) { ++ for (i = 0; i < mlxsw_qsfp_cpld_num; i++) { + if ((mlxsw_qsfp->cpld_dev_attrs + i) == attr) + break; + } +- if (i == MLXSW_QSFP_MAX_CPLD_NUM) ++ if (i == mlxsw_qsfp_cpld_num) + return -EINVAL; + + mlxsw_reg_msci_pack(msci_pl, i); +@@ -227,6 +231,32 @@ mlxsw_qsfp_cpld_show(struct device *dev, struct device_attribute *attr, + return sprintf(buf, "%u\n", version); + } + ++static int __init mlxsw_qsfp_dmi_set_cpld_num(const struct dmi_system_id *dmi) ++{ ++ mlxsw_qsfp_cpld_num = MLXSW_QSFP_MAX_CPLD_NUM; ++ ++ return 1; ++}; ++ ++static struct dmi_system_id mlxsw_qsfp_dmi_table[] __initdata = { ++ { ++ .callback = mlxsw_qsfp_dmi_set_cpld_num, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN24"), ++ }, ++ }, ++ { ++ .callback = mlxsw_qsfp_dmi_set_cpld_num, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MSN27"), ++ }, ++ }, ++ { } ++}; ++MODULE_DEVICE_TABLE(dmi, mlxsw_qsfp_dmi_table); ++ + int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, + const struct mlxsw_bus_info *mlxsw_bus_info, + struct mlxsw_qsfp **p_qsfp) +@@ -242,6 +272,8 @@ int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, + if (!strcmp(mlxsw_bus_info->device_kind, "i2c")) + return 0; + ++ dmi_check_system(mlxsw_qsfp_dmi_table); ++ + mlxsw_qsfp = devm_kzalloc(mlxsw_bus_info->dev, sizeof(*mlxsw_qsfp), + GFP_KERNEL); + if (!mlxsw_qsfp) +@@ -285,7 +317,7 @@ int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, + return -ENOMEM; + + mlxsw_qsfp->cpld_dev_attrs = devm_kzalloc(mlxsw_bus_info->dev, +- MLXSW_QSFP_MAX_CPLD_NUM * ++ mlxsw_qsfp_cpld_num * + sizeof(*mlxsw_qsfp->cpld_dev_attrs), + GFP_KERNEL); + if (!mlxsw_qsfp->cpld_dev_attrs) +@@ -323,7 +355,7 @@ int mlxsw_qsfp_init(struct mlxsw_core *mlxsw_core, + } + + cpld_dev_attr = mlxsw_qsfp->cpld_dev_attrs; +- for (i = 0; i < MLXSW_QSFP_MAX_CPLD_NUM; i++, cpld_dev_attr++) { ++ for (i = 0; i < mlxsw_qsfp_cpld_num; i++, cpld_dev_attr++) { + cpld_dev_attr->show = mlxsw_qsfp_cpld_show; + cpld_dev_attr->attr.mode = 0444; + cpld_dev_attr->attr.name = devm_kasprintf(mlxsw_bus_info->dev, +diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c +index ba9241e..5c13591 100644 +--- a/drivers/platform/mellanox/mlxreg-hotplug.c ++++ b/drivers/platform/mellanox/mlxreg-hotplug.c +@@ -58,6 +58,7 @@ + #define MLXREG_HOTPLUG_PROP_STATUS "status" + + #define MLXREG_HOTPLUG_ATTRS_MAX 24 ++#define MLXREG_HOTPLUG_NOT_ASSERT 3 + + /** + * struct mlxreg_hotplug_priv_data - platform private data: +@@ -74,6 +75,7 @@ + * @cell: location of top aggregation interrupt register; + * @mask: top aggregation interrupt common mask; + * @aggr_cache: last value of aggregation register status; ++ * @not_asserted: number of entries in workqueue with no signal assertion; + */ + struct mlxreg_hotplug_priv_data { + int irq; +@@ -94,6 +96,7 @@ struct mlxreg_hotplug_priv_data { + u32 mask; + u32 aggr_cache; + bool after_probe; ++ u8 not_asserted; + }; + + #if defined(CONFIG_OF_DYNAMIC) +@@ -441,7 +444,7 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv, + * *---* + * + * In case some system changed are detected: FAN in/out, PSU in/out, power +- * cable attached/detached, ASIC helath good/bad, relevant device is created ++ * cable attached/detached, ASIC health good/bad, relevant device is created + * or destroyed. + */ + static void mlxreg_hotplug_work_handler(struct work_struct *work) +@@ -472,6 +475,13 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work) + aggr_asserted = priv->aggr_cache ^ regval; + priv->aggr_cache = regval; + ++ if (priv->not_asserted == MLXREG_HOTPLUG_NOT_ASSERT) { ++ priv->not_asserted = 0; ++ aggr_asserted = pdata->mask; ++ } ++ if (!aggr_asserted) ++ goto unmask_event; ++ + /* Handle topology and health configuration changes. */ + for (i = 0; i < pdata->counter; i++, item++) { + if (aggr_asserted & item->aggr_mask) { +@@ -503,6 +513,8 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work) + return; + } + ++unmask_event: ++ priv->not_asserted++; + /* Unmask aggregation event (no need acknowledge). */ + ret = regmap_write(priv->regmap, pdata->cell + + MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); +@@ -626,6 +638,7 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev) + { + struct mlxreg_core_hotplug_platform_data *pdata; + struct mlxreg_hotplug_priv_data *priv; ++ struct i2c_adapter *deferred_adap; + int err; + + pdata = dev_get_platdata(&pdev->dev); +@@ -634,6 +647,12 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev) + return -EINVAL; + } + ++ /* Defer probing if the necessary adapter is not configured yet. */ ++ deferred_adap = i2c_get_adapter(pdata->deferred_nr); ++ if (!deferred_adap) ++ return -EPROBE_DEFER; ++ i2c_put_adapter(deferred_adap); ++ + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +index 61cbe35..e03f03f 100644 +--- a/drivers/platform/x86/mlx-platform.c ++++ b/drivers/platform/x86/mlx-platform.c +@@ -99,6 +99,15 @@ + #define MLXPLAT_CPLD_LED_LO_NIBBLE_MASK GENMASK(7, 4) + #define MLXPLAT_CPLD_LED_HI_NIBBLE_MASK GENMASK(3, 0) + ++/* Default I2C parent bus number */ ++#define MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR 1 ++ ++/* Maximum number of possible physical buses equipped on system */ ++#define MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM 16 ++ ++/* Number of channels in group */ ++#define MLXPLAT_CPLD_GRP_CHNL_NUM 8 ++ + /* Start channel numbers */ + #define MLXPLAT_CPLD_CH1 2 + #define MLXPLAT_CPLD_CH2 10 +@@ -106,7 +115,8 @@ + /* Number of LPC attached MUX platform devices */ + #define MLXPLAT_CPLD_LPC_MUX_DEVS 2 + +-/* PSU adapter numbers */ ++/* Hotplug devices adapter numbers */ ++#define MLXPLAT_CPLD_NR_NONE -1 + #define MLXPLAT_CPLD_PSU_DEFAULT_NR 10 + #define MLXPLAT_CPLD_PSU_MSNXXXX_NR 4 + +@@ -137,7 +147,7 @@ static const struct resource mlxplat_lpc_resources[] = { + }; + + /* Platform default channels */ +-static const int mlxplat_default_channels[][8] = { ++static const int mlxplat_default_channels[][MLXPLAT_CPLD_GRP_CHNL_NUM] = { + { + MLXPLAT_CPLD_CH1, MLXPLAT_CPLD_CH1 + 1, MLXPLAT_CPLD_CH1 + 2, + MLXPLAT_CPLD_CH1 + 3, MLXPLAT_CPLD_CH1 + 4, MLXPLAT_CPLD_CH1 + +@@ -472,14 +482,14 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_fan_items_data[] = { + { + .label = "fan5", + .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, +- .mask = BIT(3), ++ .mask = BIT(4), + .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, + .hpdev.nr = 15, + }, + { + .label = "fan6", + .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, +- .mask = BIT(3), ++ .mask = BIT(5), + .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, + .hpdev.nr = 16, + }, +@@ -943,10 +953,18 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_regs_io_data[] = { + GENMASK(7, 0) & ~BIT(0), 0x00, 0444 }, + { "cause_short_pb", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, + GENMASK(7, 0) & ~BIT(1), 0x00, 0444 }, +- { "cause_pwr_aux", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ { "cause_aux_pwr_or_refresh", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, + GENMASK(7, 0) & ~BIT(2), 0x00, 0444 }, +- { "cause_pwr_fail", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ { "cause_main_pwr_fail", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, + GENMASK(7, 0) & ~BIT(3), 0x00, 0444 }, ++ { "cause_sw_reset", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(4), 0x00, 0444 }, ++ { "cause_fw_reset", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(5), 0x00, 0444 }, ++ { "cause_hotswap_or_wd", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(6), 0x00, 0444 }, ++ { "cause_asic_thermal", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, ++ GENMASK(7, 0) & ~BIT(7), 0x00, 0444 }, + { "psu1_on", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(0), + 0x00, 0200 }, + { "psu2_on", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(1), +@@ -977,6 +995,8 @@ static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) + ARRAY_SIZE(mlxplat_default_channels[i]); + } + mlxplat_hotplug = &mlxplat_mlxcpld_default_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_default_led_data; + mlxplat_regs_io = &mlxplat_default_regs_io_data; + +@@ -993,6 +1013,8 @@ static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) + ARRAY_SIZE(mlxplat_msn21xx_channels); + } + mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_msn21xx_led_data; + mlxplat_regs_io = &mlxplat_default_regs_io_data; + +@@ -1009,6 +1031,8 @@ static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi) + ARRAY_SIZE(mlxplat_msn21xx_channels); + } + mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_default_led_data; + mlxplat_regs_io = &mlxplat_default_regs_io_data; + +@@ -1025,6 +1049,8 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) + ARRAY_SIZE(mlxplat_msn21xx_channels); + } + mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_default_ng_led_data; + mlxplat_regs_io = &mlxplat_default_regs_io_data; + +@@ -1041,13 +1067,15 @@ static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) + ARRAY_SIZE(mlxplat_msn21xx_channels); + } + mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data; ++ mlxplat_hotplug->deferred_nr = ++ mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_msn21xx_led_data; + mlxplat_regs_io = &mlxplat_default_regs_io_data; + + return 1; + }; + +-static struct dmi_system_id mlxplat_dmi_table[] __initdata = { ++static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { + { + .callback = mlxplat_dmi_msn274x_matched, + .matches = { +@@ -1118,14 +1146,84 @@ static struct dmi_system_id mlxplat_dmi_table[] __initdata = { + DMI_MATCH(DMI_PRODUCT_NAME, "SN34"), + }, + }, ++ { ++ .callback = mlxplat_dmi_default_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0001"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_msn21xx_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0002"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_msn274x_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0003"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_msn201x_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0004"), ++ }, ++ }, ++ { ++ .callback = mlxplat_dmi_qmb7xx_matched, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "VMOD0005"), ++ }, ++ }, + { } + }; + ++MODULE_DEVICE_TABLE(dmi, mlxplat_dmi_table); ++ ++static int mlxplat_mlxcpld_verify_bus_topology(int *nr) ++{ ++ struct i2c_adapter *search_adap; ++ int shift, i; ++ ++ /* Scan adapters from expected id to verify it is free. */ ++ *nr = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; ++ for (i = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; i < ++ MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; i++) { ++ search_adap = i2c_get_adapter(i); ++ if (search_adap) { ++ i2c_put_adapter(search_adap); ++ continue; ++ } ++ ++ /* Return if expected parent adapter is free. */ ++ if (i == MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR) ++ return 0; ++ break; ++ } ++ ++ /* Return with error if free id for adapter is not found. */ ++ if (i == MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM) ++ return -ENODEV; ++ ++ /* Shift adapter ids, since expected parent adapter is not free. */ ++ *nr = i; ++ for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { ++ shift = *nr - mlxplat_mux_data[i].parent; ++ mlxplat_mux_data[i].parent = *nr; ++ mlxplat_mux_data[i].base_nr += shift; ++ if (shift > 0) ++ mlxplat_hotplug->shift_nr = shift; ++ } ++ ++ return 0; ++} ++ + static int __init mlxplat_init(void) + { + struct mlxplat_priv *priv; + void __iomem *base; +- int i, j, err = 0; ++ int i, j, nr, err = 0; + + if (!dmi_check_system(mlxplat_dmi_table)) + return -ENODEV; +@@ -1145,7 +1243,12 @@ static int __init mlxplat_init(void) + } + platform_set_drvdata(mlxplat_dev, priv); + +- priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", -1, ++ err = mlxplat_mlxcpld_verify_bus_topology(&nr); ++ if (nr < 0) ++ goto fail_alloc; ++ ++ nr = (nr == MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM) ? -1 : nr; ++ priv->pdev_i2c = platform_device_register_simple("i2c_mlxcpld", nr, + NULL, 0); + if (IS_ERR(priv->pdev_i2c)) { + err = PTR_ERR(priv->pdev_i2c); +@@ -1166,13 +1269,17 @@ static int __init mlxplat_init(void) + + base = devm_ioport_map(&mlxplat_dev->dev, + mlxplat_lpc_resources[1].start, 1); +- if (IS_ERR(base)) ++ if (!base) { ++ err = -ENOMEM; + goto fail_platform_mux_register; ++ } + + mlxplat_hotplug->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL, + base, &mlxplat_mlxcpld_regmap_config); +- if (IS_ERR(mlxplat_hotplug->regmap)) ++ if (IS_ERR(mlxplat_hotplug->regmap)) { ++ err = PTR_ERR(mlxplat_hotplug->regmap); + goto fail_platform_mux_register; ++ } + + /* Set default registers. */ + for (j = 0; j < mlxplat_mlxcpld_regmap_config.num_reg_defaults; j++) { +@@ -1257,13 +1364,3 @@ module_exit(mlxplat_exit); + MODULE_AUTHOR("Vadim Pasternak (vadimp@mellanox.com)"); + MODULE_DESCRIPTION("Mellanox platform driver"); + MODULE_LICENSE("Dual BSD/GPL"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSN24*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSN27*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSB*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSX*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*:MSN21*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*MSN274*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*MSN201*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*QMB7*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*SN37*:"); +-MODULE_ALIAS("dmi:*:*Mellanox*QM34*:"); +diff --git a/include/linux/platform_data/mlxreg.h b/include/linux/platform_data/mlxreg.h +index c25623b..b77c7a5 100644 +--- a/include/linux/platform_data/mlxreg.h ++++ b/include/linux/platform_data/mlxreg.h +@@ -129,6 +129,8 @@ struct mlxreg_core_platform_data { + * @mask: top aggregation interrupt common mask; + * @cell_low: location of low aggregation interrupt register; + * @mask_low: low aggregation interrupt common mask; ++ * @deferred_nr: I2C adapter number must be exist prior probing execution; ++ * @shift_nr: I2C adapter numbers must be incremented by this value; + */ + struct mlxreg_core_hotplug_platform_data { + struct mlxreg_core_item *items; +@@ -139,6 +141,8 @@ struct mlxreg_core_hotplug_platform_data { + u32 mask; + u32 cell_low; + u32 mask_low; ++ int deferred_nr; ++ int shift_nr; + }; + + #endif /* __LINUX_PLATFORM_DATA_MLXREG_H */ diff --git a/packages/base/any/kernels/4.9-lts/patches/0012-i2c-busses-Add-capabilities-to-i2c-mlxcpld.patch b/packages/base/any/kernels/4.9-lts/patches/0012-i2c-busses-Add-capabilities-to-i2c-mlxcpld.patch new file mode 100644 index 00000000..866593a2 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0012-i2c-busses-Add-capabilities-to-i2c-mlxcpld.patch @@ -0,0 +1,199 @@ +From 23c8535af1dd9dcaecb5aaf4097129bfb7e24570 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Thu, 15 Mar 2018 18:38:18 +0000 +Subject: [backport 4.9 7/7] i2c: busses: Add capabilities to i2c-mlxcpld + +It adds support for extended length of read and write transactions. +New CPLD logic allows double size of the read and write transactions +length. This feature is verified through capability register, which is +renamed from unclear LPF_REG to CPBLTY_REG. Two bits 5 and 6 of these +register are used for length capability detection, while only 01 +combination indicates support of extended transaction length. Others mean +lack of such support. + +It adds support for smbus block read transaction. CPLD smbus block read +bit of capability register is verified during driver initialization, and +driver data is updated if such capability is available. In case an upper +layer requests a read transaction of length one and expects that length +will be the first received byte, driver will notify CPLD about SMBus block +read transaction flavor, so CPLD will know to execute such kind of +transaction. + +It fixes report about supported functionality. +Functionality can be different up to CPLD capability. + +It allows mlxcpld driver to be connected to pre-defined adapter number +equal or greater than one, in order to avoid current limitation, assuming +usage of id number one only. + +Author: Michael Shych +Patches are sent to i2c-next. + +Signed-off-by: Vadim Pasternak +--- + drivers/i2c/busses/i2c-mlxcpld.c | 70 ++++++++++++++++++++++++++++++++++------ + 1 file changed, 60 insertions(+), 10 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c +index d271e6a..745ed43 100644 +--- a/drivers/i2c/busses/i2c-mlxcpld.c ++++ b/drivers/i2c/busses/i2c-mlxcpld.c +@@ -45,13 +45,16 @@ + #define MLXCPLD_I2C_VALID_FLAG (I2C_M_RECV_LEN | I2C_M_RD) + #define MLXCPLD_I2C_BUS_NUM 1 + #define MLXCPLD_I2C_DATA_REG_SZ 36 ++#define MLXCPLD_I2C_DATA_SZ_BIT BIT(5) ++#define MLXCPLD_I2C_DATA_SZ_MASK GENMASK(6, 5) ++#define MLXCPLD_I2C_SMBUS_BLK_BIT BIT(7) + #define MLXCPLD_I2C_MAX_ADDR_LEN 4 + #define MLXCPLD_I2C_RETR_NUM 2 + #define MLXCPLD_I2C_XFER_TO 500000 /* usec */ + #define MLXCPLD_I2C_POLL_TIME 2000 /* usec */ + + /* LPC I2C registers */ +-#define MLXCPLD_LPCI2C_LPF_REG 0x0 ++#define MLXCPLD_LPCI2C_CPBLTY_REG 0x0 + #define MLXCPLD_LPCI2C_CTRL_REG 0x1 + #define MLXCPLD_LPCI2C_HALF_CYC_REG 0x4 + #define MLXCPLD_LPCI2C_I2C_HOLD_REG 0x5 +@@ -83,6 +86,7 @@ struct mlxcpld_i2c_priv { + struct mutex lock; + struct mlxcpld_i2c_curr_xfer xfer; + struct device *dev; ++ bool smbus_block; + }; + + static void mlxcpld_i2c_lpc_write_buf(u8 *data, u8 len, u32 addr) +@@ -230,7 +234,7 @@ static void mlxcpld_i2c_set_transf_data(struct mlxcpld_i2c_priv *priv, + * All upper layers currently are never use transfer with more than + * 2 messages. Actually, it's also not so relevant in Mellanox systems + * because of HW limitation. Max size of transfer is not more than 32 +- * bytes in the current x86 LPCI2C bridge. ++ * or 68 bytes in the current x86 LPCI2C bridge. + */ + priv->xfer.cmd = msgs[num - 1].flags & I2C_M_RD; + +@@ -295,7 +299,7 @@ static int mlxcpld_i2c_wait_for_free(struct mlxcpld_i2c_priv *priv) + static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv) + { + int status, i, timeout = 0; +- u8 datalen; ++ u8 datalen, val; + + do { + usleep_range(MLXCPLD_I2C_POLL_TIME / 2, MLXCPLD_I2C_POLL_TIME); +@@ -324,9 +328,22 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv) + * Actual read data len will be always the same as + * requested len. 0xff (line pull-up) will be returned + * if slave has no data to return. Thus don't read +- * MLXCPLD_LPCI2C_NUM_DAT_REG reg from CPLD. ++ * MLXCPLD_LPCI2C_NUM_DAT_REG reg from CPLD. Only in case of ++ * SMBus block read transaction data len can be different, ++ * check this case. + */ +- datalen = priv->xfer.data_len; ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG, &val, ++ 1); ++ if (priv->smbus_block && (val & MLXCPLD_I2C_SMBUS_BLK_BIT)) { ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG, ++ &datalen, 1); ++ if (unlikely(datalen > (I2C_SMBUS_BLOCK_MAX + 1))) { ++ dev_err(priv->dev, "Incorrect smbus block read message len\n"); ++ return -E2BIG; ++ } ++ } else { ++ datalen = priv->xfer.data_len; ++ } + + mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_DATA_REG, + priv->xfer.msg[i].buf, datalen); +@@ -344,12 +361,20 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv) + static void mlxcpld_i2c_xfer_msg(struct mlxcpld_i2c_priv *priv) + { + int i, len = 0; +- u8 cmd; ++ u8 cmd, val; + + mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG, + &priv->xfer.data_len, 1); +- mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG, +- &priv->xfer.addr_width, 1); ++ ++ val = priv->xfer.addr_width; ++ /* Notify HW about SMBus block read transaction */ ++ if (priv->smbus_block && priv->xfer.msg_num >= 2 && ++ priv->xfer.msg[1].len == 1 && ++ (priv->xfer.msg[1].flags & I2C_M_RECV_LEN) && ++ (priv->xfer.msg[1].flags & I2C_M_RD)) ++ val |= MLXCPLD_I2C_SMBUS_BLK_BIT; ++ ++ mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG, &val, 1); + + for (i = 0; i < priv->xfer.msg_num; i++) { + if ((priv->xfer.msg[i].flags & I2C_M_RD) != I2C_M_RD) { +@@ -425,7 +450,14 @@ static int mlxcpld_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, + + static u32 mlxcpld_i2c_func(struct i2c_adapter *adap) + { +- return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; ++ struct mlxcpld_i2c_priv *priv = i2c_get_adapdata(adap); ++ ++ if (priv->smbus_block) ++ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | ++ I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_BLOCK_DATA; ++ else ++ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | ++ I2C_FUNC_SMBUS_I2C_BLOCK; + } + + static const struct i2c_algorithm mlxcpld_i2c_algo = { +@@ -433,13 +465,20 @@ static const struct i2c_algorithm mlxcpld_i2c_algo = { + .functionality = mlxcpld_i2c_func + }; + +-static struct i2c_adapter_quirks mlxcpld_i2c_quirks = { ++static const struct i2c_adapter_quirks mlxcpld_i2c_quirks = { + .flags = I2C_AQ_COMB_WRITE_THEN_READ, + .max_read_len = MLXCPLD_I2C_DATA_REG_SZ - MLXCPLD_I2C_MAX_ADDR_LEN, + .max_write_len = MLXCPLD_I2C_DATA_REG_SZ, + .max_comb_1st_msg_len = 4, + }; + ++static const struct i2c_adapter_quirks mlxcpld_i2c_quirks_ext = { ++ .flags = I2C_AQ_COMB_WRITE_THEN_READ, ++ .max_read_len = MLXCPLD_I2C_DATA_REG_SZ * 2 - MLXCPLD_I2C_MAX_ADDR_LEN, ++ .max_write_len = MLXCPLD_I2C_DATA_REG_SZ * 2, ++ .max_comb_1st_msg_len = 4, ++}; ++ + static struct i2c_adapter mlxcpld_i2c_adapter = { + .owner = THIS_MODULE, + .name = "i2c-mlxcpld", +@@ -454,6 +493,7 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev) + { + struct mlxcpld_i2c_priv *priv; + int err; ++ u8 val; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) +@@ -466,6 +506,16 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev) + + /* Register with i2c layer */ + mlxcpld_i2c_adapter.timeout = usecs_to_jiffies(MLXCPLD_I2C_XFER_TO); ++ /* Read capability register */ ++ mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_CPBLTY_REG, &val, 1); ++ /* Check support for extended transaction length */ ++ if ((val & MLXCPLD_I2C_DATA_SZ_MASK) == MLXCPLD_I2C_DATA_SZ_BIT) ++ mlxcpld_i2c_adapter.quirks = &mlxcpld_i2c_quirks_ext; ++ /* Check support for smbus block transaction */ ++ if (val & MLXCPLD_I2C_SMBUS_BLK_BIT) ++ priv->smbus_block = true; ++ if (pdev->id >= -1) ++ mlxcpld_i2c_adapter.nr = pdev->id; + priv->adap = mlxcpld_i2c_adapter; + priv->adap.dev.parent = &pdev->dev; + priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR; +-- +2.1.4 + diff --git a/packages/base/any/kernels/4.9-lts/patches/series b/packages/base/any/kernels/4.9-lts/patches/series index b16099f0..e83cb1cb 100644 --- a/packages/base/any/kernels/4.9-lts/patches/series +++ b/packages/base/any/kernels/4.9-lts/patches/series @@ -7,3 +7,7 @@ driver-support-intel-igb-bcm5461-phy.patch 0006-Mellanox-switch-drivers-changes.patch 0007-hwmon-pmbus-Add-support-for-Intel-VID-protocol-VR13.patch 0008-hwmon-pmbus-Add-support-for-Texas-Instruments-tps536.patch +0009-platform-mellonox-introduce-mlxreg-io-driver-and-add.patch +0010-platform-mellanox-mlxreg-hotplug-driver-add-check-fo.patch +0011-platform-x86-mlx-platform-new-features.patch +0012-i2c-busses-Add-capabilities-to-i2c-mlxcpld.patch From a27f118fcca3860e70df7a7f80d3fa719d13bd32 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Wed, 28 Mar 2018 11:32:17 +0800 Subject: [PATCH 201/244] Valiadate the SFP bitmaps, present and rx_los. Signed-off-by: roy_lee --- .../builds/x86-64-accton-as7326-56x-cpld.c | 154 +++++++++++++----- .../onlp/builds/src/module/src/sfpi.c | 67 ++++---- 2 files changed, 138 insertions(+), 83 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c index ac018c04..7985f09a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/modules/builds/x86-64-accton-as7326-56x-cpld.c @@ -581,74 +581,138 @@ static const struct attribute_group as7326_56x_cpld1_group = { .attrs = as7326_56x_cpld1_attributes, }; +/*Split a number into bytes and insert blank between any 2 of bytes.*/ +static int string_byte_sep(char *out, int bits, u64 bytes) +{ + int i; + char sb[8]; + + if (!out) + return -EINVAL; + + out[0] = 0; + for (i = 0; i < ((bits+7)/8); i++) { + sprintf(sb, "%02llx ", (bytes>>(i*8))&0xff); + strncat(out, sb, strlen(sb)); + } + out[strlen(out)-1] = 0; + + return 0; +} + static ssize_t show_present_all(struct device *dev, struct device_attribute *da, char *buf) { - int i, status; - u8 values[4] = {0}; - u8 regs[] = {0x9, 0xA, 0xB, 0x18}; - struct i2c_client *client = to_i2c_client(dev); - struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + int i, status; + u64 values = 0, num; + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); - mutex_lock(&data->update_lock); - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = as7326_56x_cpld_read_internal(client, regs[i]); - - if (status < 0) { - goto exit; - } - - values[i] = ~(u8)status; - } - - mutex_unlock(&data->update_lock); - - /* Return values 1 -> 56 in order */ if (data->type == as7326_56x_cpld2) { - values[3] &= 0xF; - } - else { /* as7326_56x_cpld3 */ - values[3] &= 0x3; - } + u8 byte; + u8 regs[] = {0x0F, 0x10, 0x11, 0x12}; - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); + mutex_lock(&data->update_lock); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7326_56x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + byte= (u64)status; + byte= ~byte; + values |= (byte)<<(i*8); + } + mutex_unlock(&data->update_lock); + /* Return values for port 1~30 in order */ + num = 30; + values &= (1<update_lock); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7326_56x_cpld_read_internal(client, regs[i]); + if (status < 0) { + goto exit; + } + bytes[i] = (u8)status; + bytes[i] = ~bytes[i]; + } + mutex_unlock(&data->update_lock); + + /* Return values of port 31 -> 58 in order */ + values = bytes[0] | (bytes[1]<<8) | ((bytes[2]&0x3)<<16) | ((bytes[3])<<18) | + (((bytes[2]&0xC) >> 2)<<26); + num = 28; + values &= (1<update_lock); - return status; + mutex_unlock(&data->update_lock); + return status; } static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, char *buf) { - int i, status; - u8 values[3] = {0}; - u8 regs[] = {0x12, 0x13, 0x14}; - struct i2c_client *client = to_i2c_client(dev); - struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); + int i, status; + u64 values = 0, num; + struct i2c_client *client = to_i2c_client(dev); + struct as7326_56x_cpld_data *data = i2c_get_clientdata(client); - mutex_lock(&data->update_lock); + if (data->type == as7326_56x_cpld2) { + u8 byte; + u8 regs[] = {0x0B, 0x0C, 0x0D, 0x0E}; - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = as7326_56x_cpld_read_internal(client, regs[i]); + mutex_lock(&data->update_lock); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7326_56x_cpld_read_internal(client, regs[i]); - if (status < 0) { - goto exit; + if (status < 0) { + goto exit; + } + byte= (u64)status; + values |= (byte)<<(i*8); } + mutex_unlock(&data->update_lock); + + /* Return values for port 1~30 in order */ + num = 30; + values &= (1<update_lock); + mutex_lock(&data->update_lock); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7326_56x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + bytes[i] = (u8)status; + } + mutex_unlock(&data->update_lock); - /* Return values 1 -> 24 in order */ - return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + /* Return values of port 31 -> 58 in order */ + values = bytes[0] | (bytes[1]<<8) | ((bytes[2]&0x3)<<16) | + (((bytes[2]&0xC) >> 2)<<26); + num = 28; + values &= (1<update_lock); - return status; + mutex_unlock(&data->update_lock); + return status; } static ssize_t show_status(struct device *dev, struct device_attribute *da, diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c index 4aead529..d737f263 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sfpi.c @@ -103,11 +103,12 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[8], *ptr = NULL; + uint8_t bytes[8]; + uint32_t *words[2]; FILE* fp; - int addr; - - ptr = bytes; + int addr, i; + uint8_t *ptr = bytes; + unsigned long long presence_all = 0, per_cpld; for (addr = 62; addr >= 60; addr-=2) { /* Read present status of port 0~53 */ @@ -121,7 +122,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_E_INTERNAL; } - int count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + int count = fscanf(fp, "%hhx %hhx %hhx %hhx", ptr+0, ptr+1, ptr+2, ptr+3); fclose(fp); if(count != 4) { /* Likely a CPLD read timeout. */ @@ -132,26 +133,14 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) ptr += count; } - /* Mask out non-existant QSFP ports */ - bytes[3] &= 0xF; - bytes[7] &= 0x3; + /*Presumed here are little-endian.*/ + words[0] = (uint32_t*)&bytes[0]; + words[1] = (uint32_t*)&bytes[4]; /* Convert to 64 bit integer in port order */ - int i = 0; - uint64_t presence_all = 0 ; - presence_all |= bytes[7]; - presence_all <<= 4; - presence_all |= bytes[3]; - - for(i = 6; i >= 4; i--) { - presence_all <<= 8; - presence_all |= bytes[i]; - } - - for(i = 2; i >= 0; i--) { - presence_all <<= 8; - presence_all |= bytes[i]; - } + presence_all |= *words[0] & ((1<<30)-1); /*30 port at cpld 2*/ + per_cpld = (unsigned long long)(*words[1] & ((1<<28)-1)) << 30; /*28 port at cpld 1*/ + presence_all |= per_cpld; /* Populate bitmap */ for(i = 0; presence_all; i++) { @@ -165,19 +154,21 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[6]; - uint32_t *ptr = bytes; + uint8_t bytes[8]; + uint32_t *words[2]; + uint8_t *ptr = bytes; FILE* fp; + unsigned long long all = 0, per_cpld; /* Read present status of port 0~23 */ int addr, i = 0; for (addr = 62; addr >= 60; addr-=2) { if (addr == 62) { - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); } else { - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); } if(fp == NULL) { @@ -185,9 +176,9 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_E_INTERNAL; } - int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + int count = fscanf(fp, "%hhx %hhx %hhx %hhx", ptr+0, ptr+1, ptr+2, ptr+3); fclose(fp); - if(count != 3) { + if(count != 4) { /* Likely a CPLD read timeout. */ AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); return ONLP_STATUS_E_INTERNAL; @@ -195,19 +186,19 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) ptr += count; } + /*Presumed here are little-endian.*/ + words[0] = (uint32_t*)&bytes[0]; + words[1] = (uint32_t*)&bytes[4]; /* Convert to 64 bit integer in port order */ - i = 0; - uint64_t rx_los_all = 0 ; - for(i = 5; i >= 0; i--) { - rx_los_all <<= 8; - rx_los_all |= bytes[i]; - } + all |= *words[0] & ((1<<30)-1); /*30 port at cpld 2*/ + per_cpld = (unsigned long long)(*words[1] & ((1<<28)-1)) << 30; /*28 port at cpld 1*/ + all |= per_cpld; /* Populate bitmap */ - for(i = 0; rx_los_all; i++) { - AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); - rx_los_all >>= 1; + for(i = 0; all; i++) { + AIM_BITMAP_MOD(dst, i, (all & 1)); + all >>= 1; } return ONLP_STATUS_OK; From 7a55f96744d858b95de4a33092ec86a81137f361 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 28 Mar 2018 16:01:17 +0800 Subject: [PATCH 202/244] [as5822-54x] Add support for OOM --- .../builds/x86-64-accton-as5822-54x-cpld.c | 1148 ++++++++++++++ .../builds/x86-64-accton-as5822-54x-fan.c | 8 +- .../builds/x86-64-accton-as5822-54x-leds.c | 8 +- .../builds/x86-64-accton-as5822-54x-psu.c | 17 +- .../builds/x86-64-accton-as5822-54x-sfp.c | 1376 ----------------- .../onlp/builds/src/module/src/sfpi.c | 269 ++-- .../x86_64_accton_as5822_54x_r0/__init__.py | 18 +- 7 files changed, 1346 insertions(+), 1498 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-cpld.c new file mode 100644 index 00000000..455614ef --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-cpld.c @@ -0,0 +1,1148 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5822_54x CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as5822_54x_cpld1, + as5822_54x_cpld2, + as5822_54x_cpld3 +}; + +struct as5822_54x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as5822_54x_cpld_id[] = { + { "as5822_54x_cpld1", as5822_54x_cpld1 }, + { "as5822_54x_cpld2", as5822_54x_cpld2 }, + { "as5822_54x_cpld3", as5822_54x_cpld3 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as5822_54x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5822_54x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5822_54x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5822_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5822_54x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5822_54x_cpld1_group = { + .attrs = as5822_54x_cpld1_attributes, +}; + +static struct attribute *as5822_54x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + NULL +}; + +static const struct attribute_group as5822_54x_cpld2_group = { + .attrs = as5822_54x_cpld2_attributes, +}; + +static struct attribute *as5822_54x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5822_54x_cpld3_group = { + .attrs = as5822_54x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x3, 0x4, 0x5, 0x6}; + struct i2c_client *client = to_i2c_client(dev); + struct as5822_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5822_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 54 in order */ + if (data->type == as5822_54x_cpld2) { + values[3] &= 0x1F; + } + else { /* as5822_54x_cpld3 */ + values[2] &= 0x7; + values[3] &= 0x3F; + values[2] |= (values[3] & 0x1F) << 3; + values[3] >>= 5; /* shift out port 49-53 */ + } + + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs_cpld2[] = {0xF, 0x10, 0x11, 0x12}; + u8 regs_cpld3[] = {0xD, 0xE, 0xF}; + u8 *regs[] = {NULL, regs_cpld2, regs_cpld3}; + u8 size[] = {0, ARRAY_SIZE(regs_cpld2), ARRAY_SIZE(regs_cpld3)}; + struct i2c_client *client = to_i2c_client(dev); + struct as5822_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < size[data->type]; i++) { + status = as5822_54x_cpld_read_internal(client, regs[data->type][i]); + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + if (data->type == as5822_54x_cpld2) { + values[3] &= 0x1F; + + /* Return values in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", values[0], values[1], values[2], values[3]); + } + else { /* as5822_54x_cpld3 */ + values[2] &= 0x7; + + /* Return values in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + } + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5822_54x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x3; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x4; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x5; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_29: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_30 ... MODULE_PRESENT_37: + reg = 0x3; + mask = 0x1 << (attr->index - MODULE_PRESENT_30); + break; + case MODULE_PRESENT_38 ... MODULE_PRESENT_45: + reg = 0x4; + mask = 0x1 << (attr->index - MODULE_PRESENT_38); + break; + case MODULE_PRESENT_46 ... MODULE_PRESENT_48: + reg = 0x5; + mask = 0x1 << (attr->index - MODULE_PRESENT_46); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x6; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_29: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_30 ... MODULE_TXFAULT_37: + reg = 0x7; + mask = 0x1 << (attr->index - MODULE_TXFAULT_30); + break; + case MODULE_TXFAULT_38 ... MODULE_TXFAULT_45: + reg = 0x8; + mask = 0x1 << (attr->index - MODULE_TXFAULT_38); + break; + case MODULE_TXFAULT_46 ... MODULE_TXFAULT_48: + reg = 0x9; + mask = 0x1 << (attr->index - MODULE_TXFAULT_46); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_29: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_30 ... MODULE_TXDISABLE_37: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_30); + break; + case MODULE_TXDISABLE_38 ... MODULE_TXDISABLE_45: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_38); + break; + case MODULE_TXDISABLE_46 ... MODULE_TXDISABLE_48: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_46); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_29: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_30 ... MODULE_RXLOS_37: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_RXLOS_30); + break; + case MODULE_RXLOS_38 ... MODULE_RXLOS_45: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_RXLOS_38); + break; + case MODULE_RXLOS_46 ... MODULE_RXLOS_48: + reg = 0xF; + mask = 0x1 << (attr->index - MODULE_RXLOS_46); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5822_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5822_54x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0xD; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_29: + reg = 0xE; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_30 ... MODULE_TXDISABLE_37: + reg = 0xA; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_30); + break; + case MODULE_TXDISABLE_38 ... MODULE_TXDISABLE_45: + reg = 0xB; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_38); + break; + case MODULE_TXDISABLE_46 ... MODULE_TXDISABLE_48: + reg = 0xC; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_46); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5822_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5822_54x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5822_54x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5822_54x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as5822_54x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5822_54x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as5822_54x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as5822_54x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as5822_54x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as5822_54x_cpld1: + group = &as5822_54x_cpld1_group; + break; + case as5822_54x_cpld2: + group = &as5822_54x_cpld2_group; + break; + case as5822_54x_cpld3: + group = &as5822_54x_cpld3_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as5822_54x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as5822_54x_cpld_remove(struct i2c_client *client) +{ + struct as5822_54x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as5822_54x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5822_54x_cpld1: + group = &as5822_54x_cpld1_group; + break; + case as5822_54x_cpld2: + group = &as5822_54x_cpld2_group; + break; + case as5822_54x_cpld3: + group = &as5822_54x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as5822_54x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5822_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5822_54x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5822_54x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5822_54x_cpld_read); + +int as5822_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5822_54x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5822_54x_cpld_write); + +static struct i2c_driver as5822_54x_cpld_driver = { + .driver = { + .name = "as5822_54x_cpld", + .owner = THIS_MODULE, + }, + .probe = as5822_54x_cpld_probe, + .remove = as5822_54x_cpld_remove, + .id_table = as5822_54x_cpld_id, +}; + +static int __init as5822_54x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5822_54x_cpld_driver); +} + +static void __exit as5822_54x_cpld_exit(void) +{ + i2c_del_driver(&as5822_54x_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as5822_54x_cpld_init); +module_exit(as5822_54x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-fan.c index 52b55612..2149b4f4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-fan.c @@ -39,8 +39,8 @@ static struct as5822_54x_fan_data *as5822_54x_fan_update_device(struct device *d static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5822_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5822_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /* fan related data, the index should match sysfs_fan_attributes */ @@ -199,12 +199,12 @@ static struct attribute *as5822_54x_fan_attributes[] = { static int as5822_54x_fan_read_value(u8 reg) { - return accton_i2c_cpld_read(FAN_STATUS_I2C_ADDR, reg); + return as5822_54x_cpld_read(FAN_STATUS_I2C_ADDR, reg); } static int as5822_54x_fan_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(FAN_STATUS_I2C_ADDR, reg, value); + return as5822_54x_cpld_write(FAN_STATUS_I2C_ADDR, reg, value); } /* fan utility functions diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-leds.c index 2795da57..52d70db4 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-leds.c @@ -38,8 +38,8 @@ #define DEBUG_PRINT(fmt, args...) #endif -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5822_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5822_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); struct accton_as5822_54x_led_data { struct platform_device *pdev; @@ -147,12 +147,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5822_54x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as5822_54x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as5822_54x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as5822_54x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as5822_54x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c index 4d2e8a28..7e0c08ca 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c @@ -50,7 +50,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); static int as5822_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5822_54x_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -317,7 +317,7 @@ static struct as5822_54x_psu_data *as5822_54x_psu_update_device(struct device *d data->valid = 0; /* Read psu status */ - status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as5822_54x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -372,18 +372,7 @@ exit: return data; } -static int __init as5822_54x_psu_init(void) -{ - return i2c_add_driver(&as5822_54x_psu_driver); -} - -static void __exit as5822_54x_psu_exit(void) -{ - i2c_del_driver(&as5822_54x_psu_driver); -} - -module_init(as5822_54x_psu_init); -module_exit(as5822_54x_psu_exit); +module_i2c_driver(as5822_54x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as5822_54x_psu driver"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-sfp.c deleted file mode 100644 index 5124e494..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-sfp.c +++ /dev/null @@ -1,1376 +0,0 @@ -/* - * SFP driver for accton as5822_54x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5822_54x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -/* Platform dependent +++ */ -enum CPLD_ID{ - SFP_CPLD1, - SFP_CPLD2, - NUM_OF_CPLD -}; - -int cplds[NUM_OF_CPLD] = {0x61, 0x62}; - -/* Platform dependent --- */ - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_FAULT_ALL, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - TX_DISABLE_ALL, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_fault_all, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT_ALL); -static SENSOR_DEVICE_ATTR(sfp_tx_disable_all, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_DISABLE_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable_all.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as5822_54x_sfp1, as5822_54x_sfp2, as5822_54x_sfp3, as5822_54x_sfp4, as5822_54x_sfp5, as5822_54x_sfp6, as5822_54x_sfp7, as5822_54x_sfp8, -as5822_54x_sfp9, as5822_54x_sfp10, as5822_54x_sfp11, as5822_54x_sfp12, as5822_54x_sfp13, as5822_54x_sfp14, as5822_54x_sfp15, as5822_54x_sfp16, -as5822_54x_sfp17, as5822_54x_sfp18, as5822_54x_sfp19, as5822_54x_sfp20, as5822_54x_sfp21, as5822_54x_sfp22, as5822_54x_sfp23, as5822_54x_sfp24, -as5822_54x_sfp25, as5822_54x_sfp26, as5822_54x_sfp27, as5822_54x_sfp28, as5822_54x_sfp29, as5822_54x_sfp30, as5822_54x_sfp31, as5822_54x_sfp32, -as5822_54x_sfp33, as5822_54x_sfp34, as5822_54x_sfp35, as5822_54x_sfp36, as5822_54x_sfp37, as5822_54x_sfp38, as5822_54x_sfp39, as5822_54x_sfp40, -as5822_54x_sfp41, as5822_54x_sfp42, as5822_54x_sfp43, as5822_54x_sfp44, as5822_54x_sfp45, as5822_54x_sfp46, as5822_54x_sfp47, as5822_54x_sfp48, -as5822_54x_sfp49, as5822_54x_sfp50, as5822_54x_sfp51, as5822_54x_sfp52, as5822_54x_sfp53, as5822_54x_sfp54 -}; - -static const struct i2c_device_id sfp_device_id[] = { -{ "as5822_54x_sfp1", as5822_54x_sfp1 }, { "as5822_54x_sfp2", as5822_54x_sfp2 }, { "as5822_54x_sfp3", as5822_54x_sfp3 }, { "as5822_54x_sfp4", as5822_54x_sfp4 }, -{ "as5822_54x_sfp5", as5822_54x_sfp5 }, { "as5822_54x_sfp6", as5822_54x_sfp6 }, { "as5822_54x_sfp7", as5822_54x_sfp7 }, { "as5822_54x_sfp8", as5822_54x_sfp8 }, -{ "as5822_54x_sfp9", as5822_54x_sfp9 }, { "as5822_54x_sfp10", as5822_54x_sfp10 }, { "as5822_54x_sfp11", as5822_54x_sfp11 }, { "as5822_54x_sfp12", as5822_54x_sfp12 }, -{ "as5822_54x_sfp13", as5822_54x_sfp13 }, { "as5822_54x_sfp14", as5822_54x_sfp14 }, { "as5822_54x_sfp15", as5822_54x_sfp15 }, { "as5822_54x_sfp16", as5822_54x_sfp16 }, -{ "as5822_54x_sfp17", as5822_54x_sfp17 }, { "as5822_54x_sfp18", as5822_54x_sfp18 }, { "as5822_54x_sfp19", as5822_54x_sfp19 }, { "as5822_54x_sfp20", as5822_54x_sfp20 }, -{ "as5822_54x_sfp21", as5822_54x_sfp21 }, { "as5822_54x_sfp22", as5822_54x_sfp22 }, { "as5822_54x_sfp23", as5822_54x_sfp23 }, { "as5822_54x_sfp24", as5822_54x_sfp24 }, -{ "as5822_54x_sfp25", as5822_54x_sfp25 }, { "as5822_54x_sfp26", as5822_54x_sfp26 }, { "as5822_54x_sfp27", as5822_54x_sfp27 }, { "as5822_54x_sfp28", as5822_54x_sfp28 }, -{ "as5822_54x_sfp29", as5822_54x_sfp29 }, { "as5822_54x_sfp30", as5822_54x_sfp30 }, { "as5822_54x_sfp31", as5822_54x_sfp31 }, { "as5822_54x_sfp32", as5822_54x_sfp32 }, -{ "as5822_54x_sfp33", as5822_54x_sfp33 }, { "as5822_54x_sfp34", as5822_54x_sfp34 }, { "as5822_54x_sfp35", as5822_54x_sfp35 }, { "as5822_54x_sfp36", as5822_54x_sfp36 }, -{ "as5822_54x_sfp37", as5822_54x_sfp37 }, { "as5822_54x_sfp38", as5822_54x_sfp38 }, { "as5822_54x_sfp39", as5822_54x_sfp39 }, { "as5822_54x_sfp40", as5822_54x_sfp40 }, -{ "as5822_54x_sfp41", as5822_54x_sfp41 }, { "as5822_54x_sfp42", as5822_54x_sfp42 }, { "as5822_54x_sfp43", as5822_54x_sfp43 }, { "as5822_54x_sfp44", as5822_54x_sfp44 }, -{ "as5822_54x_sfp45", as5822_54x_sfp45 }, { "as5822_54x_sfp46", as5822_54x_sfp46 }, { "as5822_54x_sfp47", as5822_54x_sfp47 }, { "as5822_54x_sfp48", as5822_54x_sfp48 }, -{ "as5822_54x_sfp49", as5822_54x_sfp49 }, { "as5822_54x_sfp50", as5822_54x_sfp50 }, { "as5822_54x_sfp51", as5822_54x_sfp51 }, { "as5822_54x_sfp52", as5822_54x_sfp52 }, -{ "as5822_54x_sfp53", as5822_54x_sfp53 }, { "as5822_54x_sfp54", as5822_54x_sfp54 }, -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < ARRAY_SIZE(cplds); i++) { - for (j = 0; j < 4; j++) { - reg = 0x3+j; - status = accton_i2c_cpld_read(cplds[i], reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cplds[i], reg, status); - goto exit; - } - - if (i == SFP_CPLD1) { /* SFP_CPLD1 */ - data->present |= (u64)status << j*8; - } - else if (i == SFP_CPLD2) { /* SFP_CPLD2 */ - switch (j) { - case 0: - case 1: - data->present |= (u64)status << (j*8 + 29); - break; - case 2: - data->present |= ((u64)status & 0x7) << 45; - break; - case 3: - data->present |= ((u64)status & 0x3F) << 48; - break; - default: - break; - }; - } - } - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -struct i2c_info { - enum CPLD_ID cid; - int reg; -}; - -static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - struct i2c_info tx_fault[] = {{SFP_CPLD1, 0x7}, {SFP_CPLD1, 0x8}, - {SFP_CPLD1, 0x9}, {SFP_CPLD1, 0xa}, - {SFP_CPLD2, 0x7}, {SFP_CPLD2, 0x8}, - {SFP_CPLD2, 0x9}}; - struct i2c_info tx_disable[] = {{SFP_CPLD1, 0xb}, {SFP_CPLD1, 0xc}, - {SFP_CPLD1, 0xd}, {SFP_CPLD1, 0xe}, - {SFP_CPLD2, 0xa}, {SFP_CPLD2, 0xb}, - {SFP_CPLD2, 0xc}}; - struct i2c_info rx_los[] = {{SFP_CPLD1, 0xf}, {SFP_CPLD1, 0x10}, - {SFP_CPLD1, 0x11},{SFP_CPLD1, 0x12}, - {SFP_CPLD2, 0xd}, {SFP_CPLD2, 0xe}, - {SFP_CPLD2, 0xf}}; - struct i2c_info *tx_rx_data[] = {tx_fault, tx_disable, rx_los}; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as5822_54x sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - for (i = 0; i < ARRAY_SIZE(tx_rx_data); i++) { - for (j = 0; j < ARRAY_SIZE(tx_fault); j++) { - int cid = tx_rx_data[i][j].cid; - int reg = tx_rx_data[i][j].reg; - - status = accton_i2c_cpld_read(cplds[cid], reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cplds[cid], reg, status); - goto exit; - } - - switch (j) { - case 0 ... 2: - data->msa->status[i] |= (u64)status << j*8; - break; - case 3: - data->msa->status[i] |= ((u64)status & 0x1F) << j*8; - break; - case 4 ... 5: - data->msa->status[i] |= (u64)status << ((j-4)*8 + 29); - break; - case 6: - data->msa->status[i] |= ((u64)status & 0x7) << 45; - break; - default: - break; - }; - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_id = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - u8 tx_disable_regs[] = {0xb, 0xc, 0xd, 0xe, 0xa, 0xb, 0xc}; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < as5822_54x_sfp29) { - cpld_id = SFP_CPLD1; - cpld_reg = tx_disable_regs[data->port / 8]; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 30 ~ 48 */ - cpld_id = SFP_CPLD2; - cpld_reg = tx_disable_regs[(data->port - as5822_54x_sfp29) / 8 + 4]; - cpld_bit = 1 << ((data->port - as5822_54x_sfp30) % 8); - } - - /* Read current status */ - cpld_val = accton_i2c_cpld_read(cplds[cpld_id], cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - DEBUG_PRINT("Write to CPLD(0x%x), REG(0x%x), VAL(0x%x)", cplds[cpld_id], cpld_reg, cpld_val); - accton_i2c_cpld_write(cplds[cpld_id], cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL || attr->index == TX_FAULT_ALL || - attr->index == TX_DISABLE_ALL) { - int i = 0, index = 0; - u8 values[6] = {0}; - - switch (attr->index) { - case TX_FAULT_ALL: - index = 0; - break; - case TX_DISABLE_ALL: - index = 1; - break; - case RX_LOS_ALL: - index = 2; - break; - default: - break; - }; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[index] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as5822_54x_sfp1 && dev_id->driver_data <= as5822_54x_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* as5822_54x_sfp49 ~ as5822_54x_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5822_54x_sfp driver"); -MODULE_LICENSE("GPL"); - -late_initcall(sfp_init); -module_exit(sfp_exit); - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/sfpi.c index 47e39ee2..a2e1bb45 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/onlp/builds/src/module/src/sfpi.c @@ -2,7 +2,7 @@ * * * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2016 Accton Technology Corporation. + * Copyright 2013 Accton Technology Corporation. * * Licensed under the Eclipse Public License, Version 1.0 (the * "License"); you may not use this file except in compliance @@ -24,29 +24,21 @@ * ***********************************************************/ #include +#include #include -#include "platform_lib.h" - +#include "x86_64_accton_as5822_54x_int.h" #include "x86_64_accton_as5822_54x_log.h" -#define NUM_OF_SFP_PORT 54 -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_BUS_INDEX(port) (port+18) +#define PORT_BUS_INDEX(port) (port+18) -static char* -sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - FRONT_PORT_BUS_INDEX(port), addr, node_name); - return sfp_node_path; -} - -static char* -sfp_get_port_path(int port, char *node_name) -{ - return sfp_get_port_path_addr(port, 50, node_name); -} +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/10-0061/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/11-0062/module_rx_los_all" /************************************************************ * @@ -68,7 +60,7 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) */ int p; - for(p = 0; p < NUM_OF_SFP_PORT; p++) { + for(p = 0; p < 54; p++) { AIM_BITMAP_SET(bmap, p); } @@ -84,9 +76,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char *path = sfp_get_port_path(port, "sfp_is_present"); + int bus, addr; - if (onlp_file_read_int(&present, path) < 0) { + addr = (port < 29) ? 61 : 62; + bus = (addr == 61) ? 10 : 11; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -97,42 +92,51 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char* path; + uint32_t bytes[8], *ptr = NULL; FILE* fp; + int addr; - AIM_BITMAP_CLR_ALL(dst); + ptr = bytes; - path = sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + for (addr = 61; addr <= 62; addr++) { + /* Read present status of port 0~53 */ + char file[64] = {0}; + int bus = (addr == 61) ? 10 : 11; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD."); + return ONLP_STATUS_E_INTERNAL; + } - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + int count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD."); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Mask out non-existant QSFP ports */ - bytes[6] &= 0x3F; + bytes[3] &= 0x1F; + bytes[7] &= 0x1; /* Convert to 64 bit integer in port order */ int i = 0; uint64_t presence_all = 0 ; - for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + for(i = 7; i >= 4; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + presence_all <<= 5; + presence_all |= bytes[3]; + + for(i = 2; i >= 0; i--) { presence_all <<= 8; presence_all |= bytes[i]; } @@ -149,39 +153,68 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[6]; - char* path; + uint32_t bytes[7]; + uint32_t *ptr = bytes; FILE* fp; - path = sfp_get_port_path(0, "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 61; addr <= 62; addr++) { + int count; + + if (addr == 61) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + if (addr == 61) { + count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + else { + count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; uint64_t rx_los_all = 0 ; - for(i = 5; i >= 0; i--) { + bytes[3] &= 0x1F; + bytes[6] &= 0x7; + for(i = 6; i >= 4; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } + rx_los_all <<= 5; + rx_los_all |= bytes[3]; + + for(i = 2; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ for(i = 0; rx_los_all; i++) { AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); @@ -194,50 +227,102 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); return ONLP_STATUS_E_INTERNAL; } return ONLP_STATUS_OK; } +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 29) ? 61 : 62; + int bus = (addr == 61) ? 10 : 11; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - char* path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_write_integer(path, value) != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -259,16 +344,20 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; - char* path = NULL; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 29) ? 61 : 62; + int bus = (addr == 61) ? 10 : 11; switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - path = sfp_get_port_path(port, "sfp_rx_los"); - - if (onlp_file_read_int(value, path) < 0) { - AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } else { @@ -279,9 +368,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - path = sfp_get_port_path(port, "sfp_tx_fault"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -293,9 +380,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -312,9 +397,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) return rv; } - int onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/platform-config/r0/src/python/x86_64_accton_as5822_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/platform-config/r0/src/python/x86_64_accton_as5822_54x_r0/__init__.py index dff6590e..88005cae 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/platform-config/r0/src/python/x86_64_accton_as5822_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/platform-config/r0/src/python/x86_64_accton_as5822_54x_r0/__init__.py @@ -8,9 +8,9 @@ class OnlPlatform_x86_64_accton_as5822_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5822.54" def baseconfig(self): - self.insmod("accton_i2c_cpld") + self.insmod('optoe') self.insmod("ym2651y") - for m in [ "sfp", "psu", "fan", "leds" ]: + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: self.insmod("x86-64-accton-as5822-54x-%s" % m) ########### initialize I2C bus 0 ########### @@ -20,7 +20,7 @@ class OnlPlatform_x86_64_accton_as5822_54x_r0(OnlPlatformAccton, ('pca9548', 0x72, 0), # initialize CPLD - ('accton_i2c_cpld', 0x60, 6), + ('as5822_54x_cpld1', 0x60, 6), # initiate PSU-1 AC Power ('as5822_54x_psu1', 0x50, 3), @@ -45,8 +45,8 @@ class OnlPlatform_x86_64_accton_as5822_54x_r0(OnlPlatformAccton, ('pca9548', 0x70, 1), # initialize CPLD - ('accton_i2c_cpld', 0x61, 10), - ('accton_i2c_cpld', 0x62, 11), + ('as5822_54x_cpld2', 0x61, 10), + ('as5822_54x_cpld3', 0x62, 11), # initialize multiplexer (PCA9548) ('pca9548', 0x71, 12), @@ -64,11 +64,13 @@ class OnlPlatform_x86_64_accton_as5822_54x_r0(OnlPlatformAccton, # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5822_54x_sfp%d' % port, 0x50, port+17) - self.new_i2c_device('as5822_54x_sfp%d' % port, 0x51, port+17) + self.new_i2c_device('optoe2', 0x50, port+17) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5822_54x_sfp%d' % port, 0x50, port+17) + self.new_i2c_device('optoe1', 0x50, port+17) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+17), shell=True) return True From 721c3827c8f0729bfbb7e425393e57fa31bdd628 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 28 Mar 2018 16:53:47 +0800 Subject: [PATCH 203/244] [as5916-54xm] Add support for OOM --- .../builds/x86-64-accton-as5916-54xm-cpld.c | 1098 ++++++++++++++ .../builds/x86-64-accton-as5916-54xm-leds.c | 8 +- .../builds/x86-64-accton-as5916-54xm-psu.c | 4 +- .../builds/x86-64-accton-as5916-54xm-sfp.c | 1315 ----------------- .../onlp/builds/src/module/src/sfpi.c | 218 +-- .../x86_64_accton_as5916_54xm_r0/__init__.py | 16 +- 6 files changed, 1238 insertions(+), 1421 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-cpld.c new file mode 100644 index 00000000..d7074786 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-cpld.c @@ -0,0 +1,1098 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as5916_54xm_cpld1, + as5916_54xm_cpld2 +}; + +struct as5916_54xm_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as5916_54xm_cpld_id[] = { + { "as5916_54xm_cpld1", as5916_54xm_cpld1 }, + { "as5916_54xm_cpld2", as5916_54xm_cpld2 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as5916_54xm_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5916_54xm_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5916_54xm_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5916_54xm_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5916_54xm_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5916_54xm_cpld1_group = { + .attrs = as5916_54xm_cpld1_attributes, +}; + +static struct attribute *as5916_54xm_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5916_54xm_cpld2_group = { + .attrs = as5916_54xm_cpld2_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x10, 0x11, 0x12, 0x52}; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xm_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5916_54xm_cpld1) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5916_54xm_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + if (data->type == as5916_54xm_cpld1) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5916_54xm_cpld2 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x30, 0x32, 0x34}; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xm_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5916_54xm_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5916_54xm_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x52; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5916_54xm_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xm_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5916_54xm_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5916_54xm_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xm_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5916_54xm_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as5916_54xm_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5916_54xm_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as5916_54xm_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as5916_54xm_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as5916_54xm_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as5916_54xm_cpld1: + group = &as5916_54xm_cpld1_group; + break; + case as5916_54xm_cpld2: + group = &as5916_54xm_cpld2_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as5916_54xm_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as5916_54xm_cpld_remove(struct i2c_client *client) +{ + struct as5916_54xm_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as5916_54xm_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5916_54xm_cpld1: + group = &as5916_54xm_cpld1_group; + break; + case as5916_54xm_cpld2: + group = &as5916_54xm_cpld2_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as5916_54xm_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5916_54xm_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5916_54xm_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5916_54xm_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5916_54xm_cpld_read); + +int as5916_54xm_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5916_54xm_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5916_54xm_cpld_write); + +static struct i2c_driver as5916_54xm_cpld_driver = { + .driver = { + .name = "as5916_54xm_cpld", + .owner = THIS_MODULE, + }, + .probe = as5916_54xm_cpld_probe, + .remove = as5916_54xm_cpld_remove, + .id_table = as5916_54xm_cpld_id, +}; + +static int __init as5916_54xm_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5916_54xm_cpld_driver); +} + +static void __exit as5916_54xm_cpld_exit(void) +{ + i2c_del_driver(&as5916_54xm_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_54xm_cpld_init); +module_exit(as5916_54xm_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-leds.c index a0c31b13..04f39260 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-leds.c @@ -38,8 +38,8 @@ #define DEBUG_PRINT(fmt, args...) #endif -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5916_54xm_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5916_54xm_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); struct accton_as5916_54xm_led_data { struct platform_device *pdev; @@ -148,12 +148,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5916_54xm_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as5916_54xm_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as5916_54xm_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as5916_54xm_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as5916_54xm_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-psu.c index 90f44103..05b9a86a 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-psu.c @@ -37,7 +37,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5916_54xm_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5916_54xm_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -234,7 +234,7 @@ static struct as5916_54xm_psu_data *as5916_54xm_psu_update_device(struct device dev_dbg(&client->dev, "Starting as5916_54xm update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as5916_54xm_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-sfp.c deleted file mode 100644 index de1ed9bc..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/modules/builds/x86-64-accton-as5916-54xm-sfp.c +++ /dev/null @@ -1,1315 +0,0 @@ -/* - * SFP driver for accton as5916_54xm sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5916_54xm_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -/* Platform dependent +++ */ -#define I2C_ADDR_CPLD1 0x60 -#define I2C_ADDR_CPLD2 0x62 -/* Platform dependent --- */ - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as5916_54xm_sfp1, as5916_54xm_sfp2, as5916_54xm_sfp3, as5916_54xm_sfp4, as5916_54xm_sfp5, as5916_54xm_sfp6, as5916_54xm_sfp7, as5916_54xm_sfp8, -as5916_54xm_sfp9, as5916_54xm_sfp10, as5916_54xm_sfp11, as5916_54xm_sfp12, as5916_54xm_sfp13, as5916_54xm_sfp14, as5916_54xm_sfp15, as5916_54xm_sfp16, -as5916_54xm_sfp17, as5916_54xm_sfp18, as5916_54xm_sfp19, as5916_54xm_sfp20, as5916_54xm_sfp21, as5916_54xm_sfp22, as5916_54xm_sfp23, as5916_54xm_sfp24, -as5916_54xm_sfp25, as5916_54xm_sfp26, as5916_54xm_sfp27, as5916_54xm_sfp28, as5916_54xm_sfp29, as5916_54xm_sfp30, as5916_54xm_sfp31, as5916_54xm_sfp32, -as5916_54xm_sfp33, as5916_54xm_sfp34, as5916_54xm_sfp35, as5916_54xm_sfp36, as5916_54xm_sfp37, as5916_54xm_sfp38, as5916_54xm_sfp39, as5916_54xm_sfp40, -as5916_54xm_sfp41, as5916_54xm_sfp42, as5916_54xm_sfp43, as5916_54xm_sfp44, as5916_54xm_sfp45, as5916_54xm_sfp46, as5916_54xm_sfp47, as5916_54xm_sfp48, -as5916_54xm_sfp49, as5916_54xm_sfp50, as5916_54xm_sfp51, as5916_54xm_sfp52, as5916_54xm_sfp53, as5916_54xm_sfp54 -}; - -static const struct i2c_device_id sfp_device_id[] = { -{ "as5916_54xm_sfp1", as5916_54xm_sfp1 }, { "as5916_54xm_sfp2", as5916_54xm_sfp2 }, { "as5916_54xm_sfp3", as5916_54xm_sfp3 }, { "as5916_54xm_sfp4", as5916_54xm_sfp4 }, -{ "as5916_54xm_sfp5", as5916_54xm_sfp5 }, { "as5916_54xm_sfp6", as5916_54xm_sfp6 }, { "as5916_54xm_sfp7", as5916_54xm_sfp7 }, { "as5916_54xm_sfp8", as5916_54xm_sfp8 }, -{ "as5916_54xm_sfp9", as5916_54xm_sfp9 }, { "as5916_54xm_sfp10", as5916_54xm_sfp10 }, { "as5916_54xm_sfp11", as5916_54xm_sfp11 }, { "as5916_54xm_sfp12", as5916_54xm_sfp12 }, -{ "as5916_54xm_sfp13", as5916_54xm_sfp13 }, { "as5916_54xm_sfp14", as5916_54xm_sfp14 }, { "as5916_54xm_sfp15", as5916_54xm_sfp15 }, { "as5916_54xm_sfp16", as5916_54xm_sfp16 }, -{ "as5916_54xm_sfp17", as5916_54xm_sfp17 }, { "as5916_54xm_sfp18", as5916_54xm_sfp18 }, { "as5916_54xm_sfp19", as5916_54xm_sfp19 }, { "as5916_54xm_sfp20", as5916_54xm_sfp20 }, -{ "as5916_54xm_sfp21", as5916_54xm_sfp21 }, { "as5916_54xm_sfp22", as5916_54xm_sfp22 }, { "as5916_54xm_sfp23", as5916_54xm_sfp23 }, { "as5916_54xm_sfp24", as5916_54xm_sfp24 }, -{ "as5916_54xm_sfp25", as5916_54xm_sfp25 }, { "as5916_54xm_sfp26", as5916_54xm_sfp26 }, { "as5916_54xm_sfp27", as5916_54xm_sfp27 }, { "as5916_54xm_sfp28", as5916_54xm_sfp28 }, -{ "as5916_54xm_sfp29", as5916_54xm_sfp29 }, { "as5916_54xm_sfp30", as5916_54xm_sfp30 }, { "as5916_54xm_sfp31", as5916_54xm_sfp31 }, { "as5916_54xm_sfp32", as5916_54xm_sfp32 }, -{ "as5916_54xm_sfp33", as5916_54xm_sfp33 }, { "as5916_54xm_sfp34", as5916_54xm_sfp34 }, { "as5916_54xm_sfp35", as5916_54xm_sfp35 }, { "as5916_54xm_sfp36", as5916_54xm_sfp36 }, -{ "as5916_54xm_sfp37", as5916_54xm_sfp37 }, { "as5916_54xm_sfp38", as5916_54xm_sfp38 }, { "as5916_54xm_sfp39", as5916_54xm_sfp39 }, { "as5916_54xm_sfp40", as5916_54xm_sfp40 }, -{ "as5916_54xm_sfp41", as5916_54xm_sfp41 }, { "as5916_54xm_sfp42", as5916_54xm_sfp42 }, { "as5916_54xm_sfp43", as5916_54xm_sfp43 }, { "as5916_54xm_sfp44", as5916_54xm_sfp44 }, -{ "as5916_54xm_sfp45", as5916_54xm_sfp45 }, { "as5916_54xm_sfp46", as5916_54xm_sfp46 }, { "as5916_54xm_sfp47", as5916_54xm_sfp47 }, { "as5916_54xm_sfp48", as5916_54xm_sfp48 }, -{ "as5916_54xm_sfp49", as5916_54xm_sfp49 }, { "as5916_54xm_sfp50", as5916_54xm_sfp50 }, { "as5916_54xm_sfp51", as5916_54xm_sfp51 }, { "as5916_54xm_sfp52", as5916_54xm_sfp52 }, -{ "as5916_54xm_sfp53", as5916_54xm_sfp53 }, { "as5916_54xm_sfp54", as5916_54xm_sfp54 }, -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = I2C_ADDR_CPLD1 + i*2; - reg = 0x10+j; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-52(QSFP port) */ - cpld_addr = I2C_ADDR_CPLD2; - reg = 0x52; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)(status & 0x3F) << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - u8 tx_rx_regs[] = {0x14, 0x16, 0x18, 0x20, 0x22, 0x24, 0x30, 0x32, 0x34}; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as5916_54xm sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < ARRAY_SIZE(tx_rx_regs); j++) { - unsigned short cpld_addr = I2C_ADDR_CPLD1 + i*2; - - status = accton_i2c_cpld_read(cpld_addr, tx_rx_regs[j]); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, tx_rx_regs[i], status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - u8 tx_disable_regs[] = {0x20, 0x22, 0x24}; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = I2C_ADDR_CPLD1; - cpld_reg = tx_disable_regs[data->port / 8]; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = I2C_ADDR_CPLD2; - cpld_reg = tx_disable_regs[(data->port - 24) / 8]; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = accton_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - accton_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as5916_54xm_sfp1 && dev_id->driver_data <= as5916_54xm_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* as5916_54xm_sfp49 ~ as5916_54xm_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5916_54xm_sfp driver"); -MODULE_LICENSE("GPL"); - -late_initcall(sfp_init); -module_exit(sfp_exit); - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/sfpi.c index 965c08d4..26939c81 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/sfpi.c @@ -24,29 +24,21 @@ * ***********************************************************/ #include +#include #include -#include "platform_lib.h" - +#include "x86_64_accton_as5916_54xm_int.h" #include "x86_64_accton_as5916_54xm_log.h" -#define NUM_OF_SFP_PORT 54 -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_BUS_INDEX(port) ((port <48)? (port+41):(port-23)) +#define PORT_BUS_INDEX(port) ((port <48)? (port+41):(port-23)) -static char* -sfp_get_port_path_addr(int port, int addr, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", - FRONT_PORT_BUS_INDEX(port), addr, node_name); - return sfp_node_path; -} - -static char* -sfp_get_port_path(int port, char *node_name) -{ - return sfp_get_port_path_addr(port, 50, node_name); -} +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD1 "/sys/bus/i2c/devices/11-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/12-0062/module_rx_los_all" /************************************************************ * @@ -67,8 +59,8 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) * Ports {0, 54} */ int p; - - for(p = 0; p < NUM_OF_SFP_PORT; p++) { + + for(p = 0; p < 54; p++) { AIM_BITMAP_SET(bmap, p); } @@ -84,9 +76,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char *path = sfp_get_port_path(port, "sfp_is_present"); + int bus, addr; - if (onlp_file_read_int(&present, path) < 0) { + addr = (port < 24) ? 60 : 62; + bus = (addr == 60) ? 11 : 12; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -97,33 +92,45 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char* path; + uint32_t bytes[7], *ptr = NULL; FILE* fp; + int addr; - AIM_BITMAP_CLR_ALL(dst); + ptr = bytes; - path = sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); + for (addr = 60; addr <= 62; addr+=2) { + /* Read present status of port 0~53 */ + int count = 0; + char file[64] = {0}; + int bus = (addr == 60) ? 11 : 12; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + if (addr == 60) { /* CPLD1 */ + count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + else { /* CPLD2 */ + count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + + ptr += count; } /* Mask out non-existant QSFP ports */ @@ -150,34 +157,40 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[6]; - char* path; + uint32_t *ptr = bytes; FILE* fp; - path = sfp_get_port_path(0, "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 60; addr <= 62; addr+=2) { + if (addr == 60) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; - for(i = 5; i >= 0; i--) { + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } @@ -194,32 +207,51 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom"); - memset(data, 0, 256); + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } - if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); return ONLP_STATUS_E_INTERNAL; } @@ -231,13 +263,18 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 11 : 12; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - char* path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_write_integer(path, value) != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -259,16 +296,20 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; - char* path = NULL; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 11 : 12; switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - path = sfp_get_port_path(port, "sfp_rx_los"); - - if (onlp_file_read_int(value, path) < 0) { - AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } else { @@ -279,9 +320,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - path = sfp_get_port_path(port, "sfp_tx_fault"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -293,9 +332,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - path = sfp_get_port_path(port, "sfp_tx_disable"); - - if (onlp_file_read_int(value, path) < 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -312,12 +349,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) return rv; } - int onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/platform-config/r0/src/python/x86_64_accton_as5916_54xm_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/platform-config/r0/src/python/x86_64_accton_as5916_54xm_r0/__init__.py index 454c3122..11dd6fed 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/platform-config/r0/src/python/x86_64_accton_as5916_54xm_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/platform-config/r0/src/python/x86_64_accton_as5916_54xm_r0/__init__.py @@ -8,9 +8,9 @@ class OnlPlatform_x86_64_accton_as5916_54xm_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5916.54" def baseconfig(self): - self.insmod("accton_i2c_cpld") + self.insmod('optoe') self.insmod("ym2651y") - for m in [ "sfp", "psu", "fan", "leds" ]: + for m in [ "cpld", "psu", "fan", "leds" ]: self.insmod("x86-64-accton-as5916-54xm-%s" % m) ########### initialize I2C bus 0 ########### @@ -36,8 +36,8 @@ class OnlPlatform_x86_64_accton_as5916_54xm_r0(OnlPlatformAccton, ('lm75', 0x4b, 10), # initialize CPLDs - ('accton_i2c_cpld', 0x60, 11), - ('accton_i2c_cpld', 0x62, 12), + ('as5916_54xm_cpld1', 0x60, 11), + ('as5916_54xm_cpld2', 0x62, 12), ] ) @@ -65,8 +65,8 @@ class OnlPlatform_x86_64_accton_as5916_54xm_r0(OnlPlatformAccton, ) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5916_54xm_sfp%d' % port, 0x50, port-24) - + self.new_i2c_device('optoe1', 0x50, port-24) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port-24), shell=True) ########### initialize I2C bus 1 ########### @@ -85,8 +85,8 @@ class OnlPlatform_x86_64_accton_as5916_54xm_r0(OnlPlatformAccton, # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5916_54xm_sfp%d' % port, 0x50, port+40) - self.new_i2c_device('as5916_54xm_sfp%d' % port, 0x51, port+40) + self.new_i2c_device('optoe2', 0x50, port+40) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+40), shell=True) return True From c0423e08ed48111d3b576a0dc225849f33eb6d0f Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Wed, 28 Mar 2018 16:57:10 +0800 Subject: [PATCH 204/244] [as7512-32x] Add support for OOM --- .../builds/x86-64-accton-as7512-32x-cpld.c | 593 ++++++++++++++++++ .../builds/x86-64-accton-as7512-32x-fan.c | 19 +- .../builds/x86-64-accton-as7512-32x-leds.c | 13 +- .../builds/x86-64-accton-as7512-32x-psu.c | 21 +- .../builds/x86-64-accton-as7512-32x-sfp.c | 356 ----------- .../onlp/builds/src/module/src/sfpi.c | 96 ++- .../x86_64_accton_as7512_32x_r0/__init__.py | 18 +- 7 files changed, 657 insertions(+), 459 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-cpld.c new file mode 100644 index 00000000..bc105f3d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-cpld.c @@ -0,0 +1,593 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as7512_32x CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as7512_32x_cpld1, + as7512_32x_cpld2, + as7512_32x_cpld3 +}; + +struct as7512_32x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as7512_32x_cpld_id[] = { + { "as7512_32x_cpld1", as7512_32x_cpld1 }, + { "as7512_32x_cpld2", as7512_32x_cpld2 }, + { "as7512_32x_cpld3", as7512_32x_cpld3 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as7512_32x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as7512_32x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7512_32x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7512_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); + +static struct attribute *as7512_32x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + NULL +}; + +static const struct attribute_group as7512_32x_cpld1_group = { + .attrs = as7512_32x_cpld1_attributes, +}; + +static struct attribute *as7512_32x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7512_32x_cpld2_group = { + .attrs = as7512_32x_cpld2_attributes, +}; + +static struct attribute *as7512_32x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7512_32x_cpld3_group = { + .attrs = as7512_32x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[4] = {0}; + u8 regs[] = {0x30, 0x31, 0x32, 0x33}; + struct i2c_client *client = to_i2c_client(dev); + struct as7512_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7512_32x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as7512_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x31; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x33; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_32) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as7512_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7512_32x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7512_32x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as7512_32x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7512_32x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as7512_32x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as7512_32x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as7512_32x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as7512_32x_cpld1: + group = &as7512_32x_cpld1_group; + break; + case as7512_32x_cpld2: + group = &as7512_32x_cpld2_group; + break; + case as7512_32x_cpld3: + group = &as7512_32x_cpld3_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as7512_32x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as7512_32x_cpld_remove(struct i2c_client *client) +{ + struct as7512_32x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as7512_32x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as7512_32x_cpld1: + group = &as7512_32x_cpld1_group; + break; + case as7512_32x_cpld2: + group = &as7512_32x_cpld2_group; + break; + case as7512_32x_cpld3: + group = &as7512_32x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as7512_32x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7512_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as7512_32x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7512_32x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7512_32x_cpld_read); + +int as7512_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7512_32x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7512_32x_cpld_write); + +static struct i2c_driver as7512_32x_cpld_driver = { + .driver = { + .name = "as7512_32x_cpld", + .owner = THIS_MODULE, + }, + .probe = as7512_32x_cpld_probe, + .remove = as7512_32x_cpld_remove, + .id_table = as7512_32x_cpld_id, +}; + +static int __init as7512_32x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7512_32x_cpld_driver); +} + +static void __exit as7512_32x_cpld_exit(void) +{ + i2c_del_driver(&as7512_32x_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as7512_32x_cpld_init); +module_exit(as7512_32x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-fan.c index 6dfa74f8..cfc9630f 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-fan.c @@ -36,8 +36,6 @@ static struct as7512_32x_fan_data *as7512_32x_fan_update_device(struct device *d static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /* fan related data, the index should match sysfs_fan_attributes */ @@ -487,24 +485,9 @@ static struct i2c_driver as7512_32x_fan_driver = { .address_list = normal_i2c, }; -static int __init as7512_32x_fan_init(void) -{ - extern int platform_accton_as7512_32x(void); - if (!platform_accton_as7512_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7512_32x_fan_driver); -} - -static void __exit as7512_32x_fan_exit(void) -{ - i2c_del_driver(&as7512_32x_fan_driver); -} +module_i2c_driver(as7512_32x_fan_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as7512_32x_fan driver"); MODULE_LICENSE("GPL"); -module_init(as7512_32x_fan_init); -module_exit(as7512_32x_fan_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-leds.c index 3dc5def5..ee771701 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-leds.c @@ -30,8 +30,8 @@ #include #include -extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as7512_32x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as7512_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); #define DRVNAME "as7512_32x_led" #define NUM_OF_LED_REG 5 @@ -191,12 +191,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as7512_32x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as7512_32x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as7512_32x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as7512_32x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as7512_32x_led_update(void) @@ -457,11 +457,6 @@ static int __init accton_as7512_32x_led_init(void) { int ret; - extern int platform_accton_as7512_32x(void); - if (!platform_accton_as7512_32x()) { - return -ENODEV; - } - ret = platform_driver_register(&accton_as7512_32x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-psu.c index 3ab19698..3e4e4608 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-psu.c @@ -36,7 +36,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as7512_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as7512_32x_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -238,7 +238,7 @@ static struct as7512_32x_psu_data *as7512_32x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as7512_32x update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as7512_32x_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); @@ -276,24 +276,9 @@ exit: return data; } -static int __init as7512_32x_psu_init(void) -{ - extern int platform_accton_as7512_32x(void); - if (!platform_accton_as7512_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7512_32x_psu_driver); -} - -static void __exit as7512_32x_psu_exit(void) -{ - i2c_del_driver(&as7512_32x_psu_driver); -} +module_i2c_driver(as7512_32x_psu_driver); MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as7512_32x_psu driver"); MODULE_LICENSE("GPL"); -module_init(as7512_32x_psu_init); -module_exit(as7512_32x_psu_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-sfp.c deleted file mode 100644 index f7560fb6..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/modules/builds/x86-64-accton-as7512-32x-sfp.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * An hwmon driver for accton as7512_32x sfp - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BIT_INDEX(i) (1UL << (i)) - - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* Each client has this additional data - */ -struct as7512_32x_sfp_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - int port; /* Front port index */ - char eeprom[256]; /* eeprom data */ - u32 is_present; /* present status */ -}; - -static struct as7512_32x_sfp_data *as7512_32x_sfp_update_device(struct device *dev); -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da,char *buf); -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum as7512_32x_sfp_sysfs_attributes { - SFP_PORT_NUMBER, - SFP_IS_PRESENT, - SFP_IS_PRESENT_ALL, - SFP_EEPROM -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, SFP_IS_PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, SFP_IS_PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); - -static struct attribute *as7512_32x_sfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_eeprom.dev_attr.attr, - NULL -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7512_32x_sfp_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->port+1); -} - -/* Error-check the CPLD read results. */ -#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ -do { \ - _rv = (_read_expr); \ - if(_rv < 0) { \ - return sprintf(_buf, "READ ERROR\n"); \ - } \ - if(_invert) { \ - _rv = ~_rv; \ - } \ - _rv &= 0xFF; \ -} while(0) - -static ssize_t show_present(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if(attr->index == SFP_IS_PRESENT_ALL) { - int values[4]; - /* - * Report the SFP_PRESENCE status for all ports. - */ - - /* SFP_PRESENT Ports 1-8 */ - VALIDATED_READ(buf, values[0], accton_i2c_cpld_read(0x60, 0x30), 1); - /* SFP_PRESENT Ports 9-16 */ - VALIDATED_READ(buf, values[1], accton_i2c_cpld_read(0x60, 0x31), 1); - /* SFP_PRESENT Ports 17-24 */ - VALIDATED_READ(buf, values[2], accton_i2c_cpld_read(0x60, 0x32), 1); - /* SFP_PRESENT Ports 25-32 */ - VALIDATED_READ(buf, values[3], accton_i2c_cpld_read(0x60, 0x33), 1); - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); - } - else { /* SFP_IS_PRESENT */ - struct as7512_32x_sfp_data *data = as7512_32x_sfp_update_device(dev); - - if (!data->valid) { - return -EIO; - } - - return sprintf(buf, "%d\n", data->is_present); - } -} - -static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct as7512_32x_sfp_data *data = as7512_32x_sfp_update_device(dev); - - if (!data->valid) { - return 0; - } - - if (!data->is_present) { - return 0; - } - - memcpy(buf, data->eeprom, sizeof(data->eeprom)); - - return sizeof(data->eeprom); -} - -static const struct attribute_group as7512_32x_sfp_group = { - .attrs = as7512_32x_sfp_attributes, -}; - -static int as7512_32x_sfp_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as7512_32x_sfp_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as7512_32x_sfp_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7512_32x_sfp_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sfp '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7512_32x_sfp_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as7512_32x_sfp_remove(struct i2c_client *client) -{ - struct as7512_32x_sfp_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7512_32x_sfp_group); - kfree(data); - - return 0; -} - -enum port_numbers { -as7512_32x_sfp1, as7512_32x_sfp2, as7512_32x_sfp3, as7512_32x_sfp4, -as7512_32x_sfp5, as7512_32x_sfp6, as7512_32x_sfp7, as7512_32x_sfp8, -as7512_32x_sfp9, as7512_32x_sfp10,as7512_32x_sfp11,as7512_32x_sfp12, -as7512_32x_sfp13,as7512_32x_sfp14,as7512_32x_sfp15,as7512_32x_sfp16, -as7512_32x_sfp17,as7512_32x_sfp18,as7512_32x_sfp19,as7512_32x_sfp20, -as7512_32x_sfp21,as7512_32x_sfp22,as7512_32x_sfp23,as7512_32x_sfp24, -as7512_32x_sfp25,as7512_32x_sfp26,as7512_32x_sfp27,as7512_32x_sfp28, -as7512_32x_sfp29,as7512_32x_sfp30,as7512_32x_sfp31,as7512_32x_sfp32 -}; - -static const struct i2c_device_id as7512_32x_sfp_id[] = { -{ "as7512_32x_sfp1", as7512_32x_sfp1 }, { "as7512_32x_sfp2", as7512_32x_sfp2 }, -{ "as7512_32x_sfp3", as7512_32x_sfp3 }, { "as7512_32x_sfp4", as7512_32x_sfp4 }, -{ "as7512_32x_sfp5", as7512_32x_sfp5 }, { "as7512_32x_sfp6", as7512_32x_sfp6 }, -{ "as7512_32x_sfp7", as7512_32x_sfp7 }, { "as7512_32x_sfp8", as7512_32x_sfp8 }, -{ "as7512_32x_sfp9", as7512_32x_sfp9 }, { "as7512_32x_sfp10", as7512_32x_sfp10 }, -{ "as7512_32x_sfp11", as7512_32x_sfp11 }, { "as7512_32x_sfp12", as7512_32x_sfp12 }, -{ "as7512_32x_sfp13", as7512_32x_sfp13 }, { "as7512_32x_sfp14", as7512_32x_sfp14 }, -{ "as7512_32x_sfp15", as7512_32x_sfp15 }, { "as7512_32x_sfp16", as7512_32x_sfp16 }, -{ "as7512_32x_sfp17", as7512_32x_sfp17 }, { "as7512_32x_sfp18", as7512_32x_sfp18 }, -{ "as7512_32x_sfp19", as7512_32x_sfp19 }, { "as7512_32x_sfp20", as7512_32x_sfp20 }, -{ "as7512_32x_sfp21", as7512_32x_sfp21 }, { "as7512_32x_sfp22", as7512_32x_sfp22 }, -{ "as7512_32x_sfp23", as7512_32x_sfp23 }, { "as7512_32x_sfp24", as7512_32x_sfp24 }, -{ "as7512_32x_sfp25", as7512_32x_sfp25 }, { "as7512_32x_sfp26", as7512_32x_sfp26 }, -{ "as7512_32x_sfp27", as7512_32x_sfp27 }, { "as7512_32x_sfp28", as7512_32x_sfp28 }, -{ "as7512_32x_sfp29", as7512_32x_sfp29 }, { "as7512_32x_sfp30", as7512_32x_sfp30 }, -{ "as7512_32x_sfp31", as7512_32x_sfp31 }, { "as7512_32x_sfp32", as7512_32x_sfp32 }, -{} -}; -MODULE_DEVICE_TABLE(i2c, as7512_32x_sfp_id); - -static struct i2c_driver as7512_32x_sfp_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as7512_32x_sfp", - }, - .probe = as7512_32x_sfp_probe, - .remove = as7512_32x_sfp_remove, - .id_table = as7512_32x_sfp_id, - .address_list = normal_i2c, -}; - -static int as7512_32x_sfp_read_block(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ - int result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - - if (unlikely(result < 0)) - goto abort; - if (unlikely(result != data_len)) { - result = -EIO; - goto abort; - } - - result = 0; - -abort: - return result; -} - -static struct as7512_32x_sfp_data *as7512_32x_sfp_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7512_32x_sfp_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status = -1; - int i = 0; - u8 cpld_reg = 0x30 + (data->port/8); - - data->valid = 0; - - /* Read present status of the specified port number */ - data->is_present = 0; - status = accton_i2c_cpld_read(0x60, cpld_reg); - - if (status < 0) { - dev_dbg(&client->dev, "cpld(0x60) reg(0x%x) err %d\n", cpld_reg, status); - goto exit; - } - - data->is_present = (status & (1 << (data->port % 8))) ? 0 : 1; - - /* Read eeprom data based on port number */ - memset(data->eeprom, 0, sizeof(data->eeprom)); - - /* Check if the port is present */ - if (data->is_present) { - /* read eeprom */ - for (i = 0; i < sizeof(data->eeprom)/I2C_SMBUS_BLOCK_MAX; i++) { - status = as7512_32x_sfp_read_block(client, i*I2C_SMBUS_BLOCK_MAX, - data->eeprom+(i*I2C_SMBUS_BLOCK_MAX), - I2C_SMBUS_BLOCK_MAX); - if (status < 0) { - dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", data->port); - goto exit; - } - } - } - - data->last_updated = jiffies; - data->valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} - -static int __init as7512_32x_sfp_init(void) -{ - extern int platform_accton_as7512_32x(void); - if (!platform_accton_as7512_32x()) { - return -ENODEV; - } - - return i2c_add_driver(&as7512_32x_sfp_driver); -} - -static void __exit as7512_32x_sfp_exit(void) -{ - i2c_del_driver(&as7512_32x_sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as7512_32x_sfp driver"); -MODULE_LICENSE("GPL"); - -module_init(as7512_32x_sfp_init); -module_exit(as7512_32x_sfp_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/sfpi.c index c478ecaa..b076631c 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/onlp/builds/src/module/src/sfpi.c @@ -25,43 +25,16 @@ ***********************************************************/ #include -#include /* For O_RDWR && open */ -#include -#include -#include -#include - +#include +#include #include "platform_lib.h" -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; -#define FRONT_PORT_TO_CPLD_MUX_INDEX(port) (port+18) -static int -as7512_32x_sfp_node_read_int(char *node_path, int *value, int data_len) -{ - int ret = 0; - char buf[8]; - *value = 0; +#define PORT_BUS_INDEX(port) (port+18) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" - ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); - - if (ret == 0) { - *value = atoi(buf); - } - - return ret; -} - -static char* -as7512_32x_sfp_get_port_path(int port, char *node_name) -{ - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", - FRONT_PORT_TO_CPLD_MUX_INDEX(port), - node_name); - - return sfp_node_path; -} +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/4-0060/module_present_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/4-0060/module_present_all" /************************************************************ * @@ -100,13 +73,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - char* path = as7512_32x_sfp_get_port_path(port, "sfp_is_present"); - if (as7512_32x_sfp_node_read_int(path, &present, 0) != 0) { + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } - + return present; } @@ -114,12 +86,10 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; - char* path; FILE* fp; - path = as7512_32x_sfp_get_port_path(0, "sfp_is_present_all"); - fp = fopen(path, "r"); - + fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); + if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; @@ -154,33 +124,59 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_OK; } -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - return ONLP_STATUS_OK; -} - int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { - char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom"); - /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ + int size = 0; memset(data, 0, 256); - - if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + return ONLP_STATUS_OK; } +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = PORT_BUS_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + int onlp_sfpi_denit(void) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/platform-config/r0/src/python/x86_64_accton_as7512_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/platform-config/r0/src/python/x86_64_accton_as7512_32x_r0/__init__.py index e6b0e804..3cadb818 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/platform-config/r0/src/python/x86_64_accton_as7512_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7512-32x/platform-config/r0/src/python/x86_64_accton_as7512_32x_r0/__init__.py @@ -8,10 +8,10 @@ class OnlPlatform_x86_64_accton_as7512_32x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".7512.32" def baseconfig(self): - + self.insmod('optoe') self.insmod("ym2651y") - self.insmod("accton_i2c_cpld") - self.insmod_platform() + for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + self.insmod("x86-64-accton-as7512-32x-%s" % m) ########### initialize I2C bus 0 ########### # initialize multiplexer (PCA9548) @@ -31,9 +31,9 @@ class OnlPlatform_x86_64_accton_as7512_32x_r0(OnlPlatformAccton, # initialize CPLD self.new_i2c_devices( [ - ('accton_i2c_cpld', 0x60, 4), - ('accton_i2c_cpld', 0x62, 5), - ('accton_i2c_cpld', 0x64, 6), + ('as7512_32x_cpld1', 0x60, 4), + ('as7512_32x_cpld2', 0x62, 5), + ('as7512_32x_cpld3', 0x64, 6), ] ) ########### initialize I2C bus 1 ########### @@ -65,7 +65,9 @@ class OnlPlatform_x86_64_accton_as7512_32x_r0(OnlPlatformAccton, ) # initialize QSFP port 1~32 - for p in range(1,33): - self.new_i2c_device('as7512_32x_sfp%d' % p, 0x50, 17+p) + # initialize QSFP devices + for port in range(1, 33): + self.new_i2c_device('optoe1', 0x50, port+17) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+17), shell=True) return True From 9a11cd02818abd994fc671b6bdd5c414bca9dc20 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Thu, 29 Mar 2018 11:41:07 +0800 Subject: [PATCH 205/244] [as7816-64x] Replace psu driver with at24 --- .../builds/x86-64-accton-as7816-64x-cpld1.c | 62 +++++ .../builds/x86-64-accton-as7816-64x-psu.c | 239 ------------------ .../onlp/builds/src/module/src/platform_lib.c | 5 +- .../onlp/builds/src/module/src/platform_lib.h | 7 +- .../onlp/builds/src/module/src/psui.c | 26 +- .../x86_64_accton_as7816_64x_r0/__init__.py | 6 +- 6 files changed, 75 insertions(+), 270 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c index 1dcd3395..16474804 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-cpld1.c @@ -45,6 +45,8 @@ struct cpld_client_node { #define I2C_RW_RETRY_COUNT 10 #define I2C_RW_RETRY_INTERVAL 60 /* ms */ +static ssize_t show_psu(struct device *dev, struct device_attribute *da, + char *buf); static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_present_all(struct device *dev, struct device_attribute *da, @@ -66,6 +68,8 @@ struct as7816_64x_cpld_data { static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; #define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define PSU_PRESENT_ATTR_ID(index) PSU##index##_PRESENT +#define PSU_POWERGOOD_ATTR_ID(index) PSU##index##_POWER_GOOD enum as7816_64x_cpld_sysfs_attributes { CPLD_VERSION, @@ -136,6 +140,12 @@ enum as7816_64x_cpld_sysfs_attributes { TRANSCEIVER_PRESENT_ATTR_ID(62), TRANSCEIVER_PRESENT_ATTR_ID(63), TRANSCEIVER_PRESENT_ATTR_ID(64), + + /* psu attributes */ + PSU_PRESENT_ATTR_ID(1), + PSU_PRESENT_ATTR_ID(2), + PSU_POWERGOOD_ATTR_ID(1), + PSU_POWERGOOD_ATTR_ID(2), }; /* sysfs attributes for hwmon @@ -146,6 +156,14 @@ enum as7816_64x_cpld_sysfs_attributes { static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_present, NULL, MODULE_PRESENT_##index) #define DECLARE_TRANSCEIVER_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr +/* psu attributes */ +#define DECLARE_PSU_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(psu##index##_present, S_IRUGO, show_psu, NULL, PSU##index##_PRESENT); \ + static SENSOR_DEVICE_ATTR(psu##index##_power_good, S_IRUGO, show_psu, NULL, PSU##index##_POWER_GOOD); +#define DECLARE_PSU_ATTR(index) \ + &sensor_dev_attr_psu##index##_present.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_power_good.dev_attr.attr + static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); /* transceiver attributes */ @@ -215,6 +233,10 @@ DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(62); DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(63); DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(64); +/* psu attributes*/ +DECLARE_PSU_SENSOR_DEVICE_ATTR(1); +DECLARE_PSU_SENSOR_DEVICE_ATTR(2); + static struct attribute *as7816_64x_cpld_attributes[] = { &sensor_dev_attr_version.dev_attr.attr, &sensor_dev_attr_access.dev_attr.attr, @@ -284,6 +306,10 @@ static struct attribute *as7816_64x_cpld_attributes[] = { DECLARE_TRANSCEIVER_ATTR(62), DECLARE_TRANSCEIVER_ATTR(63), DECLARE_TRANSCEIVER_ATTR(64), + + /* psu attributes*/ + DECLARE_PSU_ATTR(1), + DECLARE_PSU_ATTR(2), NULL }; @@ -291,6 +317,42 @@ static const struct attribute_group as7816_64x_cpld_group = { .attrs = as7816_64x_cpld_attributes, }; +static ssize_t show_psu(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 as7816_64x_cpld_data *data = i2c_get_clientdata(client); + int status = 0, value = 0; + + mutex_lock(&data->update_lock); + status = as7816_64x_cpld_read_internal(client, 0x03); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + switch (attr->index) { + case PSU1_PRESENT: + case PSU2_PRESENT: + value = !(status & BIT(attr->index - PSU1_PRESENT)); + break; + case PSU1_POWER_GOOD: + case PSU2_POWER_GOOD: + value = !!(status & BIT(attr->index - PSU1_POWER_GOOD + 2)); + break; + default: + return 0; + } + + + return sprintf(buf, "%d\n", value); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + static ssize_t show_present_all(struct device *dev, struct device_attribute *da, char *buf) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c deleted file mode 100644 index a2703aa9..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/modules/builds/x86-64-accton-as7816-64x-psu.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * An hwmon driver for accton as7816_64x Power Module - * - * Copyright (C) 2014 Accton Technology Corporation. - * Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PSU_STATUS_I2C_ADDR 0x60 -#define PSU_STATUS_I2C_REG_OFFSET 0x03 - -#define IS_POWER_GOOD(id, value) (!!(value & BIT(2+id))) -#define IS_PRESENT(id, value) (!(value & BIT(id))) - -static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); -static struct as7816_64x_psu_data *as7816_64x_psu_update_device(struct device *dev); -extern int as7816_64x_cpld_read (unsigned short cpld_addr, u8 reg); - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -/* Each client has this additional data - */ -struct as7816_64x_psu_data { - struct device *hwmon_dev; - struct mutex update_lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 index; /* PSU index */ - u8 status; /* Status(present/power_good) register read from CPLD */ -}; - -enum as7816_64x_psu_sysfs_attributes { - PSU_PRESENT, - PSU_POWER_GOOD -}; - -/* sysfs attributes for hwmon - */ -static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); -static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); - -static struct attribute *as7816_64x_psu_attributes[] = { - &sensor_dev_attr_psu_present.dev_attr.attr, - &sensor_dev_attr_psu_power_good.dev_attr.attr, - NULL -}; - -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct as7816_64x_psu_data *data = as7816_64x_psu_update_device(dev); - u8 status = 0; - - if (!data->valid) { - return -EIO; - } - - if (attr->index == PSU_PRESENT) { - status = IS_PRESENT(data->index, data->status); - } - else { /* PSU_POWER_GOOD */ - status = IS_POWER_GOOD(data->index, data->status); - } - - return sprintf(buf, "%d\n", status); -} - -static const struct attribute_group as7816_64x_psu_group = { - .attrs = as7816_64x_psu_attributes, -}; - -static int as7816_64x_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct as7816_64x_psu_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as7816_64x_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->update_lock); - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as7816_64x_psu_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - dev_info(&client->dev, "%s: psu '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as7816_64x_psu_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as7816_64x_psu_remove(struct i2c_client *client) -{ - struct as7816_64x_psu_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as7816_64x_psu_group); - kfree(data); - - return 0; -} - -enum psu_index -{ - as7816_64x_psu1, - as7816_64x_psu2 -}; - -static const struct i2c_device_id as7816_64x_psu_id[] = { - { "as7816_64x_psu1", as7816_64x_psu1 }, - { "as7816_64x_psu2", as7816_64x_psu2 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as7816_64x_psu_id); - -static struct i2c_driver as7816_64x_psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as7816_64x_psu", - }, - .probe = as7816_64x_psu_probe, - .remove = as7816_64x_psu_remove, - .id_table = as7816_64x_psu_id, - .address_list = normal_i2c, -}; - -static struct as7816_64x_psu_data *as7816_64x_psu_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct as7816_64x_psu_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) - || !data->valid) { - int status; - - data->valid = 0; - dev_dbg(&client->dev, "Starting as7816_64x update\n"); - - /* Read psu status */ - status = as7816_64x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); - - if (status < 0) { - dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); - goto exit; - } - else { - data->status = status; - } - - data->last_updated = jiffies; - data->valid = 1; - } - -exit: - mutex_unlock(&data->update_lock); - - return data; -} - -static int __init as7816_64x_psu_init(void) -{ - return i2c_add_driver(&as7816_64x_psu_driver); -} - -static void __exit as7816_64x_psu_exit(void) -{ - i2c_del_driver(&as7816_64x_psu_driver); -} - -module_init(as7816_64x_psu_init); -module_exit(as7816_64x_psu_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as7816_64x_psu driver"); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c index d589fa93..dffc3c46 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.c @@ -68,9 +68,8 @@ psu_type_t psu_type_get(int id, char* modelname, int modelname_len) /* Check if the psu is power good */ - prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; - if (onlp_file_read_int(&value, "%s%s", prefix, "psu_power_good") < 0) { - AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, "psu_power_good"); + if (onlp_file_read_int(&value, PSU_POWERGOOD_FORMAT, id) < 0) { + AIM_LOG_ERROR("Unable to read present status from PSU(%d)\r\n", index); return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h index 54d03dd4..3a37a536 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/platform_lib.h @@ -42,11 +42,8 @@ #define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node #define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node -#define PSU1_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/10-0053/" -#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/9-0050/" - -#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node -#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node +#define PSU_PRESENT_FORMAT "/sys/bus/i2c/devices/19-0060/psu%d_present" +#define PSU_POWERGOOD_FORMAT "/sys/bus/i2c/devices/19-0060/psu%d_power_good" #define FAN_BOARD_PATH "/sys/bus/i2c/devices/17-0068/" #define FAN_NODE(node) FAN_BOARD_PATH#node diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c index a80b5627..6e347b6e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/onlp/builds/src/module/src/psui.c @@ -37,21 +37,6 @@ } \ } while(0) -static int -psu_status_info_get(int id, char *node, int *value) -{ - char *prefix = NULL; - *value = 0; - - prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; - if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) { - AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node); - return ONLP_STATUS_E_INTERNAL; - } - - return 0; -} - int onlp_psui_init(void) { @@ -124,9 +109,9 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) memset(info, 0, sizeof(onlp_psu_info_t)); *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - /* Get the present state */ - if (psu_status_info_get(index, "psu_present", &val) != 0) { - printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + if (onlp_file_read_int(&val, PSU_PRESENT_FORMAT, index) < 0) { + AIM_LOG_ERROR("Unable to read present status from PSU(%d)\r\n", index); + return ONLP_STATUS_E_INTERNAL; } if (val != PSU_STATUS_PRESENT) { @@ -137,8 +122,9 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) /* Get power good status */ - if (psu_status_info_get(index, "psu_power_good", &val) != 0) { - printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + if (onlp_file_read_int(&val, PSU_POWERGOOD_FORMAT, index) < 0) { + AIM_LOG_ERROR("Unable to read power status from PSU(%d)\r\n", index); + return ONLP_STATUS_E_INTERNAL; } if (val != PSU_STATUS_POWER_GOOD) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py index 0f79ec54..163f3991 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7816-64x/platform-config/r0/src/python/x86_64_accton_as7816_64x_r0/__init__.py @@ -11,7 +11,7 @@ class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton, self.insmod('optoe') self.insmod('ym2651y') self.insmod('accton_i2c_cpld') - for m in [ 'fan', 'cpld1', 'psu', 'leds' ]: + for m in [ 'fan', 'cpld1', 'leds' ]: self.insmod("x86-64-accton-as7816-64x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -25,11 +25,11 @@ class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton, ('pca9548', 0x73, 1), # initiate PSU-1 - ('as7816_64x_psu1', 0x53, 10), + ('24c02', 0x53, 10), ('ym2851', 0x5b, 10), # initiate PSU-2 - ('as7816_64x_psu2', 0x50, 9), + ('24c02', 0x50, 9), ('ym2851', 0x58, 9), # initiate chassis fan From be9cdca9d586075b055183e1b8e5b6ebe4241729 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 29 Mar 2018 18:18:27 +0000 Subject: [PATCH 206/244] Manufecturer field missing from JSON output. --- packages/base/any/onlp/src/onlplib/module/src/onie.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/base/any/onlp/src/onlplib/module/src/onie.c b/packages/base/any/onlp/src/onlplib/module/src/onie.c index 2060e2e3..62663ce9 100644 --- a/packages/base/any/onlp/src/onlplib/module/src/onie.c +++ b/packages/base/any/onlp/src/onlplib/module/src/onie.c @@ -111,7 +111,7 @@ decode_tlv__(onlp_onie_info_t* info, tlvinfo_tlv_t * tlv) } \ _info -> _member = aim_zmalloc(_tlv->length + 1); \ memcpy((void*) _info -> _member, _tlv->value, _tlv->length); \ - break; \ + break; \ } CASE_TLV_STRING(info, product_name, PRODUCT_NAME, tlv); @@ -425,6 +425,7 @@ onlp_onie_show_json(onlp_onie_info_t* info, aim_pvs_t* pvs) cJSON_AddStringToObject(cj, "MAC", mac); aim_free(mac); } + _S(Manufacturer, manufacturer); _S(Manufacture Date,manufacture_date); _S(Vendor,vendor); _S(Platform Name,platform_name); @@ -522,8 +523,3 @@ onlp_onie_read_json(onlp_onie_info_t* info, const char* fname) cJSON_Delete(cj); return 0; } - - - - - From c6d880505fb27338b799e3e0822c6978adcc2a47 Mon Sep 17 00:00:00 2001 From: Brandon Chuang Date: Fri, 30 Mar 2018 10:51:30 +0800 Subject: [PATCH 207/244] [as5916-54x] Add support for OOM --- .../builds/x86-64-accton-as5916-54x-cpld.c | 1098 ++++++++++++++ .../builds/x86-64-accton-as5916-54x-leds.c | 8 +- .../builds/x86-64-accton-as5916-54x-psu.c | 4 +- .../builds/x86-64-accton-as5916-54x-sfp.c | 1315 ----------------- .../onlp/builds/src/module/src/sfpi.c | 238 +-- .../x86_64_accton_as5916_54x_r1/__init__.py | 16 +- 6 files changed, 1267 insertions(+), 1412 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-cpld.c delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-cpld.c new file mode 100644 index 00000000..646cb025 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-cpld.c @@ -0,0 +1,1098 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as5916_54x_cpld1, + as5916_54x_cpld2 +}; + +struct as5916_54x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as5916_54x_cpld_id[] = { + { "as5916_54x_cpld1", as5916_54x_cpld1 }, + { "as5916_54x_cpld2", as5916_54x_cpld2 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as5916_54x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5916_54x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5916_54x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5916_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5916_54x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5916_54x_cpld1_group = { + .attrs = as5916_54x_cpld1_attributes, +}; + +static struct attribute *as5916_54x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5916_54x_cpld2_group = { + .attrs = as5916_54x_cpld2_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x10, 0x11, 0x12, 0x52}; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5916_54x_cpld1) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5916_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + if (data->type == as5916_54x_cpld1) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5916_54x_cpld2 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x30, 0x32, 0x34}; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5916_54x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as5916_54x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x52; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5916_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5916_54x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5916_54x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5916_54x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as5916_54x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5916_54x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as5916_54x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as5916_54x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as5916_54x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as5916_54x_cpld1: + group = &as5916_54x_cpld1_group; + break; + case as5916_54x_cpld2: + group = &as5916_54x_cpld2_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as5916_54x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as5916_54x_cpld_remove(struct i2c_client *client) +{ + struct as5916_54x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as5916_54x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5916_54x_cpld1: + group = &as5916_54x_cpld1_group; + break; + case as5916_54x_cpld2: + group = &as5916_54x_cpld2_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as5916_54x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5916_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5916_54x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5916_54x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5916_54x_cpld_read); + +int as5916_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5916_54x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5916_54x_cpld_write); + +static struct i2c_driver as5916_54x_cpld_driver = { + .driver = { + .name = "as5916_54x_cpld", + .owner = THIS_MODULE, + }, + .probe = as5916_54x_cpld_probe, + .remove = as5916_54x_cpld_remove, + .id_table = as5916_54x_cpld_id, +}; + +static int __init as5916_54x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5916_54x_cpld_driver); +} + +static void __exit as5916_54x_cpld_exit(void) +{ + i2c_del_driver(&as5916_54x_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_54x_cpld_init); +module_exit(as5916_54x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-leds.c index 7f55dae7..9f6be629 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-leds.c @@ -38,8 +38,8 @@ #define DEBUG_PRINT(fmt, args...) #endif -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5916_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5916_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); struct accton_as5916_54x_led_data { struct platform_device *pdev; @@ -157,12 +157,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5916_54x_led_read_value(u8 reg) { - return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); + return as5916_54x_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); } static int accton_as5916_54x_led_write_value(u8 reg, u8 value) { - return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); + return as5916_54x_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); } static void accton_as5916_54x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-psu.c index 4627df9c..e9d00dfb 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-psu.c @@ -37,7 +37,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5916_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5916_54x_cpld_read(unsigned short cpld_addr, u8 reg); /* Addresses scanned */ @@ -234,7 +234,7 @@ static struct as5916_54x_psu_data *as5916_54x_psu_update_device(struct device *d dev_dbg(&client->dev, "Starting as5916_54x update\n"); /* Read psu status */ - status = accton_i2c_cpld_read(0x60, 0x2); + status = as5916_54x_cpld_read(0x60, 0x2); if (status < 0) { dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-sfp.c deleted file mode 100644 index c924772b..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/modules/builds/x86-64-accton-as5916-54x-sfp.c +++ /dev/null @@ -1,1315 +0,0 @@ -/* - * SFP driver for accton as5916_54x sfp - * - * Copyright (C) Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "as5916_54x_sfp" /* Platform dependent */ - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(fmt, args...) \ - printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) -#else - #define DEBUG_PRINT(fmt, args...) -#endif - -#define NUM_OF_SFP_PORT 54 -#define EEPROM_NAME "sfp_eeprom" -#define EEPROM_SIZE 256 /* 256 byte eeprom */ -#define BIT_INDEX(i) (1ULL << (i)) -#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) -#define SFP_EEPROM_A2_I2C_ADDR (0xA2 >> 1) - -#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 -#define SFF8024_DEVICE_ID_SFP 0x3 -#define SFF8024_DEVICE_ID_QSFP 0xC -#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD -#define SFF8024_DEVICE_ID_QSFP28 0x11 - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 -#define SFF8472_10G_ETH_COMPLIANCE_ADDR 0x3 -#define SFF8472_10G_BASE_MASK 0xF0 - -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -/* Platform dependent +++ */ -#define I2C_ADDR_CPLD1 0x60 -#define I2C_ADDR_CPLD2 0x62 -/* Platform dependent --- */ - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, char *buf); -static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); -static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); -extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); - -enum sfp_sysfs_attributes { - PRESENT, - PRESENT_ALL, - PORT_NUMBER, - PORT_TYPE, - DDM_IMPLEMENTED, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - RX_LOS_ALL -}; - -/* SFP/QSFP common attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); -static SENSOR_DEVICE_ATTR(sfp_port_type, S_IRUGO, show_port_type, NULL, PORT_TYPE); -static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); -static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); -static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); - -/* QSFP attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); -static struct attribute *qsfp_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, - NULL -}; - -/* SFP msa attributes for sysfs */ -static SENSOR_DEVICE_ATTR(sfp_ddm_implemented, S_IRUGO, sfp_show_ddm_implemented, NULL, DDM_IMPLEMENTED); -static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); -static struct attribute *sfp_msa_attributes[] = { - &sensor_dev_attr_sfp_port_number.dev_attr.attr, - &sensor_dev_attr_sfp_port_type.dev_attr.attr, - &sensor_dev_attr_sfp_is_present.dev_attr.attr, - &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, - &sensor_dev_attr_sfp_ddm_implemented.dev_attr.attr, - &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los.dev_attr.attr, - &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, - &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, - NULL -}; - -/* SFP ddm attributes for sysfs */ -static struct attribute *sfp_ddm_attributes[] = { - NULL -}; - -/* Platform dependent +++ */ -#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) - -enum port_numbers { -as5916_54x_sfp1, as5916_54x_sfp2, as5916_54x_sfp3, as5916_54x_sfp4, as5916_54x_sfp5, as5916_54x_sfp6, as5916_54x_sfp7, as5916_54x_sfp8, -as5916_54x_sfp9, as5916_54x_sfp10, as5916_54x_sfp11, as5916_54x_sfp12, as5916_54x_sfp13, as5916_54x_sfp14, as5916_54x_sfp15, as5916_54x_sfp16, -as5916_54x_sfp17, as5916_54x_sfp18, as5916_54x_sfp19, as5916_54x_sfp20, as5916_54x_sfp21, as5916_54x_sfp22, as5916_54x_sfp23, as5916_54x_sfp24, -as5916_54x_sfp25, as5916_54x_sfp26, as5916_54x_sfp27, as5916_54x_sfp28, as5916_54x_sfp29, as5916_54x_sfp30, as5916_54x_sfp31, as5916_54x_sfp32, -as5916_54x_sfp33, as5916_54x_sfp34, as5916_54x_sfp35, as5916_54x_sfp36, as5916_54x_sfp37, as5916_54x_sfp38, as5916_54x_sfp39, as5916_54x_sfp40, -as5916_54x_sfp41, as5916_54x_sfp42, as5916_54x_sfp43, as5916_54x_sfp44, as5916_54x_sfp45, as5916_54x_sfp46, as5916_54x_sfp47, as5916_54x_sfp48, -as5916_54x_sfp49, as5916_54x_sfp50, as5916_54x_sfp51, as5916_54x_sfp52, as5916_54x_sfp53, as5916_54x_sfp54 -}; - -static const struct i2c_device_id sfp_device_id[] = { -{ "as5916_54x_sfp1", as5916_54x_sfp1 }, { "as5916_54x_sfp2", as5916_54x_sfp2 }, { "as5916_54x_sfp3", as5916_54x_sfp3 }, { "as5916_54x_sfp4", as5916_54x_sfp4 }, -{ "as5916_54x_sfp5", as5916_54x_sfp5 }, { "as5916_54x_sfp6", as5916_54x_sfp6 }, { "as5916_54x_sfp7", as5916_54x_sfp7 }, { "as5916_54x_sfp8", as5916_54x_sfp8 }, -{ "as5916_54x_sfp9", as5916_54x_sfp9 }, { "as5916_54x_sfp10", as5916_54x_sfp10 }, { "as5916_54x_sfp11", as5916_54x_sfp11 }, { "as5916_54x_sfp12", as5916_54x_sfp12 }, -{ "as5916_54x_sfp13", as5916_54x_sfp13 }, { "as5916_54x_sfp14", as5916_54x_sfp14 }, { "as5916_54x_sfp15", as5916_54x_sfp15 }, { "as5916_54x_sfp16", as5916_54x_sfp16 }, -{ "as5916_54x_sfp17", as5916_54x_sfp17 }, { "as5916_54x_sfp18", as5916_54x_sfp18 }, { "as5916_54x_sfp19", as5916_54x_sfp19 }, { "as5916_54x_sfp20", as5916_54x_sfp20 }, -{ "as5916_54x_sfp21", as5916_54x_sfp21 }, { "as5916_54x_sfp22", as5916_54x_sfp22 }, { "as5916_54x_sfp23", as5916_54x_sfp23 }, { "as5916_54x_sfp24", as5916_54x_sfp24 }, -{ "as5916_54x_sfp25", as5916_54x_sfp25 }, { "as5916_54x_sfp26", as5916_54x_sfp26 }, { "as5916_54x_sfp27", as5916_54x_sfp27 }, { "as5916_54x_sfp28", as5916_54x_sfp28 }, -{ "as5916_54x_sfp29", as5916_54x_sfp29 }, { "as5916_54x_sfp30", as5916_54x_sfp30 }, { "as5916_54x_sfp31", as5916_54x_sfp31 }, { "as5916_54x_sfp32", as5916_54x_sfp32 }, -{ "as5916_54x_sfp33", as5916_54x_sfp33 }, { "as5916_54x_sfp34", as5916_54x_sfp34 }, { "as5916_54x_sfp35", as5916_54x_sfp35 }, { "as5916_54x_sfp36", as5916_54x_sfp36 }, -{ "as5916_54x_sfp37", as5916_54x_sfp37 }, { "as5916_54x_sfp38", as5916_54x_sfp38 }, { "as5916_54x_sfp39", as5916_54x_sfp39 }, { "as5916_54x_sfp40", as5916_54x_sfp40 }, -{ "as5916_54x_sfp41", as5916_54x_sfp41 }, { "as5916_54x_sfp42", as5916_54x_sfp42 }, { "as5916_54x_sfp43", as5916_54x_sfp43 }, { "as5916_54x_sfp44", as5916_54x_sfp44 }, -{ "as5916_54x_sfp45", as5916_54x_sfp45 }, { "as5916_54x_sfp46", as5916_54x_sfp46 }, { "as5916_54x_sfp47", as5916_54x_sfp47 }, { "as5916_54x_sfp48", as5916_54x_sfp48 }, -{ "as5916_54x_sfp49", as5916_54x_sfp49 }, { "as5916_54x_sfp50", as5916_54x_sfp50 }, { "as5916_54x_sfp51", as5916_54x_sfp51 }, { "as5916_54x_sfp52", as5916_54x_sfp52 }, -{ "as5916_54x_sfp53", as5916_54x_sfp53 }, { "as5916_54x_sfp54", as5916_54x_sfp54 }, -{ /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, sfp_device_id); -/* Platform dependent --- */ - -/* - * list of valid port types - * note OOM_PORT_TYPE_NOT_PRESENT to indicate no - * module is present in this port - */ -typedef enum oom_driver_port_type_e { - OOM_DRIVER_PORT_TYPE_INVALID, - OOM_DRIVER_PORT_TYPE_NOT_PRESENT, - OOM_DRIVER_PORT_TYPE_SFP, - OOM_DRIVER_PORT_TYPE_SFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP, - OOM_DRIVER_PORT_TYPE_QSFP_PLUS, - OOM_DRIVER_PORT_TYPE_QSFP28 -} oom_driver_port_type_t; - -enum driver_type_e { - DRIVER_TYPE_SFP_MSA, - DRIVER_TYPE_SFP_DDM, - DRIVER_TYPE_QSFP -}; - -/* Each client has this additional data - */ -struct eeprom_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - struct bin_attribute bin; /* eeprom data */ -}; - -struct sfp_msa_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u64 status[6]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss - 3 => device id - 4 => 10G Ethernet Compliance Codes - to distinguish SFP or SFP+ - 5 => DIAGNOSTIC MONITORING TYPE */ - struct eeprom_data eeprom; -}; - -struct sfp_ddm_data { - struct eeprom_data eeprom; -}; - -struct qsfp_data { - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 status[3]; /* bit0:port0, bit1:port1 and so on */ - /* index 0 => tx_fail - 1 => tx_disable - 2 => rx_loss */ - - u8 device_id; - struct eeprom_data eeprom; -}; - -struct sfp_port_data { - struct mutex update_lock; - enum driver_type_e driver_type; - int port; /* CPLD port index */ - oom_driver_port_type_t port_type; - u64 present; /* present status, bit0:port0, bit1:port1 and so on */ - - struct sfp_msa_data *msa; - struct sfp_ddm_data *ddm; - struct qsfp_data *qsfp; - - struct i2c_client *client; -}; - -static ssize_t show_port_number(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); -} - -/* Platform dependent +++ */ -static struct sfp_port_data *sfp_update_present(struct i2c_client *client) -{ - int i = 0, j = 0, status = -1; - u8 reg; - unsigned short cpld_addr; - struct sfp_port_data *data = i2c_get_clientdata(client); - - DEBUG_PRINT("Starting sfp present status update"); - mutex_lock(&data->update_lock); - data->present = 0; - - /* Read present status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 3; j++) { - cpld_addr = I2C_ADDR_CPLD1 + i*2; - reg = 0x10+j; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - - DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); - data->present |= (u64)status << ((i*24) + (j%3)*8); - } - } - - /* Read present status of port 49-52(QSFP port) */ - cpld_addr = I2C_ADDR_CPLD2; - reg = 0x52; - status = accton_i2c_cpld_read(cpld_addr, reg); - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); - goto exit; - } - else { - data->present |= (u64)(status & 0x3F) << 48; - } - - DEBUG_PRINT("Present status = 0x%lx", data->present); -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static struct sfp_port_data* sfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i = 0, j = 0; - int status = -1; - u8 tx_rx_regs[] = {0x14, 0x16, 0x18, 0x20, 0x22, 0x24, 0x30, 0x32, 0x34}; - - if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { - return data; - } - - DEBUG_PRINT("Starting as5916_54x sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->msa->valid = 0; - memset(data->msa->status, 0, sizeof(data->msa->status)); - - /* Read status of port 1~48(SFP port) */ - for (i = 0; i < 2; i++) { - for (j = 0; j < ARRAY_SIZE(tx_rx_regs); j++) { - unsigned short cpld_addr = I2C_ADDR_CPLD1 + i*2; - - status = accton_i2c_cpld_read(cpld_addr, tx_rx_regs[j]); - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, tx_rx_regs[i], status); - goto exit; - } - - data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); - } - } - - data->msa->valid = 1; - data->msa->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - unsigned short cpld_addr = 0; - u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; - long disable; - int error; - u8 tx_disable_regs[] = {0x20, 0x22, 0x24}; - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_set_tx_disable(dev, da, buf, count); - } - - error = kstrtol(buf, 10, &disable); - if (error) { - return error; - } - - mutex_lock(&data->update_lock); - - if(data->port < 24) { - cpld_addr = I2C_ADDR_CPLD1; - cpld_reg = tx_disable_regs[data->port / 8]; - cpld_bit = 1 << (data->port % 8); - } - else { /* port 24 ~ 48 */ - cpld_addr = I2C_ADDR_CPLD2; - cpld_reg = tx_disable_regs[(data->port - 24) / 8]; - cpld_bit = 1 << (data->port % 8); - } - - /* Read current status */ - cpld_val = accton_i2c_cpld_read(cpld_addr, cpld_reg); - - /* Update tx_disable status */ - if (disable) { - data->msa->status[1] |= BIT_INDEX(data->port); - cpld_val |= cpld_bit; - } - else { - data->msa->status[1] &= ~BIT_INDEX(data->port); - cpld_val &= ~cpld_bit; - } - - accton_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); - mutex_unlock(&data->update_lock); - return count; -} - -static int sfp_is_port_present(struct i2c_client *client, int port) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - data = sfp_update_present(client); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - return !(data->present & BIT_INDEX(data->port)); /* Platform dependent */ -} - -static ssize_t show_present(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); - - if (PRESENT_ALL == attr->index) { - int i; - u8 values[7] = {0}; - struct sfp_port_data *data = sfp_update_present(client); - - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = ~(u8)(data->present >> (i * 8)); - } - - /* Return values 1 -> 54 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5], - values[6] & 0x3F); - } - else { - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - /* PRESENT */ - return sprintf(buf, "%d\n", present); - } -} -/* Platform dependent --- */ - -static struct sfp_port_data *sfp_update_port_type(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - u8 buf = 0; - int status; - - mutex_lock(&data->update_lock); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - if (buf != SFF8024_DEVICE_ID_SFP) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - status = sfp_eeprom_read(client, SFF8472_10G_ETH_COMPLIANCE_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("sfp port type (0x3) data = (0x%x)", buf); - data->port_type = buf & SFF8472_10G_BASE_MASK ? OOM_DRIVER_PORT_TYPE_SFP_PLUS : OOM_DRIVER_PORT_TYPE_SFP; - break; - } - case DRIVER_TYPE_QSFP: - { - status = sfp_eeprom_read(client, SFF8024_PHYSICAL_DEVICE_ID_ADDR, &buf, sizeof(buf)); - if (unlikely(status < 0)) { - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - DEBUG_PRINT("qsfp port type (0x0) buf = (0x%x)", buf); - switch (buf) { - case SFF8024_DEVICE_ID_QSFP: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP; - break; - case SFF8024_DEVICE_ID_QSFP_PLUS: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - case SFF8024_DEVICE_ID_QSFP28: - data->port_type = OOM_DRIVER_PORT_TYPE_QSFP_PLUS; - break; - default: - data->port_type = OOM_DRIVER_PORT_TYPE_INVALID; - break; - } - - break; - } - default: - break; - } - - mutex_unlock(&data->update_lock); - return data; -} - -static ssize_t show_port_type(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int present = sfp_is_port_present(client, data->port); - - if (IS_ERR_VALUE(present)) { - return present; - } - - if (!present) { - return sprintf(buf, "%d\n", OOM_DRIVER_PORT_TYPE_NOT_PRESENT); - } - - sfp_update_port_type(dev); - return sprintf(buf, "%d\n", data->port_type); -} - -static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - int i, status = -1; - u8 buf = 0; - u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; - - if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { - return data; - } - - DEBUG_PRINT("Starting sfp tx rx status update"); - mutex_lock(&data->update_lock); - data->qsfp->valid = 0; - memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); - - /* Notify device to update tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - } - msleep(200); - - /* Read actual tx fault/ tx disable/ rx los status */ - for (i = 0; i < ARRAY_SIZE(reg); i++) { - status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); - if (unlikely(status < 0)) { - goto exit; - } - - DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); - data->qsfp->status[i] = (buf & 0xF); - } - - data->qsfp->valid = 1; - data->qsfp->last_updated = jiffies; - -exit: - mutex_unlock(&data->update_lock); - return (status < 0) ? ERR_PTR(status) : data; -} - -static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - int present; - u8 val = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - present = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENXIO; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - switch (attr->index) { - case TX_FAULT: - val = !!(data->qsfp->status[2] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - case TX_DISABLE: - val = data->qsfp->status[1] & 0xF; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - case RX_LOS: - val = !!(data->qsfp->status[0] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); - break; - default: - break; - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - long disable; - int status; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (!status) { - /* port is not present */ - return -ENXIO; - } - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - data = qsfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - mutex_lock(&data->update_lock); - - if (attr->index == TX_DISABLE) { - data->qsfp->status[1] = disable & 0xF; - } - else {/* TX_DISABLE1 ~ TX_DISABLE4*/ - if (disable) { - data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); - } - else { - data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); - } - } - - DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); - status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); - if (unlikely(status < 0)) { - count = status; - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t sfp_show_ddm_implemented(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - char ddm; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - - status = sfp_is_port_present(client, data->port); - if (IS_ERR_VALUE(status)) { - return status; - } - - if (status == 0) { - /* port is not present */ - return -ENODEV; - } - - status = sfp_eeprom_read(client, SFF8472_DIAG_MON_TYPE_ADDR, &ddm, sizeof(ddm)); - if (unlikely(status < 0)) { - return status; - } - - return sprintf(buf, "%d\n", !!(ddm & SFF8472_DIAG_MON_TYPE_DDM_MASK)); -} - -/* Platform dependent +++ */ -static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 val = 0, index = 0; - struct i2c_client *client = to_i2c_client(dev); - struct sfp_port_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - - if (data->driver_type == DRIVER_TYPE_QSFP) { - return qsfp_show_tx_rx_status(dev, da, buf); - } - - data = sfp_update_tx_rx_status(dev); - if (IS_ERR(data)) { - return PTR_ERR(data); - } - - if(attr->index == RX_LOS_ALL) { - int i = 0; - u8 values[6] = {0}; - - for (i = 0; i < ARRAY_SIZE(values); i++) { - values[i] = (u8)(data->msa->status[2] >> (i * 8)); - } - - /** Return values 1 -> 48 in order */ - return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], - values[3], values[4], values[5]); - } - - switch (attr->index) { - case TX_FAULT: - index = 0; - break; - case TX_DISABLE: - index = 1; - break; - case RX_LOS: - index = 2; - break; - default: - return 0; - } - - val = !!(data->msa->status[index] & BIT_INDEX(data->port)); - return sprintf(buf, "%d\n", val); -} -/* Platform dependent --- */ -static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return data_len; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, command, *data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - return status; - } - - return 1; -#endif - - -} - -static ssize_t sfp_port_write(struct sfp_port_data *data, - const char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - return count; - } - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_write(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; -} - - -static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_write(data, buf, off, count); -} - -static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, - int data_len) -{ -#if USE_I2C_BLOCK_READ - int status, retry = I2C_RW_RETRY_COUNT; - - if (data_len > I2C_SMBUS_BLOCK_MAX) { - data_len = I2C_SMBUS_BLOCK_MAX; - } - - while (retry) { - status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - goto abort; - } - if (unlikely(status != data_len)) { - status = -EIO; - goto abort; - } - - //result = data_len; - -abort: - return status; -#else - int status, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, command); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - if (unlikely(status < 0)) { - dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); - goto abort; - } - - *data = (u8)status; - status = 1; - -abort: - return status; -#endif -} - -static ssize_t sfp_port_read(struct sfp_port_data *data, - char *buf, loff_t off, size_t count) -{ - ssize_t retval = 0; - - if (unlikely(!count)) { - DEBUG_PRINT("Count = 0, return"); - return count; - } - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&data->update_lock); - - while (count) { - ssize_t status; - - status = sfp_eeprom_read(data->client, off, buf, count); - if (status <= 0) { - if (retval == 0) { - retval = status; - } - break; - } - - buf += status; - off += status; - count -= status; - retval += status; - } - - mutex_unlock(&data->update_lock); - return retval; - -} - -static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, - char *buf, loff_t off, size_t count) -{ - int present; - struct sfp_port_data *data; - DEBUG_PRINT("offset = (%d), count = (%d)", off, count); - data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - - present = sfp_is_port_present(data->client, data->port); - if (IS_ERR_VALUE(present)) { - return present; - } - - if (present == 0) { - /* port is not present */ - return -ENODEV; - } - - return sfp_port_read(data, buf, off, count); -} - -static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) -{ - int err; - - sysfs_bin_attr_init(eeprom); - eeprom->attr.name = EEPROM_NAME; - eeprom->attr.mode = S_IWUSR | S_IRUGO; - eeprom->read = sfp_bin_read; - eeprom->write = sfp_bin_write; - eeprom->size = EEPROM_SIZE; - - /* Create eeprom file */ - err = sysfs_create_bin_file(kobj, eeprom); - if (err) { - return err; - } - - return 0; -} - -static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) -{ - sysfs_remove_bin_file(kobj, eeprom); - return 0; -} - -static const struct attribute_group sfp_msa_group = { - .attrs = sfp_msa_attributes, -}; - -static int sfp_i2c_check_functionality(struct i2c_client *client) -{ -#if USE_I2C_BLOCK_READ - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); -#else - return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); -#endif -} - -static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_msa_data **data) -{ - int status; - struct sfp_msa_data *msa; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); - if (!msa) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = msa; - dev_info(&client->dev, "sfp msa '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); -exit_free: - kfree(msa); -exit: - - return status; -} - -static const struct attribute_group sfp_ddm_group = { - .attrs = sfp_ddm_attributes, -}; - -static int sfp_ddm_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct sfp_ddm_data **data) -{ - int status; - struct sfp_ddm_data *ddm; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - ddm = kzalloc(sizeof(struct sfp_ddm_data), GFP_KERNEL); - if (!ddm) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_ddm_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &ddm->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = ddm; - dev_info(&client->dev, "sfp ddm '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); -exit_free: - kfree(ddm); -exit: - - return status; -} - -static const struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; - -static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, - struct qsfp_data **data) -{ - int status; - struct qsfp_data *qsfp; - - if (!sfp_i2c_check_functionality(client)) { - status = -EIO; - goto exit; - } - - qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); - if (!qsfp) { - status = -ENOMEM; - goto exit; - } - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &qsfp_group); - if (status) { - goto exit_free; - } - - /* init eeprom */ - status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); - if (status) { - goto exit_remove; - } - - *data = qsfp; - dev_info(&client->dev, "qsfp '%s'\n", client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &qsfp_group); -exit_free: - kfree(qsfp); -exit: - - return status; -} - -/* Platform dependent +++ */ -static int sfp_device_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct sfp_port_data *data = NULL; - - data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->port = dev_id->driver_data; - data->client = client; - - if (dev_id->driver_data >= as5916_54x_sfp1 && dev_id->driver_data <= as5916_54x_sfp48) { - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_MSA; - return sfp_msa_probe(client, dev_id, &data->msa); - } - else if (client->addr == SFP_EEPROM_A2_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_SFP_DDM; - return sfp_ddm_probe(client, dev_id, &data->ddm); - } - } - else { /* as5916_54x_sfp49 ~ as5916_54x_sfp54 */ - if (client->addr == SFP_EEPROM_A0_I2C_ADDR) { - data->driver_type = DRIVER_TYPE_QSFP; - return qsfp_probe(client, dev_id, &data->qsfp); - } - } - - return -ENODEV; -} -/* Platform dependent --- */ - -static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); - kfree(data); - return 0; -} - -static int sfp_ddm_remove(struct i2c_client *client, struct sfp_ddm_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &sfp_ddm_group); - kfree(data); - return 0; -} - -static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) -{ - sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); - sysfs_remove_group(&client->dev.kobj, &qsfp_group); - kfree(data); - return 0; -} - -static int sfp_device_remove(struct i2c_client *client) -{ - struct sfp_port_data *data = i2c_get_clientdata(client); - - switch (data->driver_type) { - case DRIVER_TYPE_SFP_MSA: - return sfp_msa_remove(client, data->msa); - case DRIVER_TYPE_SFP_DDM: - return sfp_ddm_remove(client, data->ddm); - case DRIVER_TYPE_QSFP: - return qfp_remove(client, data->qsfp); - } - - return 0; -} - -/* Addresses scanned - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -static struct i2c_driver sfp_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = sfp_device_probe, - .remove = sfp_device_remove, - .id_table = sfp_device_id, - .address_list = normal_i2c, -}; - -static int __init sfp_init(void) -{ - return i2c_add_driver(&sfp_driver); -} - -static void __exit sfp_exit(void) -{ - i2c_del_driver(&sfp_driver); -} - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("accton as5916_54x_sfp driver"); -MODULE_LICENSE("GPL"); - -late_initcall(sfp_init); -module_exit(sfp_exit); - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/sfpi.c index d1606f47..75f8ce55 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/onlp/builds/src/module/src/sfpi.c @@ -24,17 +24,21 @@ * ***********************************************************/ #include +#include #include -#include "platform_lib.h" - +#include "x86_64_accton_as5916_54x_int.h" #include "x86_64_accton_as5916_54x_log.h" -#define NUM_OF_SFP_PORT 54 -#define MAX_PORT_PATH 64 +#define PORT_BUS_INDEX(port) (port+33) -#define SFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" -#define SFP_PORT_DOM_FORMAT "/sys/bus/i2c/devices/%d-0051/%s" -#define SFP_BUS_INDEX(port) (port+33) +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD1 "/sys/bus/i2c/devices/11-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/12-0062/module_rx_los_all" /************************************************************ * @@ -56,7 +60,7 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) */ int p; - for(p = 0; p < NUM_OF_SFP_PORT; p++) { + for(p = 0; p < 54; p++) { AIM_BITMAP_SET(bmap, p); } @@ -72,7 +76,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - if (onlp_file_read_int(&present, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_is_present") < 0) { + int bus, addr; + + addr = (port < 24) ? 60 : 62; + bus = (addr == 60) ? 11 : 12; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -83,31 +92,45 @@ onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[7]; - char path[MAX_PORT_PATH] = {0}; + uint32_t bytes[7], *ptr = NULL; FILE* fp; + int addr; - sprintf(path, SFP_PORT_FORMAT, SFP_BUS_INDEX(0), "sfp_is_present_all"); - fp = fopen(path, "r"); + ptr = bytes; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5, - bytes+6 - ); - fclose(fp); - if(count != AIM_ARRAYSIZE(bytes)) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 60; addr <= 62; addr+=2) { + /* Read present status of port 0~53 */ + int count = 0; + char file[64] = {0}; + int bus = (addr == 60) ? 11 : 12; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + + if (addr == 60) { /* CPLD1 */ + count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + else { /* CPLD2 */ + count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + + ptr += count; } /* Mask out non-existant QSFP ports */ @@ -130,64 +153,44 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_OK; } -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int size = 0; - if(onlp_file_read(data, 256, &size, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { - if(size == 256) { - return ONLP_STATUS_OK; - } - } - - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - int size = 0; - if(onlp_file_read(data, 256, &size, SFP_PORT_DOM_FORMAT, SFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) { - if(size == 256) { - return ONLP_STATUS_OK; - } - } - - return ONLP_STATUS_E_INTERNAL; -} - int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[6]; - char path[MAX_PORT_PATH] = {0}; + uint32_t *ptr = bytes; FILE* fp; - sprintf(path, SFP_PORT_FORMAT, SFP_BUS_INDEX(0), "sfp_rx_los_all"); - fp = fopen(path, "r"); + /* Read present status of port 0~23 */ + int addr, i = 0; - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; - } - int count = fscanf(fp, "%x %x %x %x %x %x", - bytes+0, - bytes+1, - bytes+2, - bytes+3, - bytes+4, - bytes+5 - ); - fclose(fp); - if(count != 6) { - AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); - return ONLP_STATUS_E_INTERNAL; + for (addr = 60; addr <= 62; addr+=2) { + if (addr == 60) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; } /* Convert to 64 bit integer in port order */ - int i = 0; + i = 0; uint64_t rx_los_all = 0 ; - for(i = 5; i >= 0; i--) { + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { rx_los_all <<= 8; rx_los_all |= bytes[i]; } @@ -201,16 +204,77 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) return ONLP_STATUS_OK; } +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 11 : 12; + switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_write_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_disable") != 0) { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -233,12 +297,19 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 11 : 12; + switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_rx_los") < 0) { - AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } else { @@ -249,7 +320,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_fault") < 0) { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -261,7 +332,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_read_int(value, SFP_PORT_FORMAT, SFP_BUS_INDEX(port), "sfp_tx_disable") < 0) { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -278,7 +349,6 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) return rv; } - int onlp_sfpi_denit(void) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/platform-config/r1/src/python/x86_64_accton_as5916_54x_r1/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/platform-config/r1/src/python/x86_64_accton_as5916_54x_r1/__init__.py index 171b3c20..c2b8e872 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/platform-config/r1/src/python/x86_64_accton_as5916_54x_r1/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54x/platform-config/r1/src/python/x86_64_accton_as5916_54x_r1/__init__.py @@ -8,9 +8,9 @@ class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, SYS_OBJECT_ID=".5916.54" def baseconfig(self): - self.insmod("accton_i2c_cpld") + self.insmod('optoe') self.insmod("ym2651y") - for m in [ "sfp", "psu", "fan", "leds" ]: + for m in [ "cpld", "psu", "fan", "leds" ]: self.insmod("x86-64-accton-as5916-54x-%s" % m) ########### initialize I2C bus 0 ########### @@ -30,8 +30,8 @@ class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, ('lm75', 0x4b, 10), # initialize CPLDs - ('accton_i2c_cpld', 0x60, 11), - ('accton_i2c_cpld', 0x62, 12), + ('as5916_54x_cpld1', 0x60, 11), + ('as5916_54x_cpld2', 0x62, 12), # initialize multiplexer (PCA9548) ('pca9548', 0x74, 2), @@ -61,12 +61,14 @@ class OnlPlatform_x86_64_accton_as5916_54x_r1(OnlPlatformAccton, # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('as5916_54x_sfp%d' % port, 0x50, port+32) - self.new_i2c_device('as5916_54x_sfp%d' % port, 0x51, port+32) + self.new_i2c_device('optoe2', 0x50, port+32) # initialize QSFP devices for port in range(49, 55): - self.new_i2c_device('as5916_54x_sfp%d' % port, 0x50, port+32) + self.new_i2c_device('optoe1', 0x50, port+32) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+32), shell=True) return True From bc949a5afbfbffb74b26eed9046f2dd4cd32c77f Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 2 Apr 2018 18:53:22 +0000 Subject: [PATCH 208/244] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 9cc37062..93a3eee2 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 9cc37062419222acc152d8d94b9f95965ccd665f +Subproject commit 93a3eee233b1543a8c3734354bbb77bf2747938b From 41bf6970e5c99d657153da8023455be2e858257f Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 2 Apr 2018 17:41:02 +0000 Subject: [PATCH 209/244] Add option for local script execution during autoboot. --- .../base/all/initrds/loader-initrd-files/src/bin/autoboot | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot b/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot index 79bfa3fc..6638708a 100644 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/autoboot @@ -21,6 +21,9 @@ if [ -f /etc/onl/abort ]; then exit 1 fi +if [ -f /mnt/onl/boot/autoboot ]; then + . /mnt/onl/boot/autoboot +fi # # The maximum number of times we will retry autobooting before @@ -118,4 +121,3 @@ else msg_error "BOOTMODE $BOOTMODE is not implemented. Autobooting cannot continue." exit 1 fi - From 3b45ae681311e22809b359b48c36dce4bf947a10 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 3 Apr 2018 21:11:29 +0000 Subject: [PATCH 210/244] UDS Error Handling - Don't allow UDS connects() to block. - Add a 1 second timeout for all UDS read/write operations. --- .../base/any/onlp/src/onlplib/module/src/file.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/base/any/onlp/src/onlplib/module/src/file.c b/packages/base/any/onlp/src/onlplib/module/src/file.c index ef31b840..df73165c 100644 --- a/packages/base/any/onlp/src/onlplib/module/src/file.c +++ b/packages/base/any/onlp/src/onlplib/module/src/file.c @@ -50,11 +50,26 @@ ds_connect__(const char* path) return -1; } + /* + * UDS connects must be non-blocking. + */ + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); + memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1); if(connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == 0) { + + /* + * Set blocking with a 1 second timeout on all domain socket read/write operations. + */ + struct timeval tv; + + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK); + tv.tv_sec = 1; + tv.tv_usec = 0; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv); return fd; } else { From fde45aafd78a58db5ae7940291bb14ca2fc3da2e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 5 Apr 2018 17:27:21 +0000 Subject: [PATCH 211/244] Disable ASR generation by default. Packages using ASR must be updated explicitly. --- tools/onlpm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index ab68bdae..523287f0 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -431,7 +431,7 @@ class OnlPackage(object): if self.pkg.get('init-after-remove', True): command = command + "--after-remove %s " % OnlPackageAfterRemoveScript(self.pkg['init'], dir=workdir).name - if self.pkg.get('asr', True): + if self.pkg.get('asr', False): with onlu.Profiler() as profiler: # Generate the ASR documentation for this package. sys.path.append("%s/sm/infra/tools" % os.getenv('ONL')) From 7faad73b4a8105313e8e09230b2a6cbf354686ef Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 5 Apr 2018 17:32:31 +0000 Subject: [PATCH 212/244] Enable ASR generation. --- packages/base/any/faultd/APKG.yml | 5 +---- packages/base/any/onlp-snmpd/APKG.yml | 3 +-- packages/base/any/onlp/APKG.yml | 5 +---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/base/any/faultd/APKG.yml b/packages/base/any/faultd/APKG.yml index 6eb1b970..9a9d6eb5 100644 --- a/packages/base/any/faultd/APKG.yml +++ b/packages/base/any/faultd/APKG.yml @@ -16,7 +16,4 @@ packages: init: ${ONL}/packages/base/any/faultd/faultd.init changelog: Change changes changes., - - - - + asr: True diff --git a/packages/base/any/onlp-snmpd/APKG.yml b/packages/base/any/onlp-snmpd/APKG.yml index bb37f217..b21767cb 100644 --- a/packages/base/any/onlp-snmpd/APKG.yml +++ b/packages/base/any/onlp-snmpd/APKG.yml @@ -21,5 +21,4 @@ packages: init: ${ONL}/packages/base/any/onlp-snmpd/onlp-snmpd.init changelog: Change changes changes., - - + asr: True diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml index 4597e63d..1d6832e5 100644 --- a/packages/base/any/onlp/APKG.yml +++ b/packages/base/any/onlp/APKG.yml @@ -36,7 +36,4 @@ packages: init: $ONL/packages/base/any/onlp/src/onlpd.init changelog: Change changes changes., - - - - + asr: True From 82a51e3a16075206189fce1992217c8bfd9888b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 10 Apr 2018 11:32:32 -0700 Subject: [PATCH 213/244] Revert "[as5712-54x] Add support for OOM driver" --- .../builds/x86-64-accton-as5712-54x-cpld.c | 1154 ++-------- .../builds/x86-64-accton-as5712-54x-fan.c | 13 +- .../builds/x86-64-accton-as5712-54x-leds.c | 12 +- .../builds/x86-64-accton-as5712-54x-psu.c | 21 +- .../builds/x86-64-accton-as5712-54x-sfp.c | 1882 +++++++++++++++++ .../onlp/builds/src/module/src/sfpi.c | 216 +- .../x86_64_accton_as5712_54x_r0/__init__.py | 24 +- 7 files changed, 2211 insertions(+), 1111 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c index 244ed40b..ad09168d 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-cpld.c @@ -32,13 +32,31 @@ #include #include #include +#include #include -#include -#include -#include -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ +static struct dmi_system_id as5712_dmi_table[] = { + { + .ident = "Accton AS5712", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS5712"), + }, + }, + { + .ident = "Accton AS5712", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS5712"), + }, + }, +}; + +int platform_accton_as5712_54x(void) +{ + return dmi_check_system(as5712_dmi_table); +} +EXPORT_SYMBOL(platform_accton_as5712_54x); #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x18 @@ -46,6 +64,10 @@ #define CPLD_CHANNEL_SELECT_REG 0x2 #define CPLD_DESELECT_CHANNEL 0xFF +#if 0 +#define NUM_OF_ALL_CPLD_CHANS (NUM_OF_CPLD2_CHANS + NUM_OF_CPLD3_CHANS) +#endif + #define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS static LIST_HEAD(cpld_client_list); @@ -62,15 +84,20 @@ enum cpld_mux_type { as5712_54x_cpld1 }; -struct as5712_54x_cpld_data { +struct accton_i2c_cpld_mux { enum cpld_mux_type type; struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; u8 last_chan; /* last register value */ - - struct device *hwmon_dev; - struct mutex update_lock; }; +#if 0 +/* The mapping table between mux index and adapter index + array index : the mux index + the content : adapter index + */ +static int mux_adap_map[NUM_OF_ALL_CPLD_CHANS]; +#endif + struct chip_desc { u8 nchans; u8 deselectChan; @@ -92,835 +119,45 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id as5712_54x_cpld_mux_id[] = { +static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { { "as5712_54x_cpld1", as5712_54x_cpld1 }, { "as5712_54x_cpld2", as5712_54x_cpld2 }, { "as5712_54x_cpld3", as5712_54x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, as5712_54x_cpld_mux_id); - -#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index -#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index -#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index -#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index - -enum as5712_54x_cpld1_sysfs_attributes { - CPLD_VERSION, - ACCESS, - MODULE_PRESENT_ALL, - MODULE_RXLOS_ALL, - /* transceiver attributes */ - TRANSCEIVER_PRESENT_ATTR_ID(1), - TRANSCEIVER_PRESENT_ATTR_ID(2), - TRANSCEIVER_PRESENT_ATTR_ID(3), - TRANSCEIVER_PRESENT_ATTR_ID(4), - TRANSCEIVER_PRESENT_ATTR_ID(5), - TRANSCEIVER_PRESENT_ATTR_ID(6), - TRANSCEIVER_PRESENT_ATTR_ID(7), - TRANSCEIVER_PRESENT_ATTR_ID(8), - TRANSCEIVER_PRESENT_ATTR_ID(9), - TRANSCEIVER_PRESENT_ATTR_ID(10), - TRANSCEIVER_PRESENT_ATTR_ID(11), - TRANSCEIVER_PRESENT_ATTR_ID(12), - TRANSCEIVER_PRESENT_ATTR_ID(13), - TRANSCEIVER_PRESENT_ATTR_ID(14), - TRANSCEIVER_PRESENT_ATTR_ID(15), - TRANSCEIVER_PRESENT_ATTR_ID(16), - TRANSCEIVER_PRESENT_ATTR_ID(17), - TRANSCEIVER_PRESENT_ATTR_ID(18), - TRANSCEIVER_PRESENT_ATTR_ID(19), - TRANSCEIVER_PRESENT_ATTR_ID(20), - TRANSCEIVER_PRESENT_ATTR_ID(21), - TRANSCEIVER_PRESENT_ATTR_ID(22), - TRANSCEIVER_PRESENT_ATTR_ID(23), - TRANSCEIVER_PRESENT_ATTR_ID(24), - TRANSCEIVER_PRESENT_ATTR_ID(25), - TRANSCEIVER_PRESENT_ATTR_ID(26), - TRANSCEIVER_PRESENT_ATTR_ID(27), - TRANSCEIVER_PRESENT_ATTR_ID(28), - TRANSCEIVER_PRESENT_ATTR_ID(29), - TRANSCEIVER_PRESENT_ATTR_ID(30), - TRANSCEIVER_PRESENT_ATTR_ID(31), - TRANSCEIVER_PRESENT_ATTR_ID(32), - TRANSCEIVER_PRESENT_ATTR_ID(33), - TRANSCEIVER_PRESENT_ATTR_ID(34), - TRANSCEIVER_PRESENT_ATTR_ID(35), - TRANSCEIVER_PRESENT_ATTR_ID(36), - TRANSCEIVER_PRESENT_ATTR_ID(37), - TRANSCEIVER_PRESENT_ATTR_ID(38), - TRANSCEIVER_PRESENT_ATTR_ID(39), - TRANSCEIVER_PRESENT_ATTR_ID(40), - TRANSCEIVER_PRESENT_ATTR_ID(41), - TRANSCEIVER_PRESENT_ATTR_ID(42), - TRANSCEIVER_PRESENT_ATTR_ID(43), - TRANSCEIVER_PRESENT_ATTR_ID(44), - TRANSCEIVER_PRESENT_ATTR_ID(45), - TRANSCEIVER_PRESENT_ATTR_ID(46), - TRANSCEIVER_PRESENT_ATTR_ID(47), - TRANSCEIVER_PRESENT_ATTR_ID(48), - TRANSCEIVER_PRESENT_ATTR_ID(49), - TRANSCEIVER_PRESENT_ATTR_ID(50), - TRANSCEIVER_PRESENT_ATTR_ID(51), - TRANSCEIVER_PRESENT_ATTR_ID(52), - TRANSCEIVER_PRESENT_ATTR_ID(53), - TRANSCEIVER_PRESENT_ATTR_ID(54), - TRANSCEIVER_TXDISABLE_ATTR_ID(1), - TRANSCEIVER_TXDISABLE_ATTR_ID(2), - TRANSCEIVER_TXDISABLE_ATTR_ID(3), - TRANSCEIVER_TXDISABLE_ATTR_ID(4), - TRANSCEIVER_TXDISABLE_ATTR_ID(5), - TRANSCEIVER_TXDISABLE_ATTR_ID(6), - TRANSCEIVER_TXDISABLE_ATTR_ID(7), - TRANSCEIVER_TXDISABLE_ATTR_ID(8), - TRANSCEIVER_TXDISABLE_ATTR_ID(9), - TRANSCEIVER_TXDISABLE_ATTR_ID(10), - TRANSCEIVER_TXDISABLE_ATTR_ID(11), - TRANSCEIVER_TXDISABLE_ATTR_ID(12), - TRANSCEIVER_TXDISABLE_ATTR_ID(13), - TRANSCEIVER_TXDISABLE_ATTR_ID(14), - TRANSCEIVER_TXDISABLE_ATTR_ID(15), - TRANSCEIVER_TXDISABLE_ATTR_ID(16), - TRANSCEIVER_TXDISABLE_ATTR_ID(17), - TRANSCEIVER_TXDISABLE_ATTR_ID(18), - TRANSCEIVER_TXDISABLE_ATTR_ID(19), - TRANSCEIVER_TXDISABLE_ATTR_ID(20), - TRANSCEIVER_TXDISABLE_ATTR_ID(21), - TRANSCEIVER_TXDISABLE_ATTR_ID(22), - TRANSCEIVER_TXDISABLE_ATTR_ID(23), - TRANSCEIVER_TXDISABLE_ATTR_ID(24), - TRANSCEIVER_TXDISABLE_ATTR_ID(25), - TRANSCEIVER_TXDISABLE_ATTR_ID(26), - TRANSCEIVER_TXDISABLE_ATTR_ID(27), - TRANSCEIVER_TXDISABLE_ATTR_ID(28), - TRANSCEIVER_TXDISABLE_ATTR_ID(29), - TRANSCEIVER_TXDISABLE_ATTR_ID(30), - TRANSCEIVER_TXDISABLE_ATTR_ID(31), - TRANSCEIVER_TXDISABLE_ATTR_ID(32), - TRANSCEIVER_TXDISABLE_ATTR_ID(33), - TRANSCEIVER_TXDISABLE_ATTR_ID(34), - TRANSCEIVER_TXDISABLE_ATTR_ID(35), - TRANSCEIVER_TXDISABLE_ATTR_ID(36), - TRANSCEIVER_TXDISABLE_ATTR_ID(37), - TRANSCEIVER_TXDISABLE_ATTR_ID(38), - TRANSCEIVER_TXDISABLE_ATTR_ID(39), - TRANSCEIVER_TXDISABLE_ATTR_ID(40), - TRANSCEIVER_TXDISABLE_ATTR_ID(41), - TRANSCEIVER_TXDISABLE_ATTR_ID(42), - TRANSCEIVER_TXDISABLE_ATTR_ID(43), - TRANSCEIVER_TXDISABLE_ATTR_ID(44), - TRANSCEIVER_TXDISABLE_ATTR_ID(45), - TRANSCEIVER_TXDISABLE_ATTR_ID(46), - TRANSCEIVER_TXDISABLE_ATTR_ID(47), - TRANSCEIVER_TXDISABLE_ATTR_ID(48), - TRANSCEIVER_RXLOS_ATTR_ID(1), - TRANSCEIVER_RXLOS_ATTR_ID(2), - TRANSCEIVER_RXLOS_ATTR_ID(3), - TRANSCEIVER_RXLOS_ATTR_ID(4), - TRANSCEIVER_RXLOS_ATTR_ID(5), - TRANSCEIVER_RXLOS_ATTR_ID(6), - TRANSCEIVER_RXLOS_ATTR_ID(7), - TRANSCEIVER_RXLOS_ATTR_ID(8), - TRANSCEIVER_RXLOS_ATTR_ID(9), - TRANSCEIVER_RXLOS_ATTR_ID(10), - TRANSCEIVER_RXLOS_ATTR_ID(11), - TRANSCEIVER_RXLOS_ATTR_ID(12), - TRANSCEIVER_RXLOS_ATTR_ID(13), - TRANSCEIVER_RXLOS_ATTR_ID(14), - TRANSCEIVER_RXLOS_ATTR_ID(15), - TRANSCEIVER_RXLOS_ATTR_ID(16), - TRANSCEIVER_RXLOS_ATTR_ID(17), - TRANSCEIVER_RXLOS_ATTR_ID(18), - TRANSCEIVER_RXLOS_ATTR_ID(19), - TRANSCEIVER_RXLOS_ATTR_ID(20), - TRANSCEIVER_RXLOS_ATTR_ID(21), - TRANSCEIVER_RXLOS_ATTR_ID(22), - TRANSCEIVER_RXLOS_ATTR_ID(23), - TRANSCEIVER_RXLOS_ATTR_ID(24), - TRANSCEIVER_RXLOS_ATTR_ID(25), - TRANSCEIVER_RXLOS_ATTR_ID(26), - TRANSCEIVER_RXLOS_ATTR_ID(27), - TRANSCEIVER_RXLOS_ATTR_ID(28), - TRANSCEIVER_RXLOS_ATTR_ID(29), - TRANSCEIVER_RXLOS_ATTR_ID(30), - TRANSCEIVER_RXLOS_ATTR_ID(31), - TRANSCEIVER_RXLOS_ATTR_ID(32), - TRANSCEIVER_RXLOS_ATTR_ID(33), - TRANSCEIVER_RXLOS_ATTR_ID(34), - TRANSCEIVER_RXLOS_ATTR_ID(35), - TRANSCEIVER_RXLOS_ATTR_ID(36), - TRANSCEIVER_RXLOS_ATTR_ID(37), - TRANSCEIVER_RXLOS_ATTR_ID(38), - TRANSCEIVER_RXLOS_ATTR_ID(39), - TRANSCEIVER_RXLOS_ATTR_ID(40), - TRANSCEIVER_RXLOS_ATTR_ID(41), - TRANSCEIVER_RXLOS_ATTR_ID(42), - TRANSCEIVER_RXLOS_ATTR_ID(43), - TRANSCEIVER_RXLOS_ATTR_ID(44), - TRANSCEIVER_RXLOS_ATTR_ID(45), - TRANSCEIVER_RXLOS_ATTR_ID(46), - TRANSCEIVER_RXLOS_ATTR_ID(47), - TRANSCEIVER_RXLOS_ATTR_ID(48), - TRANSCEIVER_TXFAULT_ATTR_ID(1), - TRANSCEIVER_TXFAULT_ATTR_ID(2), - TRANSCEIVER_TXFAULT_ATTR_ID(3), - TRANSCEIVER_TXFAULT_ATTR_ID(4), - TRANSCEIVER_TXFAULT_ATTR_ID(5), - TRANSCEIVER_TXFAULT_ATTR_ID(6), - TRANSCEIVER_TXFAULT_ATTR_ID(7), - TRANSCEIVER_TXFAULT_ATTR_ID(8), - TRANSCEIVER_TXFAULT_ATTR_ID(9), - TRANSCEIVER_TXFAULT_ATTR_ID(10), - TRANSCEIVER_TXFAULT_ATTR_ID(11), - TRANSCEIVER_TXFAULT_ATTR_ID(12), - TRANSCEIVER_TXFAULT_ATTR_ID(13), - TRANSCEIVER_TXFAULT_ATTR_ID(14), - TRANSCEIVER_TXFAULT_ATTR_ID(15), - TRANSCEIVER_TXFAULT_ATTR_ID(16), - TRANSCEIVER_TXFAULT_ATTR_ID(17), - TRANSCEIVER_TXFAULT_ATTR_ID(18), - TRANSCEIVER_TXFAULT_ATTR_ID(19), - TRANSCEIVER_TXFAULT_ATTR_ID(20), - TRANSCEIVER_TXFAULT_ATTR_ID(21), - TRANSCEIVER_TXFAULT_ATTR_ID(22), - TRANSCEIVER_TXFAULT_ATTR_ID(23), - TRANSCEIVER_TXFAULT_ATTR_ID(24), - TRANSCEIVER_TXFAULT_ATTR_ID(25), - TRANSCEIVER_TXFAULT_ATTR_ID(26), - TRANSCEIVER_TXFAULT_ATTR_ID(27), - TRANSCEIVER_TXFAULT_ATTR_ID(28), - TRANSCEIVER_TXFAULT_ATTR_ID(29), - TRANSCEIVER_TXFAULT_ATTR_ID(30), - TRANSCEIVER_TXFAULT_ATTR_ID(31), - TRANSCEIVER_TXFAULT_ATTR_ID(32), - TRANSCEIVER_TXFAULT_ATTR_ID(33), - TRANSCEIVER_TXFAULT_ATTR_ID(34), - TRANSCEIVER_TXFAULT_ATTR_ID(35), - TRANSCEIVER_TXFAULT_ATTR_ID(36), - TRANSCEIVER_TXFAULT_ATTR_ID(37), - TRANSCEIVER_TXFAULT_ATTR_ID(38), - TRANSCEIVER_TXFAULT_ATTR_ID(39), - TRANSCEIVER_TXFAULT_ATTR_ID(40), - TRANSCEIVER_TXFAULT_ATTR_ID(41), - TRANSCEIVER_TXFAULT_ATTR_ID(42), - TRANSCEIVER_TXFAULT_ATTR_ID(43), - TRANSCEIVER_TXFAULT_ATTR_ID(44), - TRANSCEIVER_TXFAULT_ATTR_ID(45), - TRANSCEIVER_TXFAULT_ATTR_ID(46), - TRANSCEIVER_TXFAULT_ATTR_ID(47), - TRANSCEIVER_TXFAULT_ATTR_ID(48), -}; - -/* sysfs attributes for hwmon - */ -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf); -static int as5712_54x_cpld_read_internal(struct i2c_client *client, u8 reg); -static int as5712_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); - -/* transceiver attributes */ -#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ - static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) -#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr - -#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ - static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ - static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ - static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) -#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ - &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ - &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ - &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr - -static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); -/* transceiver attributes */ -static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); -static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); - -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); - -static struct attribute *as5712_54x_cpld1_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - NULL -}; - -static const struct attribute_group as5712_54x_cpld1_group = { - .attrs = as5712_54x_cpld1_attributes, -}; - -static struct attribute *as5712_54x_cpld2_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - &sensor_dev_attr_module_rx_los_all.dev_attr.attr, - DECLARE_TRANSCEIVER_PRESENT_ATTR(1), - DECLARE_TRANSCEIVER_PRESENT_ATTR(2), - DECLARE_TRANSCEIVER_PRESENT_ATTR(3), - DECLARE_TRANSCEIVER_PRESENT_ATTR(4), - DECLARE_TRANSCEIVER_PRESENT_ATTR(5), - DECLARE_TRANSCEIVER_PRESENT_ATTR(6), - DECLARE_TRANSCEIVER_PRESENT_ATTR(7), - DECLARE_TRANSCEIVER_PRESENT_ATTR(8), - DECLARE_TRANSCEIVER_PRESENT_ATTR(9), - DECLARE_TRANSCEIVER_PRESENT_ATTR(10), - DECLARE_TRANSCEIVER_PRESENT_ATTR(11), - DECLARE_TRANSCEIVER_PRESENT_ATTR(12), - DECLARE_TRANSCEIVER_PRESENT_ATTR(13), - DECLARE_TRANSCEIVER_PRESENT_ATTR(14), - DECLARE_TRANSCEIVER_PRESENT_ATTR(15), - DECLARE_TRANSCEIVER_PRESENT_ATTR(16), - DECLARE_TRANSCEIVER_PRESENT_ATTR(17), - DECLARE_TRANSCEIVER_PRESENT_ATTR(18), - DECLARE_TRANSCEIVER_PRESENT_ATTR(19), - DECLARE_TRANSCEIVER_PRESENT_ATTR(20), - DECLARE_TRANSCEIVER_PRESENT_ATTR(21), - DECLARE_TRANSCEIVER_PRESENT_ATTR(22), - DECLARE_TRANSCEIVER_PRESENT_ATTR(23), - DECLARE_TRANSCEIVER_PRESENT_ATTR(24), - DECLARE_SFP_TRANSCEIVER_ATTR(1), - DECLARE_SFP_TRANSCEIVER_ATTR(2), - DECLARE_SFP_TRANSCEIVER_ATTR(3), - DECLARE_SFP_TRANSCEIVER_ATTR(4), - DECLARE_SFP_TRANSCEIVER_ATTR(5), - DECLARE_SFP_TRANSCEIVER_ATTR(6), - DECLARE_SFP_TRANSCEIVER_ATTR(7), - DECLARE_SFP_TRANSCEIVER_ATTR(8), - DECLARE_SFP_TRANSCEIVER_ATTR(9), - DECLARE_SFP_TRANSCEIVER_ATTR(10), - DECLARE_SFP_TRANSCEIVER_ATTR(11), - DECLARE_SFP_TRANSCEIVER_ATTR(12), - DECLARE_SFP_TRANSCEIVER_ATTR(13), - DECLARE_SFP_TRANSCEIVER_ATTR(14), - DECLARE_SFP_TRANSCEIVER_ATTR(15), - DECLARE_SFP_TRANSCEIVER_ATTR(16), - DECLARE_SFP_TRANSCEIVER_ATTR(17), - DECLARE_SFP_TRANSCEIVER_ATTR(18), - DECLARE_SFP_TRANSCEIVER_ATTR(19), - DECLARE_SFP_TRANSCEIVER_ATTR(20), - DECLARE_SFP_TRANSCEIVER_ATTR(21), - DECLARE_SFP_TRANSCEIVER_ATTR(22), - DECLARE_SFP_TRANSCEIVER_ATTR(23), - DECLARE_SFP_TRANSCEIVER_ATTR(24), - NULL -}; - -static const struct attribute_group as5712_54x_cpld2_group = { - .attrs = as5712_54x_cpld2_attributes, -}; - -static struct attribute *as5712_54x_cpld3_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - &sensor_dev_attr_module_rx_los_all.dev_attr.attr, - DECLARE_TRANSCEIVER_PRESENT_ATTR(25), - DECLARE_TRANSCEIVER_PRESENT_ATTR(26), - DECLARE_TRANSCEIVER_PRESENT_ATTR(27), - DECLARE_TRANSCEIVER_PRESENT_ATTR(28), - DECLARE_TRANSCEIVER_PRESENT_ATTR(29), - DECLARE_TRANSCEIVER_PRESENT_ATTR(30), - DECLARE_TRANSCEIVER_PRESENT_ATTR(31), - DECLARE_TRANSCEIVER_PRESENT_ATTR(32), - DECLARE_TRANSCEIVER_PRESENT_ATTR(33), - DECLARE_TRANSCEIVER_PRESENT_ATTR(34), - DECLARE_TRANSCEIVER_PRESENT_ATTR(35), - DECLARE_TRANSCEIVER_PRESENT_ATTR(36), - DECLARE_TRANSCEIVER_PRESENT_ATTR(37), - DECLARE_TRANSCEIVER_PRESENT_ATTR(38), - DECLARE_TRANSCEIVER_PRESENT_ATTR(39), - DECLARE_TRANSCEIVER_PRESENT_ATTR(40), - DECLARE_TRANSCEIVER_PRESENT_ATTR(41), - DECLARE_TRANSCEIVER_PRESENT_ATTR(42), - DECLARE_TRANSCEIVER_PRESENT_ATTR(43), - DECLARE_TRANSCEIVER_PRESENT_ATTR(44), - DECLARE_TRANSCEIVER_PRESENT_ATTR(45), - DECLARE_TRANSCEIVER_PRESENT_ATTR(46), - DECLARE_TRANSCEIVER_PRESENT_ATTR(47), - DECLARE_TRANSCEIVER_PRESENT_ATTR(48), - DECLARE_TRANSCEIVER_PRESENT_ATTR(49), - DECLARE_TRANSCEIVER_PRESENT_ATTR(50), - DECLARE_TRANSCEIVER_PRESENT_ATTR(51), - DECLARE_TRANSCEIVER_PRESENT_ATTR(52), - DECLARE_TRANSCEIVER_PRESENT_ATTR(53), - DECLARE_TRANSCEIVER_PRESENT_ATTR(54), - DECLARE_SFP_TRANSCEIVER_ATTR(25), - DECLARE_SFP_TRANSCEIVER_ATTR(26), - DECLARE_SFP_TRANSCEIVER_ATTR(27), - DECLARE_SFP_TRANSCEIVER_ATTR(28), - DECLARE_SFP_TRANSCEIVER_ATTR(29), - DECLARE_SFP_TRANSCEIVER_ATTR(30), - DECLARE_SFP_TRANSCEIVER_ATTR(31), - DECLARE_SFP_TRANSCEIVER_ATTR(32), - DECLARE_SFP_TRANSCEIVER_ATTR(33), - DECLARE_SFP_TRANSCEIVER_ATTR(34), - DECLARE_SFP_TRANSCEIVER_ATTR(35), - DECLARE_SFP_TRANSCEIVER_ATTR(36), - DECLARE_SFP_TRANSCEIVER_ATTR(37), - DECLARE_SFP_TRANSCEIVER_ATTR(38), - DECLARE_SFP_TRANSCEIVER_ATTR(39), - DECLARE_SFP_TRANSCEIVER_ATTR(40), - DECLARE_SFP_TRANSCEIVER_ATTR(41), - DECLARE_SFP_TRANSCEIVER_ATTR(42), - DECLARE_SFP_TRANSCEIVER_ATTR(43), - DECLARE_SFP_TRANSCEIVER_ATTR(44), - DECLARE_SFP_TRANSCEIVER_ATTR(45), - DECLARE_SFP_TRANSCEIVER_ATTR(46), - DECLARE_SFP_TRANSCEIVER_ATTR(47), - DECLARE_SFP_TRANSCEIVER_ATTR(48), - NULL -}; - -static const struct attribute_group as5712_54x_cpld3_group = { - .attrs = as5712_54x_cpld3_attributes, -}; - -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf) -{ - int i, status, num_regs = 0; - u8 values[4] = {0}; - u8 regs[] = {0x6, 0x7, 0x8, 0x14}; - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - num_regs = (data->type == as5712_54x_cpld2) ? 3 : 4; - - for (i = 0; i < num_regs; i++) { - status = as5712_54x_cpld_read_internal(client, regs[i]); - - if (status < 0) { - goto exit; - } - - values[i] = ~(u8)status; - } - - mutex_unlock(&data->update_lock); - - /* Return values 1 -> 54 in order */ - if (data->type == as5712_54x_cpld2) { - status = sprintf(buf, "%.2x %.2x %.2x\n", - values[0], values[1], values[2]); - } - else { /* as5712_54x_cpld3 */ - values[3] &= 0x3F; - status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); - } - - return status; - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, - char *buf) -{ - int i, status; - u8 values[3] = {0}; - u8 regs[] = {0xF, 0x10, 0x11}; - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = as5712_54x_cpld_read_internal(client, regs[i]); - - if (status < 0) { - goto exit; - } - - values[i] = (u8)status; - } - - mutex_unlock(&data->update_lock); - - /* Return values 1 -> 24 in order */ - return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_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 as5712_54x_cpld_data *data = i2c_get_clientdata(client); - int status = 0; - u8 reg = 0, mask = 0, revert = 0; - - switch (attr->index) { - case MODULE_PRESENT_1 ... MODULE_PRESENT_8: - reg = 0x6; - mask = 0x1 << (attr->index - MODULE_PRESENT_1); - break; - case MODULE_PRESENT_9 ... MODULE_PRESENT_16: - reg = 0x7; - mask = 0x1 << (attr->index - MODULE_PRESENT_9); - break; - case MODULE_PRESENT_17 ... MODULE_PRESENT_24: - reg = 0x8; - mask = 0x1 << (attr->index - MODULE_PRESENT_17); - break; - case MODULE_PRESENT_25 ... MODULE_PRESENT_32: - reg = 0x6; - mask = 0x1 << (attr->index - MODULE_PRESENT_25); - break; - case MODULE_PRESENT_33 ... MODULE_PRESENT_40: - reg = 0x7; - mask = 0x1 << (attr->index - MODULE_PRESENT_33); - break; - case MODULE_PRESENT_41 ... MODULE_PRESENT_48: - reg = 0x8; - mask = 0x1 << (attr->index - MODULE_PRESENT_41); - break; - case MODULE_PRESENT_49: - reg = 0x14; - mask = 0x1; - break; - case MODULE_PRESENT_50: - reg = 0x14; - mask = 0x4; - break; - case MODULE_PRESENT_51: - reg = 0x14; - mask = 0x10; - break; - case MODULE_PRESENT_52: - reg = 0x14; - mask = 0x2; - break; - case MODULE_PRESENT_53: - reg = 0x14; - mask = 0x8; - break; - case MODULE_PRESENT_54: - reg = 0x14; - mask = 0x20; - break; - case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: - reg = 0x9; - mask = 0x1 << (attr->index - MODULE_TXFAULT_1); - break; - case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: - reg = 0xA; - mask = 0x1 << (attr->index - MODULE_TXFAULT_9); - break; - case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: - reg = 0xB; - mask = 0x1 << (attr->index - MODULE_TXFAULT_17); - break; - case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: - reg = 0x9; - mask = 0x1 << (attr->index - MODULE_TXFAULT_25); - break; - case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: - reg = 0xA; - mask = 0x1 << (attr->index - MODULE_TXFAULT_33); - break; - case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: - reg = 0xB; - mask = 0x1 << (attr->index - MODULE_TXFAULT_41); - break; - case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); - break; - case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); - break; - case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); - break; - case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); - break; - case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); - break; - case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); - break; - case MODULE_RXLOS_1 ... MODULE_RXLOS_8: - reg = 0xF; - mask = 0x1 << (attr->index - MODULE_RXLOS_1); - break; - case MODULE_RXLOS_9 ... MODULE_RXLOS_16: - reg = 0x10; - mask = 0x1 << (attr->index - MODULE_RXLOS_9); - break; - case MODULE_RXLOS_17 ... MODULE_RXLOS_24: - reg = 0x11; - mask = 0x1 << (attr->index - MODULE_RXLOS_17); - break; - case MODULE_RXLOS_25 ... MODULE_RXLOS_32: - reg = 0xF; - mask = 0x1 << (attr->index - MODULE_RXLOS_25); - break; - case MODULE_RXLOS_33 ... MODULE_RXLOS_40: - reg = 0x10; - mask = 0x1 << (attr->index - MODULE_RXLOS_33); - break; - case MODULE_RXLOS_41 ... MODULE_RXLOS_48: - reg = 0x11; - mask = 0x1 << (attr->index - MODULE_RXLOS_41); - break; - default: - return 0; - } - - if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { - revert = 1; - } - - mutex_lock(&data->update_lock); - status = as5712_54x_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); - long disable; - int status; - u8 reg = 0, mask = 0; - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - switch (attr->index) { - case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); - break; - case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); - break; - case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); - break; - case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); - break; - case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); - break; - case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); - break; - default: - return 0; - } - - /* Read current status */ - mutex_lock(&data->update_lock); - status = as5712_54x_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - - /* Update tx_disable status */ - if (disable) { - status |= mask; - } - else { - status &= ~mask; - } - - status = as5712_54x_cpld_write_internal(client, reg, status); - if (unlikely(status < 0)) { - goto exit; - } - - mutex_unlock(&data->update_lock); - return count; - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int status; - u32 addr, val; - struct i2c_client *client = to_i2c_client(dev); - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); - - if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { - return -EINVAL; - } - - if (addr > 0xFF || val > 0xFF) { - return -EINVAL; - } - - mutex_lock(&data->update_lock); - status = as5712_54x_cpld_write_internal(client, addr, val); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - return count; - -exit: - mutex_unlock(&data->update_lock); - return status; -} +MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int as5712_54x_cpld_mux_reg_write(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, struct i2c_client *client, u8 val) { +#if 0 + int ret = -ENODEV; + + //if (adap->algo->master_xfer) { + if (0) + struct i2c_msg msg; + char buf[2]; + + msg.addr = client->addr; + msg.flags = 0; + msg.len = 2; + buf[0] = 0x2; + buf[1] = val; + msg.buf = buf; + ret = adap->algo->master_xfer(adap, &msg, 1); + } + else { + union i2c_smbus_data data; + ret = adap->algo->smbus_xfer(adap, client->addr, + client->flags, + I2C_SMBUS_WRITE, + 0x2, I2C_SMBUS_BYTE, &data); + } + + return ret; +#else unsigned long orig_jiffies; unsigned short flags; union i2c_smbus_data data; @@ -947,37 +184,38 @@ static int as5712_54x_cpld_mux_reg_write(struct i2c_adapter *adap, } return res; +#endif } -static int as5712_54x_cpld_mux_select_chan(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, void *client, u32 chan) { - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); u8 regval; int ret = 0; regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = as5712_54x_cpld_mux_reg_write(adap, client, regval); + ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int as5712_54x_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return as5712_54x_cpld_mux_reg_write(adap, client, data->last_chan); + return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); } -static void as5712_54x_cpld_add_client(struct i2c_client *client) +static void accton_i2c_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -993,7 +231,7 @@ static void as5712_54x_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void as5712_54x_cpld_remove_client(struct i2c_client *client) +static void accton_i2c_cpld_remove_client(struct i2c_client *client) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -1019,178 +257,125 @@ static void as5712_54x_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) { - int val = 0; - struct i2c_client *client = to_i2c_client(dev); - - val = i2c_smbus_read_byte_data(client, 0x1); + u8 reg = 0x1; + struct i2c_client *client; + int len; - if (val < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); - } - - return sprintf(buf, "%d", val); + client = to_i2c_client(dev); + len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); + + return len; } +static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); + /* * I2C init/probing/exit functions */ -static int as5712_54x_cpld_mux_probe(struct i2c_client *client, +static int accton_i2c_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct as5712_54x_cpld_data *data; + struct accton_i2c_cpld_mux *data; int ret = -ENODEV; - const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto exit; + goto err; - data = kzalloc(sizeof(struct as5712_54x_cpld_data), GFP_KERNEL); + data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto exit; + goto err; } i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); + +#if 0 + /* Write the mux register at addr to verify + * that the mux is in fact present. + */ + if (i2c_smbus_write_byte(client, 0) < 0) { + dev_warn(&client->dev, "probe failed\n"); + goto exit_free; + } +#endif + data->type = id->driver_data; if (data->type == as5712_54x_cpld2 || data->type == as5712_54x_cpld3) { data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ - for (chan = 0; chan < chips[data->type].nchans; chan++) { - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, - as5712_54x_cpld_mux_select_chan, - as5712_54x_cpld_mux_deselect_mux); + /* Now create an adapter for each channel */ + for (chan = 0; chan < chips[data->type].nchans; chan++) { +#if 0 + int idx; +#endif + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + I2C_CLASS_HWMON | I2C_CLASS_SPD, +#endif + accton_i2c_cpld_mux_select_chan, + accton_i2c_cpld_mux_deselect_mux); - if (data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto exit_mux_register; - } + if (data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); + goto virt_reg_failed; } - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); +#if 0 + idx = (data->type - as5712_54x_cpld2) * NUM_OF_CPLD2_CHANS + chan; + mux_adap_map[idx] = data->virt_adaps[chan]->nr; +#endif } - /* Register sysfs hooks */ - switch (data->type) { - case as5712_54x_cpld1: - group = &as5712_54x_cpld1_group; - break; - case as5712_54x_cpld2: - group = &as5712_54x_cpld2_group; - break; - case as5712_54x_cpld3: - group = &as5712_54x_cpld3_group; - break; - default: - break; + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); } - - if (group) { - ret = sysfs_create_group(&client->dev.kobj, group); - if (ret) { - goto exit_mux_register; - } - } + accton_i2c_cpld_add_client(client); - as5712_54x_cpld_add_client(client); + ret = sysfs_create_file(&client->dev.kobj, &ver.attr); + if (ret) + goto virt_reg_failed; return 0; -exit_mux_register: +virt_reg_failed: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); } - kfree(data); -exit: + + kfree(data); +err: return ret; } -static int as5712_54x_cpld_mux_remove(struct i2c_client *client) +static int accton_i2c_cpld_mux_remove(struct i2c_client *client) { - struct as5712_54x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); const struct chip_desc *chip = &chips[data->type]; int chan; - const struct attribute_group *group = NULL; - as5712_54x_cpld_remove_client(client); - - /* Remove sysfs hooks */ - switch (data->type) { - case as5712_54x_cpld1: - group = &as5712_54x_cpld1_group; - break; - case as5712_54x_cpld2: - group = &as5712_54x_cpld2_group; - break; - case as5712_54x_cpld3: - group = &as5712_54x_cpld3_group; - break; - default: - break; - } - - if (group) { - sysfs_remove_group(&client->dev.kobj, group); - } + sysfs_remove_file(&client->dev.kobj, &ver.attr); for (chan = 0; chan < chip->nchans; ++chan) { - if (data->virt_adaps[chan]) { - i2c_del_mux_adapter(data->virt_adaps[chan]); - data->virt_adaps[chan] = NULL; - } + if (data->virt_adaps[chan]) { + i2c_del_mux_adapter(data->virt_adaps[chan]); + data->virt_adaps[chan] = NULL; + } } kfree(data); + accton_i2c_cpld_remove_client(client); return 0; } -static int as5712_54x_cpld_read_internal(struct i2c_client *client, u8 reg) -{ - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, reg); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -static int as5712_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) -{ - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, reg, value); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg) +int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -1200,21 +385,21 @@ int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = as5712_54x_cpld_read_internal(cpld_node->client, reg); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5712_54x_cpld_read); +EXPORT_SYMBOL(as5712_54x_i2c_cpld_read); -int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -1224,45 +409,60 @@ int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = as5712_54x_cpld_write_internal(cpld_node->client, reg, value); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5712_54x_cpld_write); +EXPORT_SYMBOL(as5712_54x_i2c_cpld_write); -static struct i2c_driver as5712_54x_cpld_mux_driver = { +#if 0 +int accton_i2c_cpld_mux_get_index(int adap_index) +{ + int i; + + for (i = 0; i < NUM_OF_ALL_CPLD_CHANS; i++) { + if (mux_adap_map[i] == adap_index) { + return i; + } + } + + return -EINVAL; +} +EXPORT_SYMBOL(accton_i2c_cpld_mux_get_index); +#endif + +static struct i2c_driver accton_i2c_cpld_mux_driver = { .driver = { .name = "as5712_54x_cpld", .owner = THIS_MODULE, }, - .probe = as5712_54x_cpld_mux_probe, - .remove = as5712_54x_cpld_mux_remove, - .id_table = as5712_54x_cpld_mux_id, + .probe = accton_i2c_cpld_mux_probe, + .remove = accton_i2c_cpld_mux_remove, + .id_table = accton_i2c_cpld_mux_id, }; -static int __init as5712_54x_cpld_mux_init(void) +static int __init accton_i2c_cpld_mux_init(void) { mutex_init(&list_lock); - return i2c_add_driver(&as5712_54x_cpld_mux_driver); + return i2c_add_driver(&accton_i2c_cpld_mux_driver); } -static void __exit as5712_54x_cpld_mux_exit(void) +static void __exit accton_i2c_cpld_mux_exit(void) { - i2c_del_driver(&as5712_54x_cpld_mux_driver); + i2c_del_driver(&accton_i2c_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(as5712_54x_cpld_mux_init); -module_exit(as5712_54x_cpld_mux_exit); - +module_init(accton_i2c_cpld_mux_init); +module_exit(accton_i2c_cpld_mux_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c index db81a1a8..d6ffe7b6 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-fan.c @@ -131,8 +131,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as5712_54x_fan_group = { static int accton_as5712_54x_fan_read_value(u8 reg) { - return as5712_54x_cpld_read(0x60, reg); + return as5712_54x_i2c_cpld_read(0x60, reg); } static int accton_as5712_54x_fan_write_value(u8 reg, u8 value) { - return as5712_54x_cpld_write(0x60, reg, value); + return as5712_54x_i2c_cpld_write(0x60, reg, value); } static void accton_as5712_54x_fan_update_device(struct device *dev) @@ -394,6 +394,11 @@ static int __init accton_as5712_54x_fan_init(void) { int ret; + extern int platform_accton_as5712_54x(void); + if(!platform_accton_as5712_54x()) { + return -ENODEV; + } + ret = platform_driver_register(&accton_as5712_54x_fan_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c index 36704987..cf8868e5 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as5712_54x_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as5712_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5712_54x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -220,12 +220,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5712_54x_led_read_value(u8 reg) { - return as5712_54x_cpld_read(0x60, reg); + return as5712_54x_i2c_cpld_read(0x60, reg); } static int accton_as5712_54x_led_write_value(u8 reg, u8 value) { - return as5712_54x_cpld_write(0x60, reg, value); + return as5712_54x_i2c_cpld_write(0x60, reg, value); } static void accton_as5712_54x_led_update(void) @@ -552,6 +552,10 @@ static int __init accton_as5712_54x_led_init(void) { int ret; + extern int platform_accton_as5712_54x(void); + if(!platform_accton_as5712_54x()) { + return -ENODEV; + } ret = platform_driver_register(&accton_as5712_54x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c index af0c0c01..52269933 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-psu.c @@ -43,7 +43,7 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5712_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as5712_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); static int as5712_54x_psu_model_name_get(struct device *dev); /* Addresses scanned @@ -329,7 +329,7 @@ static struct as5712_54x_psu_data *as5712_54x_psu_update_device(struct device *d /* Read psu status */ - status = as5712_54x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as5712_54x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -349,9 +349,24 @@ exit: return data; } -module_i2c_driver(as5712_54x_psu_driver); +static int __init as5712_54x_psu_init(void) +{ + extern int platform_accton_as5712_54x(void); + if(!platform_accton_as5712_54x()) { + return -ENODEV; + } + return i2c_add_driver(&as5712_54x_psu_driver); +} + +static void __exit as5712_54x_psu_exit(void) +{ + i2c_del_driver(&as5712_54x_psu_driver); +} MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5712_54x_psu driver"); MODULE_LICENSE("GPL"); +module_init(as5712_54x_psu_init); +module_exit(as5712_54x_psu_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c new file mode 100644 index 00000000..8202b39e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/modules/builds/x86-64-accton-as5712-54x-sfp.c @@ -0,0 +1,1882 @@ +/* + * SFP driver for accton as5712_54x sfp + * + * Copyright (C) Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "as5712_54x_sfp" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 54 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8472_DIAG_MON_TYPE_ADDR 92 +#define SFF8472_DIAG_MON_TYPE_DDM_MASK 0x40 +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int as5712_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5712_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL +}; + +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_rx_loss, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, sfp_show_tx_rx_status, sfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, sfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* SFP msa attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, sfp_show_tx_rx_status, NULL, RX_LOS_ALL); +static struct attribute *sfp_msa_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + NULL +}; + +/* Platform dependent +++ */ +/* The table maps active port to cpld port. + * Array index 0 is for active port 1, + * index 1 for active port 2, and so on. + * The array content implies cpld port index. + */ +static const u8 cpld_to_front_port_table[] = +{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 52, 50, 53, 51, 54}; +#define CPLD_PORT_TO_FRONT_PORT(port) (cpld_to_front_port_table[port]) + +enum port_numbers { +as5712_54x_port1, as5712_54x_port2, as5712_54x_port3, as5712_54x_port4, +as5712_54x_port5, as5712_54x_port6, as5712_54x_port7, as5712_54x_port8, +as5712_54x_port9, as5712_54x_port10, as5712_54x_port11, as5712_54x_port12, +as5712_54x_port13, as5712_54x_port14, as5712_54x_port15, as5712_54x_port16, +as5712_54x_port17, as5712_54x_port18, as5712_54x_port19, as5712_54x_port20, +as5712_54x_port21, as5712_54x_port22, as5712_54x_port23, as5712_54x_port24, +as5712_54x_port25, as5712_54x_port26, as5712_54x_port27, as5712_54x_port28, +as5712_54x_port29, as5712_54x_port30, as5712_54x_port31, as5712_54x_port32, +as5712_54x_port33, as5712_54x_port34, as5712_54x_port35, as5712_54x_port36, +as5712_54x_port37, as5712_54x_port38, as5712_54x_port39, as5712_54x_port40, +as5712_54x_port41, as5712_54x_port42, as5712_54x_port43, as5712_54x_port44, +as5712_54x_port45, as5712_54x_port46, as5712_54x_port47, as5712_54x_port48, +as5712_54x_port49, as5712_54x_port52, as5712_54x_port50, as5712_54x_port53, +as5712_54x_port51, as5712_54x_port54 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as5712_54x_port1), +I2C_DEV_ID(as5712_54x_port2), +I2C_DEV_ID(as5712_54x_port3), +I2C_DEV_ID(as5712_54x_port4), +I2C_DEV_ID(as5712_54x_port5), +I2C_DEV_ID(as5712_54x_port6), +I2C_DEV_ID(as5712_54x_port7), +I2C_DEV_ID(as5712_54x_port8), +I2C_DEV_ID(as5712_54x_port9), +I2C_DEV_ID(as5712_54x_port10), +I2C_DEV_ID(as5712_54x_port11), +I2C_DEV_ID(as5712_54x_port12), +I2C_DEV_ID(as5712_54x_port13), +I2C_DEV_ID(as5712_54x_port14), +I2C_DEV_ID(as5712_54x_port15), +I2C_DEV_ID(as5712_54x_port16), +I2C_DEV_ID(as5712_54x_port17), +I2C_DEV_ID(as5712_54x_port18), +I2C_DEV_ID(as5712_54x_port19), +I2C_DEV_ID(as5712_54x_port20), +I2C_DEV_ID(as5712_54x_port21), +I2C_DEV_ID(as5712_54x_port22), +I2C_DEV_ID(as5712_54x_port23), +I2C_DEV_ID(as5712_54x_port24), +I2C_DEV_ID(as5712_54x_port25), +I2C_DEV_ID(as5712_54x_port26), +I2C_DEV_ID(as5712_54x_port27), +I2C_DEV_ID(as5712_54x_port28), +I2C_DEV_ID(as5712_54x_port29), +I2C_DEV_ID(as5712_54x_port30), +I2C_DEV_ID(as5712_54x_port31), +I2C_DEV_ID(as5712_54x_port32), +I2C_DEV_ID(as5712_54x_port33), +I2C_DEV_ID(as5712_54x_port34), +I2C_DEV_ID(as5712_54x_port35), +I2C_DEV_ID(as5712_54x_port36), +I2C_DEV_ID(as5712_54x_port37), +I2C_DEV_ID(as5712_54x_port38), +I2C_DEV_ID(as5712_54x_port39), +I2C_DEV_ID(as5712_54x_port40), +I2C_DEV_ID(as5712_54x_port41), +I2C_DEV_ID(as5712_54x_port42), +I2C_DEV_ID(as5712_54x_port43), +I2C_DEV_ID(as5712_54x_port44), +I2C_DEV_ID(as5712_54x_port45), +I2C_DEV_ID(as5712_54x_port46), +I2C_DEV_ID(as5712_54x_port47), +I2C_DEV_ID(as5712_54x_port48), +I2C_DEV_ID(as5712_54x_port49), +I2C_DEV_ID(as5712_54x_port50), +I2C_DEV_ID(as5712_54x_port51), +I2C_DEV_ID(as5712_54x_port52), +I2C_DEV_ID(as5712_54x_port53), +I2C_DEV_ID(as5712_54x_port54), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct sfp_msa_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u64 status[6]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss + 3 => device id + 4 => 10G Ethernet Compliance Codes + to distinguish SFP or SFP+ + 5 => DIAGNOSTIC MONITORING TYPE */ + struct eeprom_data eeprom; +#if (MULTIPAGE_SUPPORT == 1) + struct i2c_client *ddm_client; /* dummy client instance for 0xA2 */ +#endif +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct sfp_msa_data *msa; + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} + +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + int i = 0, j = 0, status = -1; + u8 reg; + unsigned short cpld_addr; + struct sfp_port_data *data = i2c_get_clientdata(client); + + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + data->present = 0; + + /* Read present status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 3; j++) { + cpld_addr = 0x61+i; + reg = 0x6+j; + status = as5712_54x_i2c_cpld_read(cpld_addr, reg); + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx\r\n", data->present); + data->present |= (u64)status << ((i*24) + (j%3)*8); + } + } + + /* Read present status of port 49-54(QSFP port) */ + cpld_addr = 0x62; + reg = 0x14; + status = as5712_54x_i2c_cpld_read(cpld_addr, reg); + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + else { + data->present |= (u64)status << 48; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static struct sfp_port_data *sfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0, j = 0; + int status = -1; + + if (time_before(jiffies, data->msa->last_updated + HZ + HZ / 2) && data->msa->valid) { + return data; + } + + DEBUG_PRINT("Starting as5712_54x sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->msa->valid = 0; + memset(data->msa->status, 0, sizeof(data->msa->status)); + + /* Read status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 9; j++) { + u8 reg; + unsigned short cpld_addr; + reg = 0x9+j; + cpld_addr = 0x61+i; + + status = as5712_54x_i2c_cpld_read(cpld_addr, reg); + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", cpld_addr, reg, status); + goto exit; + } + + data->msa->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); + } + } + + data->msa->valid = 1; + data->msa->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t sfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + unsigned short cpld_addr = 0; + u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; + long disable; + int error; + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_set_tx_disable(dev, da, buf, count); + } + + error = kstrtol(buf, 10, &disable); + if (error) { + return error; + } + + mutex_lock(&data->update_lock); + + if(data->port < 24) { + cpld_addr = 0x61; + cpld_reg = 0xC + data->port / 8; + cpld_bit = 1 << (data->port % 8); + } + else { /* port 24 ~ 48 */ + cpld_addr = 0x62; + cpld_reg = 0xC + (data->port - 24) / 8; + cpld_bit = 1 << (data->port % 8); + } + + /* Read current status */ + cpld_val = as5712_54x_i2c_cpld_read(cpld_addr, cpld_reg); + + /* Update tx_disable status */ + if (disable) { + data->msa->status[1] |= BIT_INDEX(data->port); + cpld_val |= cpld_bit; + } + else { + data->msa->status[1] &= ~BIT_INDEX(data->port); + cpld_val &= ~cpld_bit; + } + + as5712_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); + mutex_unlock(&data->update_lock); + return count; +} +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + int i; + u8 values[7] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } + + /* Return values 1 -> 54 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5], + values[6] & 0x3F); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +/* Platform dependent +++ */ +static ssize_t sfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 val = 0, index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + if (data->driver_type == DRIVER_TYPE_QSFP) { + return qsfp_show_tx_rx_status(dev, da, buf); + } + + data = sfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + if(attr->index == RX_LOS_ALL) { + int i = 0; + u8 values[6] = {0}; + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = (u8)(data->msa->status[2] >> (i * 8)); + } + + /** Return values 1 -> 48 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5]); + } + + switch (attr->index) { + case TX_FAULT: + index = 0; + break; + case TX_DISABLE: + index = 1; + break; + case RX_LOS: + index = 2; + break; + default: + return 0; + } + + val = (data->msa->status[index] & BIT_INDEX(data->port)) ? 1 : 0; + return sprintf(buf, "%d", val); +} +/* Platform dependent --- */ + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* if SFP style, offset > 255, shift to i2c addr 0x51 */ + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + if (*offset > 255) { + /* like QSFP, but shifted to client[1] */ + *client = port_data->msa->ddm_client; + *offset -= 256; + } + } + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + if ((off + len) <= 256) return len; + /* if no pages needed, we're good */ + //if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + + /* Check if ddm is supported */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF8472_DIAG_MON_TYPE_ADDR, 1); + if (status < 0) return status; /* error out (no module?) */ + if (!(regval & SFF8472_DIAG_MON_TYPE_DDM_MASK)) { + if (off >= 256) return -EINVAL; + maxlen = 256 - off; + } + else { + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8472_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + if (off >= SFF_8436_EEPROM_UNPAGED_SIZE) return -EINVAL; + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + +static const struct attribute_group sfp_msa_group = { + .attrs = sfp_msa_attributes, +}; + +static int sfp_msa_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct sfp_msa_data **data) +{ + int status; + struct sfp_msa_data *msa; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + msa = kzalloc(sizeof(struct sfp_msa_data), GFP_KERNEL); + if (!msa) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &sfp_msa_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &msa->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + +#if (MULTIPAGE_SUPPORT == 1) + msa->ddm_client = i2c_new_dummy(client->adapter, client->addr + 1); + if (!msa->ddm_client) { + dev_err(&client->dev, "address 0x%02x unavailable\n", client->addr + 1); + status = -EADDRINUSE; + goto exit_eeprom; + } +#endif + + *data = msa; + dev_info(&client->dev, "sfp msa '%s'\n", client->name); + + return 0; + +exit_eeprom: + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &msa->eeprom.bin); +exit_remove: + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); +exit_free: + kfree(msa); +exit: + + return status; +} + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + /* Bring QSFPs out of reset */ + as5712_54x_i2c_cpld_write(0x62, 0x15, 0x3F); + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as5712_54x_port1 || dev_id->driver_data > as5712_54x_port54) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + + if (dev_id->driver_data >= as5712_54x_port1 && dev_id->driver_data <= as5712_54x_port48) { + data->driver_type = DRIVER_TYPE_SFP_MSA; + ret = sfp_msa_probe(client, dev_id, &data->msa); + } + else { /* as5712_54x_portsfp49 ~ as5712_54x_portsfp54 */ + data->driver_type = DRIVER_TYPE_QSFP; + ret = qsfp_probe(client, dev_id, &data->qsfp); + } + + if (ret < 0) { + goto exit_kfree_buf; + } + + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int sfp_msa_remove(struct i2c_client *client, struct sfp_msa_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); +#if (MULTIPAGE_SUPPORT == 1) + i2c_unregister_device(data->ddm_client); +#endif + sysfs_remove_group(&client->dev.kobj, &sfp_msa_group); + kfree(data); + return 0; +} + +static int qfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); + + switch (data->driver_type) { + case DRIVER_TYPE_SFP_MSA: + return sfp_msa_remove(client, data->msa); + case DRIVER_TYPE_QSFP: + return qfp_remove(client, data->qsfp); + } + +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) + kfree(data->writebuf); +#endif + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as5712_54x_sfp driver"); +MODULE_LICENSE("GPL"); + +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c index c44d8a38..560f5762 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/onlp/builds/src/module/src/sfpi.c @@ -24,24 +24,20 @@ * ***********************************************************/ #include -#include -#include -#include "x86_64_accton_as5712_54x_int.h" -#include "x86_64_accton_as5712_54x_log.h" +#include /* For O_RDWR && open */ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; #define CPLD_MUX_BUS_START_INDEX 2 -#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" -#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" -#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/0-00%d/module_rx_los_%d" -#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_fault_%d" -#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_disable_%d" -#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_present_all" -#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_present_all" -#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_rx_los_all" -#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_rx_los_all" - -static int front_port_bus_index(int port) +static int front_port_to_cpld_mux_index(int port) { int rport = 0; @@ -67,6 +63,38 @@ static int front_port_bus_index(int port) return (rport + CPLD_MUX_BUS_START_INDEX); } +static int +as5712_54x_sfp_node_read_int(char *node_path, int *value, int data_len) +{ + int ret = 0; + char buf[8] = {0}; + *value = 0; + + ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); + + if (ret == 0) { + *value = atoi(buf); + } + + return ret; +} + +static char* +as5712_54x_sfp_get_port_path_addr(int port, int addr, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", + front_port_to_cpld_mux_index(port), addr, + node_name); + return sfp_node_path; +} + +static char* +as5712_54x_sfp_get_port_path(int port, char *node_name) +{ + return as5712_54x_sfp_get_port_path_addr(port, 50, node_name); +} + + /************************************************************ * * SFPI Entry Points @@ -175,10 +203,10 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - int addr = (port < 24) ? 61 : 62; - - if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + char* path = as5712_54x_sfp_get_port_path(port, "sfp_is_present"); + + if (as5712_54x_sfp_node_read_int(path, &present, 1) != 0) { + AIM_LOG_INFO("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -189,35 +217,29 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[7]; + char* path; FILE* fp; - /* Read present status of port 0~23 */ - fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); + path = as5712_54x_sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); + if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD2."); + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } - - int count = fscanf(fp, "%x %x %x", bytes+0, bytes+1, bytes+2); + int count = fscanf(fp, "%x %x %x %x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3, + bytes+4, + bytes+5, + bytes+6 + ); fclose(fp); - if(count != 3) { + if(count != AIM_ARRAYSIZE(bytes)) { /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD2."); - return ONLP_STATUS_E_INTERNAL; - } - - /* Read present status of port 24~53 */ - fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); - return ONLP_STATUS_E_INTERNAL; - } - - count = fscanf(fp, "%x %x %x %x", bytes+3, bytes+4, bytes+5, bytes+6); - fclose(fp); - if(count != 4) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } @@ -246,39 +268,33 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[6]; - uint32_t *ptr = bytes; + uint32_t bytes[7]; + char* path; FILE* fp; - /* Read present status of port 0~23 */ - int addr, i = 0; + path = as5712_54x_sfp_get_port_path(0, "sfp_rx_los_all"); + fp = fopen(path, "r"); - for (addr = 61; addr <= 62; addr++) { - if (addr == 61) { - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); - } - else { - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); - } - - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); - fclose(fp); - if(count != 3) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - ptr += count; + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3, + bytes+4, + bytes+5 + ); + fclose(fp); + if(count != 6) { + AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); + return ONLP_STATUS_E_INTERNAL; } /* Convert to 64 bit integer in port order */ - i = 0; + int i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; @@ -299,22 +315,18 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { + char* path = as5712_54x_sfp_get_port_path(port, "sfp_eeprom"); + /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ - int size = 0; memset(data, 0, 256); - if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, front_port_bus_index(port)) != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - if (size != 256) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -324,26 +336,11 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - FILE* fp; - char file[64] = {0}; - - sprintf(file, PORT_EEPROM_FORMAT, front_port_bus_index(port)); - fp = fopen(file, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } + char* path = as5712_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom"); + memset(data, 0, 256); - if (fseek(fp, 256, SEEK_CUR) != 0) { - fclose(fp); - AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } - - int ret = fread(data, 1, 256, fp); - fclose(fp); - if (ret != 256) { - AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -353,28 +350,28 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } @@ -387,13 +384,13 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) return ONLP_STATUS_E_UNSUPPORTED; } - int addr = (port < 24) ? 61 : 62; - switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { + char* path = as5712_54x_sfp_get_port_path(port, "sfp_tx_disable"); + + if (deviceNodeWriteInt(path, value, 0) != 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -415,18 +412,19 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; + char* path = NULL; if (port < 0 || port >= 48) { return ONLP_STATUS_E_UNSUPPORTED; } - int addr = (port < 24) ? 61 : 62; - switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, addr, (port+1)) < 0) { + path = as5712_54x_sfp_get_port_path(port, "sfp_rx_loss"); + + if (as5712_54x_sfp_node_read_int(path, value, 1) != 0) { AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -438,7 +436,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, addr, (port+1)) < 0) { + path = as5712_54x_sfp_get_port_path(port, "sfp_tx_fault"); + + if (as5712_54x_sfp_node_read_int(path, value, 1) != 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -450,7 +450,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { + path = as5712_54x_sfp_get_port_path(port, "sfp_tx_disable"); + + if (as5712_54x_sfp_node_read_int(path, value, 0) != 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py index 48c9970e..810419ce 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5712-54x/platform-config/r0/src/python/x86_64_accton_as5712_54x_r0/__init__.py @@ -9,10 +9,9 @@ class OnlPlatform_x86_64_accton_as5712_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5712.54" def baseconfig(self): - self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: self.insmod("x86-64-accton-as5712-54x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -26,22 +25,15 @@ class OnlPlatform_x86_64_accton_as5712_54x_r0(OnlPlatformAccton, ) # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('optoe2', 0x50, port+1) - subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) + self.new_i2c_device('as5712_54x_port%d' % port, 0x50, port+1) # Initialize QSFP devices - self.new_i2c_device('optoe1', 0x50, 50) - self.new_i2c_device('optoe1', 0x50, 51) - self.new_i2c_device('optoe1', 0x50, 52) - self.new_i2c_device('optoe1', 0x50, 53) - self.new_i2c_device('optoe1', 0x50, 54) - self.new_i2c_device('optoe1', 0x50, 55) - subprocess.call('echo port49 > /sys/bus/i2c/devices/50-0050/port_name', shell=True) - subprocess.call('echo port52 > /sys/bus/i2c/devices/51-0050/port_name', shell=True) - subprocess.call('echo port50 > /sys/bus/i2c/devices/52-0050/port_name', shell=True) - subprocess.call('echo port53 > /sys/bus/i2c/devices/53-0050/port_name', shell=True) - subprocess.call('echo port51 > /sys/bus/i2c/devices/54-0050/port_name', shell=True) - subprocess.call('echo port54 > /sys/bus/i2c/devices/55-0050/port_name', shell=True) + self.new_i2c_device('as5712_54x_port49', 0x50, 50) + self.new_i2c_device('as5712_54x_port52', 0x50, 51) + self.new_i2c_device('as5712_54x_port50', 0x50, 52) + self.new_i2c_device('as5712_54x_port53', 0x50, 53) + self.new_i2c_device('as5712_54x_port51', 0x50, 54) + self.new_i2c_device('as5712_54x_port54', 0x50, 55) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From a5358e0e9cbf3e8f1eb89e595dfc70402dddfb97 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 10 Apr 2018 11:36:55 -0700 Subject: [PATCH 214/244] Revert "[as5812-54t] Add support for OOM driver" --- .../builds/x86-64-accton-as5812-54t-cpld.c | 457 ----- .../builds/x86-64-accton-as5812-54t-fan.c | 15 +- .../builds/x86-64-accton-as5812-54t-leds.c | 15 +- .../builds/x86-64-accton-as5812-54t-psu.c | 22 +- .../builds/x86-64-accton-as5812-54t-sfp.c | 1502 +++++++++++++++++ .../onlp/builds/src/module/src/sfpi.c | 131 +- .../x86_64_accton_as5812_54t_r0/__init__.py | 21 +- 7 files changed, 1643 insertions(+), 520 deletions(-) delete mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c deleted file mode 100644 index f4da9e76..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-cpld.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * A hwmon driver for the as5812_54t_cpld - * - * Copyright (C) 2013 Accton Technology Corporation. - * Brandon Chuang - * - * Based on ad7414.c - * Copyright 2006 Stefan Roese , DENX Software Engineering - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ - -static ssize_t show_present(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf); -static int as5812_54t_cpld_read_internal(struct i2c_client *client, u8 reg); -static int as5812_54t_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); - -struct as5812_54t_cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; -}; - -/* Addresses scanned for as5812_54t_cpld - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index - -enum as5812_54t_cpld_sysfs_attributes { - CPLD_VERSION, - ACCESS, - MODULE_PRESENT_ALL, - /* transceiver attributes */ - TRANSCEIVER_PRESENT_ATTR_ID(49), - TRANSCEIVER_PRESENT_ATTR_ID(50), - TRANSCEIVER_PRESENT_ATTR_ID(51), - TRANSCEIVER_PRESENT_ATTR_ID(52), - TRANSCEIVER_PRESENT_ATTR_ID(53), - TRANSCEIVER_PRESENT_ATTR_ID(54), -}; - -/* sysfs attributes for hwmon - */ - -/* transceiver attributes */ -#define DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ - static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_present, NULL, MODULE_PRESENT_##index) -#define DECLARE_TRANSCEIVER_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr - -static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); -/* transceiver attributes */ -static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); -DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(49); -DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(50); -DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(51); -DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(52); -DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(53); -DECLARE_TRANSCEIVER_SENSOR_DEVICE_ATTR(54); - -static struct attribute *as5812_54t_cpld_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - DECLARE_TRANSCEIVER_ATTR(49), - DECLARE_TRANSCEIVER_ATTR(50), - DECLARE_TRANSCEIVER_ATTR(51), - DECLARE_TRANSCEIVER_ATTR(52), - DECLARE_TRANSCEIVER_ATTR(53), - DECLARE_TRANSCEIVER_ATTR(54), - NULL -}; - -static const struct attribute_group as5812_54t_cpld_group = { - .attrs = as5812_54t_cpld_attributes, -}; - -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status; - u8 value = 0; - u8 reg = 0x22; - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - status = as5812_54t_cpld_read_internal(client, reg); - if (status < 0) { - goto exit; - } - - value = ~(u8)status; - value &= 0x3F; - - mutex_unlock(&data->update_lock); - - /* Return values 49 -> 54 in order */ - return sprintf(buf, "%.2x\n", value); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_present(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 as5812_54t_cpld_data *data = i2c_get_clientdata(client); - int status = 0; - u8 reg = 0, mask = 0; - - reg = 0x22; - mask = 0x1 << (attr->index - MODULE_PRESENT_49); - - mutex_lock(&data->update_lock); - status = as5812_54t_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", !(status & mask)); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 reg = 0, mask = 0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); - int status = 0; - - switch (attr->index) { - case CPLD_VERSION: - reg = 0x1; - mask = 0xFF; - break; - default: - break; - } - - mutex_lock(&data->update_lock); - status = as5812_54t_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - return sprintf(buf, "%d\n", (status & mask)); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int status; - u32 addr, val; - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); - - if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { - return -EINVAL; - } - - if (addr > 0xFF || val > 0xFF) { - return -EINVAL; - } - - mutex_lock(&data->update_lock); - status = as5812_54t_cpld_write_internal(client, addr, val); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - return count; - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static int as5812_54t_cpld_read_internal(struct i2c_client *client, u8 reg) -{ - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, reg); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -static int as5812_54t_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) -{ - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, reg, value); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -static void as5812_54t_cpld_add_client(struct i2c_client *client) -{ - struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - - if (!node) { - dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); - return; - } - - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} - -static void as5812_54t_cpld_remove_client(struct i2c_client *client) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int found = 0; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client == client) { - found = 1; - break; - } - } - - if (found) { - list_del(list_node); - kfree(cpld_node); - } - - mutex_unlock(&list_lock); -} - -static int as5812_54t_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - struct as5812_54t_cpld_data *data = NULL; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_dbg(&client->dev, "i2c_check_functionality failed (0x%x)\n", client->addr); - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct as5812_54t_cpld_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &as5812_54t_cpld_group); - if (status) { - goto exit_free; - } - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - status = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - as5812_54t_cpld_add_client(client); - - dev_info(&client->dev, "%s: cpld '%s'\n", - dev_name(data->hwmon_dev), client->name); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &as5812_54t_cpld_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int as5812_54t_cpld_remove(struct i2c_client *client) -{ - struct as5812_54t_cpld_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &as5812_54t_cpld_group); - kfree(data); - as5812_54t_cpld_remove_client(client); - - return 0; -} - -int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_read_byte_data(cpld_node->client, reg); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as5812_54t_cpld_read); - -int as5812_54t_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as5812_54t_cpld_write); - -static const struct i2c_device_id as5812_54t_cpld_id[] = { - { "as5812_54t_cpld", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, as5812_54t_cpld_id); - -static struct i2c_driver as5812_54t_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "as5812_54t_cpld", - }, - .probe = as5812_54t_cpld_probe, - .remove = as5812_54t_cpld_remove, - .id_table = as5812_54t_cpld_id, - .address_list = normal_i2c, -}; - -static int __init as5812_54t_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&as5812_54t_cpld_driver); -} - -static void __exit as5812_54t_cpld_exit(void) -{ - i2c_del_driver(&as5812_54t_cpld_driver); -} - -module_init(as5812_54t_cpld_init); -module_exit(as5812_54t_cpld_exit); - -MODULE_AUTHOR("Brandon Chuang "); -MODULE_DESCRIPTION("as5812_54t_cpld driver"); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c index d6554637..bad9245e 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-fan.c @@ -131,8 +131,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5812_54t_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as5812_54t_fan_group = { static int accton_as5812_54t_fan_read_value(u8 reg) { - return as5812_54t_cpld_read(0x60, reg); + return accton_i2c_cpld_read(0x60, reg); } static int accton_as5812_54t_fan_write_value(u8 reg, u8 value) { - return as5812_54t_cpld_write(0x60, reg, value); + return accton_i2c_cpld_write(0x60, reg, value); } static void accton_as5812_54t_fan_update_device(struct device *dev) @@ -394,7 +394,12 @@ static int __init accton_as5812_54t_fan_init(void) { int ret; - ret = platform_driver_register(&accton_as5812_54t_fan_driver); + extern int platform_accton_as5812_54t(void); + if (!platform_accton_as5812_54t()) { + return -ENODEV; + } + + ret = platform_driver_register(&accton_as5812_54t_fan_driver); if (ret < 0) { goto exit; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c index 2d70aa18..011f62e7 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5812_54t_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -223,12 +223,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5812_54t_led_read_value(u8 reg) { - return as5812_54t_cpld_read(0x60, reg); + return accton_i2c_cpld_read(0x60, reg); } static int accton_as5812_54t_led_write_value(u8 reg, u8 value) { - return as5812_54t_cpld_write(0x60, reg, value); + return accton_i2c_cpld_write(0x60, reg, value); } static void accton_as5812_54t_led_update(void) @@ -555,7 +555,12 @@ static int __init accton_as5812_54t_led_init(void) { int ret; - ret = platform_driver_register(&accton_as5812_54t_led_driver); + extern int platform_accton_as5812_54t(void); + if (!platform_accton_as5812_54t()) { + return -ENODEV; + } + + ret = platform_driver_register(&accton_as5812_54t_led_driver); if (ret < 0) { goto exit; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c index 75a2d823..a77014e8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-psu.c @@ -43,7 +43,7 @@ static ssize_t show_index(struct device *dev, struct device_attribute *da, char static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static int as5812_54t_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as5812_54t_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); static int as5812_54t_psu_model_name_get(struct device *dev); /* Addresses scanned @@ -328,7 +328,7 @@ static struct as5812_54t_psu_data *as5812_54t_psu_update_device(struct device *d data->valid = 0; /* Read psu status */ - status = as5812_54t_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -348,9 +348,25 @@ exit: return data; } -module_i2c_driver(as5812_54t_psu_driver); +static int __init as5812_54t_psu_init(void) +{ + extern int platform_accton_as5812_54t(void); + if (!platform_accton_as5812_54t()) { + return -ENODEV; + } + + return i2c_add_driver(&as5812_54t_psu_driver); +} + +static void __exit as5812_54t_psu_exit(void) +{ + i2c_del_driver(&as5812_54t_psu_driver); +} MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5812_54t_psu driver"); MODULE_LICENSE("GPL"); +module_init(as5812_54t_psu_init); +module_exit(as5812_54t_psu_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c new file mode 100644 index 00000000..0f1b7aac --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/modules/builds/x86-64-accton-as5812-54t-sfp.c @@ -0,0 +1,1502 @@ +/* + * SFP driver for accton as5812_54t sfp + * + * Copyright (C) Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "as5812_54t_sfp" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL +}; + +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+49) + +enum port_numbers { +as5812_54t_port49, +as5812_54t_port50, +as5812_54t_port51, +as5812_54t_port52, +as5812_54t_port53, +as5812_54t_port54 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as5812_54t_port49), +I2C_DEV_ID(as5812_54t_port50), +I2C_DEV_ID(as5812_54t_port51), +I2C_DEV_ID(as5812_54t_port52), +I2C_DEV_ID(as5812_54t_port53), +I2C_DEV_ID(as5812_54t_port54), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} + +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int status = -1; + + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 49~54 */ + data->present = 0; + + status = accton_i2c_cpld_read(0x60, 0x22); + if (status < 0) { + DEBUG_PRINT("cpld(0x60) reg(0x%x) err %d", regs[i], status); + goto exit; + } + + data->present |= (u64)status; + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + /* Return values 49 -> 54 in order */ + return sprintf(buf, "%.2x\n", (unsigned int)~data->present); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + /* + * Bring QSFPs out of reset, + * This is a temporary fix until the QSFP+_MOD_RST register + * can be exposed through the driver. + */ + accton_i2c_cpld_write(0x60, 0x23, 0x3F); + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as5812_54t_port49 || dev_id->driver_data > as5812_54t_port54) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif + + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as5812_54t_sfp driver"); +MODULE_LICENSE("GPL"); + +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c index cefe9dbf..8840ee26 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/onlp/builds/src/module/src/sfpi.c @@ -25,23 +25,80 @@ ***********************************************************/ #include -#include -#include +#include /* For O_RDWR && open */ +#include +#include +#include +#include + #include "platform_lib.h" +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; #define MUX_START_INDEX 2 -#define NUM_OF_SFP_PORT 6 -static const int port_bus_index[NUM_OF_SFP_PORT] = { - 2, 4, 1, 3, 5, 0 -}; -#define PORT_BUS_INDEX(port) (port_bus_index[port-48]+MUX_START_INDEX) -#define PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s" +static int front_port_to_cpld_mux_index(int port) +{ + int rport = 0; -#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-0060/module_present_%d" -#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/0-0060/module_present_all" + switch (port) + { + case 48: + rport = 2; + break; + case 49: + rport = 4; + break; + case 50: + rport = 1; + break; + case 51: + rport = 3; + break; + case 52: + rport = 5; + break; + case 53: + rport = 0; + break; + default: + break; + } + + return (rport + MUX_START_INDEX); +} + +static int +as5812_54t_sfp_node_read_int(char *node_path, int *value, int data_len) +{ + int ret = 0; + char buf[8] = {0}; + *value = 0; + + ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); + + if (ret == 0) { + *value = atoi(buf); + } + + return ret; +} + +static char* +as5812_54t_sfp_get_port_path_addr(int port, int addr, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", + front_port_to_cpld_mux_index(port), addr, + node_name); + return sfp_node_path; +} + +static char* +as5812_54t_sfp_get_port_path(int port, char *node_name) +{ + return as5812_54t_sfp_get_port_path_addr(port, 50, node_name); +} -#define VALIDATE_PORT(p) { if ((p < 48) || (p > 53)) return ONLP_STATUS_E_PARAM; } /************************************************************ * @@ -79,9 +136,10 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; + char* path = as5812_54t_sfp_get_port_path(port, "sfp_is_present"); - if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + if (as5812_54t_sfp_node_read_int(path, &present, 1) != 0) { + AIM_LOG_INFO("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -92,9 +150,11 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[1]; + char* path; FILE* fp; - fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); + path = as5812_54t_sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); @@ -128,23 +188,24 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - return ONLP_STATUS_E_UNSUPPORTED; + return ONLP_STATUS_OK; } int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { + char* path = as5812_54t_sfp_get_port_path(port, "sfp_eeprom"); + /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ - int size = 0; memset(data, 0, 256); - if(onlp_file_read(data, 256, &size, PORT_FORMAT, PORT_BUS_INDEX(port), "eeprom") != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -152,35 +213,29 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) } int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +onlp_sfpi_dom_read(int port, uint8_t data[256]) { - VALIDATE_PORT(port); - int bus = PORT_BUS_INDEX(port); - return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); + char* path = as5812_54t_sfp_get_port_path_addr(port, 51, "sfp_eeprom"); + memset(data, 0, 256); + + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; } int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) { - VALIDATE_PORT(port); - int bus = PORT_BUS_INDEX(port); - return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); + return ONLP_STATUS_E_UNSUPPORTED; } int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { - VALIDATE_PORT(port); - int bus = PORT_BUS_INDEX(port); - return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - VALIDATE_PORT(port); - int bus = PORT_BUS_INDEX(port); - return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); + return ONLP_STATUS_E_UNSUPPORTED; } int diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py index f1b37214..2326fb41 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54t/platform-config/r0/src/python/x86_64_accton_as5812_54t_r0/__init__.py @@ -10,28 +10,25 @@ class OnlPlatform_x86_64_accton_as5812_54t_r0(OnlPlatformAccton, def baseconfig(self): ########### initialize I2C bus 0 ########### - self.insmod("optoe") + self.insmod("accton_i2c_cpld") self.insmod("cpr_4011_4mxx") self.insmod("ym2651y") - for m in [ "cpld", "psu", "fan", "leds" ]: + for m in [ "sfp", "psu", "fan", "leds" ]: self.insmod("x86-64-accton-as5812-54t-%s" % m) # initialize CPLDs - self.new_i2c_device('as5812_54t_cpld', 0x60, 0) + self.new_i2c_device('accton_i2c_cpld', 0x60, 0) # initiate multiplexer (PCA9548) self.new_i2c_device('pca9548', 0x71, 0) # Initialize QSFP devices - for bus in range(2, 8): - self.new_i2c_device('optoe1', 0x50, bus) - - subprocess.call('echo port54 > /sys/bus/i2c/devices/2-0050/port_name', shell=True) - subprocess.call('echo port51 > /sys/bus/i2c/devices/3-0050/port_name', shell=True) - subprocess.call('echo port49 > /sys/bus/i2c/devices/4-0050/port_name', shell=True) - subprocess.call('echo port52 > /sys/bus/i2c/devices/5-0050/port_name', shell=True) - subprocess.call('echo port50 > /sys/bus/i2c/devices/6-0050/port_name', shell=True) - subprocess.call('echo port53 > /sys/bus/i2c/devices/7-0050/port_name', shell=True) + self.new_i2c_device('as5812_54t_port49', 0x50, 4) + self.new_i2c_device('as5812_54t_port50', 0x50, 6) + self.new_i2c_device('as5812_54t_port51', 0x50, 3) + self.new_i2c_device('as5812_54t_port52', 0x50, 5) + self.new_i2c_device('as5812_54t_port53', 0x50, 7) + self.new_i2c_device('as5812_54t_port54', 0x50, 2) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From fab46a8ee2ec4eb90e133e021f41696edad90a1b Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 11 Apr 2018 14:05:28 -0700 Subject: [PATCH 215/244] Revert "[as5812-54x] Add support for OOM" --- .../builds/x86-64-accton-as5812-54x-cpld.c | 1089 ++--------------- .../builds/x86-64-accton-as5812-54x-fan.c | 10 +- .../builds/x86-64-accton-as5812-54x-leds.c | 8 +- .../builds/x86-64-accton-as5812-54x-psu.c | 17 +- .../builds/x86-64-accton-as5812-54x-sfp.c | 508 ++++++++ .../onlp/builds/src/module/src/sfpi.c | 216 ++-- .../x86_64_accton_as5812_54x_r0/__init__.py | 21 +- 7 files changed, 757 insertions(+), 1112 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c index 5b9a5582..14e1d860 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-cpld.c @@ -33,13 +33,31 @@ #include #include #include +#include #include -#include -#include -#include -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ +static struct dmi_system_id as5812_54x_dmi_table[] = { + { + .ident = "Accton AS5812-54X", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS5812-54X"), + }, + }, + { + .ident = "Accton AS5812-54X", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS5812-54X"), + }, + }, +}; + +int platform_accton_as5812_54x(void) +{ + return dmi_check_system(as5812_54x_dmi_table); +} +EXPORT_SYMBOL(platform_accton_as5812_54x); #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x18 @@ -63,13 +81,10 @@ enum cpld_mux_type { as5812_54x_cpld1 }; -struct as5812_54x_cpld_data { +struct accton_i2c_cpld_mux { enum cpld_mux_type type; struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; u8 last_chan; /* last register value */ - - struct device *hwmon_dev; - struct mutex update_lock; }; struct chip_desc { @@ -93,833 +108,17 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id as5812_54x_cpld_mux_id[] = { +static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { { "as5812_54x_cpld1", as5812_54x_cpld1 }, { "as5812_54x_cpld2", as5812_54x_cpld2 }, { "as5812_54x_cpld3", as5812_54x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, as5812_54x_cpld_mux_id); - -#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index -#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index -#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index -#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index - -enum as5812_54x_cpld1_sysfs_attributes { - CPLD_VERSION, - ACCESS, - MODULE_PRESENT_ALL, - MODULE_RXLOS_ALL, - /* transceiver attributes */ - TRANSCEIVER_PRESENT_ATTR_ID(1), - TRANSCEIVER_PRESENT_ATTR_ID(2), - TRANSCEIVER_PRESENT_ATTR_ID(3), - TRANSCEIVER_PRESENT_ATTR_ID(4), - TRANSCEIVER_PRESENT_ATTR_ID(5), - TRANSCEIVER_PRESENT_ATTR_ID(6), - TRANSCEIVER_PRESENT_ATTR_ID(7), - TRANSCEIVER_PRESENT_ATTR_ID(8), - TRANSCEIVER_PRESENT_ATTR_ID(9), - TRANSCEIVER_PRESENT_ATTR_ID(10), - TRANSCEIVER_PRESENT_ATTR_ID(11), - TRANSCEIVER_PRESENT_ATTR_ID(12), - TRANSCEIVER_PRESENT_ATTR_ID(13), - TRANSCEIVER_PRESENT_ATTR_ID(14), - TRANSCEIVER_PRESENT_ATTR_ID(15), - TRANSCEIVER_PRESENT_ATTR_ID(16), - TRANSCEIVER_PRESENT_ATTR_ID(17), - TRANSCEIVER_PRESENT_ATTR_ID(18), - TRANSCEIVER_PRESENT_ATTR_ID(19), - TRANSCEIVER_PRESENT_ATTR_ID(20), - TRANSCEIVER_PRESENT_ATTR_ID(21), - TRANSCEIVER_PRESENT_ATTR_ID(22), - TRANSCEIVER_PRESENT_ATTR_ID(23), - TRANSCEIVER_PRESENT_ATTR_ID(24), - TRANSCEIVER_PRESENT_ATTR_ID(25), - TRANSCEIVER_PRESENT_ATTR_ID(26), - TRANSCEIVER_PRESENT_ATTR_ID(27), - TRANSCEIVER_PRESENT_ATTR_ID(28), - TRANSCEIVER_PRESENT_ATTR_ID(29), - TRANSCEIVER_PRESENT_ATTR_ID(30), - TRANSCEIVER_PRESENT_ATTR_ID(31), - TRANSCEIVER_PRESENT_ATTR_ID(32), - TRANSCEIVER_PRESENT_ATTR_ID(33), - TRANSCEIVER_PRESENT_ATTR_ID(34), - TRANSCEIVER_PRESENT_ATTR_ID(35), - TRANSCEIVER_PRESENT_ATTR_ID(36), - TRANSCEIVER_PRESENT_ATTR_ID(37), - TRANSCEIVER_PRESENT_ATTR_ID(38), - TRANSCEIVER_PRESENT_ATTR_ID(39), - TRANSCEIVER_PRESENT_ATTR_ID(40), - TRANSCEIVER_PRESENT_ATTR_ID(41), - TRANSCEIVER_PRESENT_ATTR_ID(42), - TRANSCEIVER_PRESENT_ATTR_ID(43), - TRANSCEIVER_PRESENT_ATTR_ID(44), - TRANSCEIVER_PRESENT_ATTR_ID(45), - TRANSCEIVER_PRESENT_ATTR_ID(46), - TRANSCEIVER_PRESENT_ATTR_ID(47), - TRANSCEIVER_PRESENT_ATTR_ID(48), - TRANSCEIVER_PRESENT_ATTR_ID(49), - TRANSCEIVER_PRESENT_ATTR_ID(50), - TRANSCEIVER_PRESENT_ATTR_ID(51), - TRANSCEIVER_PRESENT_ATTR_ID(52), - TRANSCEIVER_PRESENT_ATTR_ID(53), - TRANSCEIVER_PRESENT_ATTR_ID(54), - TRANSCEIVER_TXDISABLE_ATTR_ID(1), - TRANSCEIVER_TXDISABLE_ATTR_ID(2), - TRANSCEIVER_TXDISABLE_ATTR_ID(3), - TRANSCEIVER_TXDISABLE_ATTR_ID(4), - TRANSCEIVER_TXDISABLE_ATTR_ID(5), - TRANSCEIVER_TXDISABLE_ATTR_ID(6), - TRANSCEIVER_TXDISABLE_ATTR_ID(7), - TRANSCEIVER_TXDISABLE_ATTR_ID(8), - TRANSCEIVER_TXDISABLE_ATTR_ID(9), - TRANSCEIVER_TXDISABLE_ATTR_ID(10), - TRANSCEIVER_TXDISABLE_ATTR_ID(11), - TRANSCEIVER_TXDISABLE_ATTR_ID(12), - TRANSCEIVER_TXDISABLE_ATTR_ID(13), - TRANSCEIVER_TXDISABLE_ATTR_ID(14), - TRANSCEIVER_TXDISABLE_ATTR_ID(15), - TRANSCEIVER_TXDISABLE_ATTR_ID(16), - TRANSCEIVER_TXDISABLE_ATTR_ID(17), - TRANSCEIVER_TXDISABLE_ATTR_ID(18), - TRANSCEIVER_TXDISABLE_ATTR_ID(19), - TRANSCEIVER_TXDISABLE_ATTR_ID(20), - TRANSCEIVER_TXDISABLE_ATTR_ID(21), - TRANSCEIVER_TXDISABLE_ATTR_ID(22), - TRANSCEIVER_TXDISABLE_ATTR_ID(23), - TRANSCEIVER_TXDISABLE_ATTR_ID(24), - TRANSCEIVER_TXDISABLE_ATTR_ID(25), - TRANSCEIVER_TXDISABLE_ATTR_ID(26), - TRANSCEIVER_TXDISABLE_ATTR_ID(27), - TRANSCEIVER_TXDISABLE_ATTR_ID(28), - TRANSCEIVER_TXDISABLE_ATTR_ID(29), - TRANSCEIVER_TXDISABLE_ATTR_ID(30), - TRANSCEIVER_TXDISABLE_ATTR_ID(31), - TRANSCEIVER_TXDISABLE_ATTR_ID(32), - TRANSCEIVER_TXDISABLE_ATTR_ID(33), - TRANSCEIVER_TXDISABLE_ATTR_ID(34), - TRANSCEIVER_TXDISABLE_ATTR_ID(35), - TRANSCEIVER_TXDISABLE_ATTR_ID(36), - TRANSCEIVER_TXDISABLE_ATTR_ID(37), - TRANSCEIVER_TXDISABLE_ATTR_ID(38), - TRANSCEIVER_TXDISABLE_ATTR_ID(39), - TRANSCEIVER_TXDISABLE_ATTR_ID(40), - TRANSCEIVER_TXDISABLE_ATTR_ID(41), - TRANSCEIVER_TXDISABLE_ATTR_ID(42), - TRANSCEIVER_TXDISABLE_ATTR_ID(43), - TRANSCEIVER_TXDISABLE_ATTR_ID(44), - TRANSCEIVER_TXDISABLE_ATTR_ID(45), - TRANSCEIVER_TXDISABLE_ATTR_ID(46), - TRANSCEIVER_TXDISABLE_ATTR_ID(47), - TRANSCEIVER_TXDISABLE_ATTR_ID(48), - TRANSCEIVER_RXLOS_ATTR_ID(1), - TRANSCEIVER_RXLOS_ATTR_ID(2), - TRANSCEIVER_RXLOS_ATTR_ID(3), - TRANSCEIVER_RXLOS_ATTR_ID(4), - TRANSCEIVER_RXLOS_ATTR_ID(5), - TRANSCEIVER_RXLOS_ATTR_ID(6), - TRANSCEIVER_RXLOS_ATTR_ID(7), - TRANSCEIVER_RXLOS_ATTR_ID(8), - TRANSCEIVER_RXLOS_ATTR_ID(9), - TRANSCEIVER_RXLOS_ATTR_ID(10), - TRANSCEIVER_RXLOS_ATTR_ID(11), - TRANSCEIVER_RXLOS_ATTR_ID(12), - TRANSCEIVER_RXLOS_ATTR_ID(13), - TRANSCEIVER_RXLOS_ATTR_ID(14), - TRANSCEIVER_RXLOS_ATTR_ID(15), - TRANSCEIVER_RXLOS_ATTR_ID(16), - TRANSCEIVER_RXLOS_ATTR_ID(17), - TRANSCEIVER_RXLOS_ATTR_ID(18), - TRANSCEIVER_RXLOS_ATTR_ID(19), - TRANSCEIVER_RXLOS_ATTR_ID(20), - TRANSCEIVER_RXLOS_ATTR_ID(21), - TRANSCEIVER_RXLOS_ATTR_ID(22), - TRANSCEIVER_RXLOS_ATTR_ID(23), - TRANSCEIVER_RXLOS_ATTR_ID(24), - TRANSCEIVER_RXLOS_ATTR_ID(25), - TRANSCEIVER_RXLOS_ATTR_ID(26), - TRANSCEIVER_RXLOS_ATTR_ID(27), - TRANSCEIVER_RXLOS_ATTR_ID(28), - TRANSCEIVER_RXLOS_ATTR_ID(29), - TRANSCEIVER_RXLOS_ATTR_ID(30), - TRANSCEIVER_RXLOS_ATTR_ID(31), - TRANSCEIVER_RXLOS_ATTR_ID(32), - TRANSCEIVER_RXLOS_ATTR_ID(33), - TRANSCEIVER_RXLOS_ATTR_ID(34), - TRANSCEIVER_RXLOS_ATTR_ID(35), - TRANSCEIVER_RXLOS_ATTR_ID(36), - TRANSCEIVER_RXLOS_ATTR_ID(37), - TRANSCEIVER_RXLOS_ATTR_ID(38), - TRANSCEIVER_RXLOS_ATTR_ID(39), - TRANSCEIVER_RXLOS_ATTR_ID(40), - TRANSCEIVER_RXLOS_ATTR_ID(41), - TRANSCEIVER_RXLOS_ATTR_ID(42), - TRANSCEIVER_RXLOS_ATTR_ID(43), - TRANSCEIVER_RXLOS_ATTR_ID(44), - TRANSCEIVER_RXLOS_ATTR_ID(45), - TRANSCEIVER_RXLOS_ATTR_ID(46), - TRANSCEIVER_RXLOS_ATTR_ID(47), - TRANSCEIVER_RXLOS_ATTR_ID(48), - TRANSCEIVER_TXFAULT_ATTR_ID(1), - TRANSCEIVER_TXFAULT_ATTR_ID(2), - TRANSCEIVER_TXFAULT_ATTR_ID(3), - TRANSCEIVER_TXFAULT_ATTR_ID(4), - TRANSCEIVER_TXFAULT_ATTR_ID(5), - TRANSCEIVER_TXFAULT_ATTR_ID(6), - TRANSCEIVER_TXFAULT_ATTR_ID(7), - TRANSCEIVER_TXFAULT_ATTR_ID(8), - TRANSCEIVER_TXFAULT_ATTR_ID(9), - TRANSCEIVER_TXFAULT_ATTR_ID(10), - TRANSCEIVER_TXFAULT_ATTR_ID(11), - TRANSCEIVER_TXFAULT_ATTR_ID(12), - TRANSCEIVER_TXFAULT_ATTR_ID(13), - TRANSCEIVER_TXFAULT_ATTR_ID(14), - TRANSCEIVER_TXFAULT_ATTR_ID(15), - TRANSCEIVER_TXFAULT_ATTR_ID(16), - TRANSCEIVER_TXFAULT_ATTR_ID(17), - TRANSCEIVER_TXFAULT_ATTR_ID(18), - TRANSCEIVER_TXFAULT_ATTR_ID(19), - TRANSCEIVER_TXFAULT_ATTR_ID(20), - TRANSCEIVER_TXFAULT_ATTR_ID(21), - TRANSCEIVER_TXFAULT_ATTR_ID(22), - TRANSCEIVER_TXFAULT_ATTR_ID(23), - TRANSCEIVER_TXFAULT_ATTR_ID(24), - TRANSCEIVER_TXFAULT_ATTR_ID(25), - TRANSCEIVER_TXFAULT_ATTR_ID(26), - TRANSCEIVER_TXFAULT_ATTR_ID(27), - TRANSCEIVER_TXFAULT_ATTR_ID(28), - TRANSCEIVER_TXFAULT_ATTR_ID(29), - TRANSCEIVER_TXFAULT_ATTR_ID(30), - TRANSCEIVER_TXFAULT_ATTR_ID(31), - TRANSCEIVER_TXFAULT_ATTR_ID(32), - TRANSCEIVER_TXFAULT_ATTR_ID(33), - TRANSCEIVER_TXFAULT_ATTR_ID(34), - TRANSCEIVER_TXFAULT_ATTR_ID(35), - TRANSCEIVER_TXFAULT_ATTR_ID(36), - TRANSCEIVER_TXFAULT_ATTR_ID(37), - TRANSCEIVER_TXFAULT_ATTR_ID(38), - TRANSCEIVER_TXFAULT_ATTR_ID(39), - TRANSCEIVER_TXFAULT_ATTR_ID(40), - TRANSCEIVER_TXFAULT_ATTR_ID(41), - TRANSCEIVER_TXFAULT_ATTR_ID(42), - TRANSCEIVER_TXFAULT_ATTR_ID(43), - TRANSCEIVER_TXFAULT_ATTR_ID(44), - TRANSCEIVER_TXFAULT_ATTR_ID(45), - TRANSCEIVER_TXFAULT_ATTR_ID(46), - TRANSCEIVER_TXFAULT_ATTR_ID(47), - TRANSCEIVER_TXFAULT_ATTR_ID(48), -}; - -/* sysfs attributes for hwmon - */ -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf); -static int as5812_54x_cpld_read_internal(struct i2c_client *client, u8 reg); -static int as5812_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); - -/* transceiver attributes */ -#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ - static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) -#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr - -#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ - static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ - static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ - static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) -#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ - &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ - &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ - &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr - -static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); -/* transceiver attributes */ -static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); -static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); - -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); -DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); - -static struct attribute *as5812_54x_cpld1_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - NULL -}; - -static const struct attribute_group as5812_54x_cpld1_group = { - .attrs = as5812_54x_cpld1_attributes, -}; - -static struct attribute *as5812_54x_cpld2_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - &sensor_dev_attr_module_rx_los_all.dev_attr.attr, - DECLARE_TRANSCEIVER_PRESENT_ATTR(1), - DECLARE_TRANSCEIVER_PRESENT_ATTR(2), - DECLARE_TRANSCEIVER_PRESENT_ATTR(3), - DECLARE_TRANSCEIVER_PRESENT_ATTR(4), - DECLARE_TRANSCEIVER_PRESENT_ATTR(5), - DECLARE_TRANSCEIVER_PRESENT_ATTR(6), - DECLARE_TRANSCEIVER_PRESENT_ATTR(7), - DECLARE_TRANSCEIVER_PRESENT_ATTR(8), - DECLARE_TRANSCEIVER_PRESENT_ATTR(9), - DECLARE_TRANSCEIVER_PRESENT_ATTR(10), - DECLARE_TRANSCEIVER_PRESENT_ATTR(11), - DECLARE_TRANSCEIVER_PRESENT_ATTR(12), - DECLARE_TRANSCEIVER_PRESENT_ATTR(13), - DECLARE_TRANSCEIVER_PRESENT_ATTR(14), - DECLARE_TRANSCEIVER_PRESENT_ATTR(15), - DECLARE_TRANSCEIVER_PRESENT_ATTR(16), - DECLARE_TRANSCEIVER_PRESENT_ATTR(17), - DECLARE_TRANSCEIVER_PRESENT_ATTR(18), - DECLARE_TRANSCEIVER_PRESENT_ATTR(19), - DECLARE_TRANSCEIVER_PRESENT_ATTR(20), - DECLARE_TRANSCEIVER_PRESENT_ATTR(21), - DECLARE_TRANSCEIVER_PRESENT_ATTR(22), - DECLARE_TRANSCEIVER_PRESENT_ATTR(23), - DECLARE_TRANSCEIVER_PRESENT_ATTR(24), - DECLARE_SFP_TRANSCEIVER_ATTR(1), - DECLARE_SFP_TRANSCEIVER_ATTR(2), - DECLARE_SFP_TRANSCEIVER_ATTR(3), - DECLARE_SFP_TRANSCEIVER_ATTR(4), - DECLARE_SFP_TRANSCEIVER_ATTR(5), - DECLARE_SFP_TRANSCEIVER_ATTR(6), - DECLARE_SFP_TRANSCEIVER_ATTR(7), - DECLARE_SFP_TRANSCEIVER_ATTR(8), - DECLARE_SFP_TRANSCEIVER_ATTR(9), - DECLARE_SFP_TRANSCEIVER_ATTR(10), - DECLARE_SFP_TRANSCEIVER_ATTR(11), - DECLARE_SFP_TRANSCEIVER_ATTR(12), - DECLARE_SFP_TRANSCEIVER_ATTR(13), - DECLARE_SFP_TRANSCEIVER_ATTR(14), - DECLARE_SFP_TRANSCEIVER_ATTR(15), - DECLARE_SFP_TRANSCEIVER_ATTR(16), - DECLARE_SFP_TRANSCEIVER_ATTR(17), - DECLARE_SFP_TRANSCEIVER_ATTR(18), - DECLARE_SFP_TRANSCEIVER_ATTR(19), - DECLARE_SFP_TRANSCEIVER_ATTR(20), - DECLARE_SFP_TRANSCEIVER_ATTR(21), - DECLARE_SFP_TRANSCEIVER_ATTR(22), - DECLARE_SFP_TRANSCEIVER_ATTR(23), - DECLARE_SFP_TRANSCEIVER_ATTR(24), - NULL -}; - -static const struct attribute_group as5812_54x_cpld2_group = { - .attrs = as5812_54x_cpld2_attributes, -}; - -static struct attribute *as5812_54x_cpld3_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - &sensor_dev_attr_module_rx_los_all.dev_attr.attr, - DECLARE_TRANSCEIVER_PRESENT_ATTR(25), - DECLARE_TRANSCEIVER_PRESENT_ATTR(26), - DECLARE_TRANSCEIVER_PRESENT_ATTR(27), - DECLARE_TRANSCEIVER_PRESENT_ATTR(28), - DECLARE_TRANSCEIVER_PRESENT_ATTR(29), - DECLARE_TRANSCEIVER_PRESENT_ATTR(30), - DECLARE_TRANSCEIVER_PRESENT_ATTR(31), - DECLARE_TRANSCEIVER_PRESENT_ATTR(32), - DECLARE_TRANSCEIVER_PRESENT_ATTR(33), - DECLARE_TRANSCEIVER_PRESENT_ATTR(34), - DECLARE_TRANSCEIVER_PRESENT_ATTR(35), - DECLARE_TRANSCEIVER_PRESENT_ATTR(36), - DECLARE_TRANSCEIVER_PRESENT_ATTR(37), - DECLARE_TRANSCEIVER_PRESENT_ATTR(38), - DECLARE_TRANSCEIVER_PRESENT_ATTR(39), - DECLARE_TRANSCEIVER_PRESENT_ATTR(40), - DECLARE_TRANSCEIVER_PRESENT_ATTR(41), - DECLARE_TRANSCEIVER_PRESENT_ATTR(42), - DECLARE_TRANSCEIVER_PRESENT_ATTR(43), - DECLARE_TRANSCEIVER_PRESENT_ATTR(44), - DECLARE_TRANSCEIVER_PRESENT_ATTR(45), - DECLARE_TRANSCEIVER_PRESENT_ATTR(46), - DECLARE_TRANSCEIVER_PRESENT_ATTR(47), - DECLARE_TRANSCEIVER_PRESENT_ATTR(48), - DECLARE_TRANSCEIVER_PRESENT_ATTR(49), - DECLARE_TRANSCEIVER_PRESENT_ATTR(50), - DECLARE_TRANSCEIVER_PRESENT_ATTR(51), - DECLARE_TRANSCEIVER_PRESENT_ATTR(52), - DECLARE_TRANSCEIVER_PRESENT_ATTR(53), - DECLARE_TRANSCEIVER_PRESENT_ATTR(54), - DECLARE_SFP_TRANSCEIVER_ATTR(25), - DECLARE_SFP_TRANSCEIVER_ATTR(26), - DECLARE_SFP_TRANSCEIVER_ATTR(27), - DECLARE_SFP_TRANSCEIVER_ATTR(28), - DECLARE_SFP_TRANSCEIVER_ATTR(29), - DECLARE_SFP_TRANSCEIVER_ATTR(30), - DECLARE_SFP_TRANSCEIVER_ATTR(31), - DECLARE_SFP_TRANSCEIVER_ATTR(32), - DECLARE_SFP_TRANSCEIVER_ATTR(33), - DECLARE_SFP_TRANSCEIVER_ATTR(34), - DECLARE_SFP_TRANSCEIVER_ATTR(35), - DECLARE_SFP_TRANSCEIVER_ATTR(36), - DECLARE_SFP_TRANSCEIVER_ATTR(37), - DECLARE_SFP_TRANSCEIVER_ATTR(38), - DECLARE_SFP_TRANSCEIVER_ATTR(39), - DECLARE_SFP_TRANSCEIVER_ATTR(40), - DECLARE_SFP_TRANSCEIVER_ATTR(41), - DECLARE_SFP_TRANSCEIVER_ATTR(42), - DECLARE_SFP_TRANSCEIVER_ATTR(43), - DECLARE_SFP_TRANSCEIVER_ATTR(44), - DECLARE_SFP_TRANSCEIVER_ATTR(45), - DECLARE_SFP_TRANSCEIVER_ATTR(46), - DECLARE_SFP_TRANSCEIVER_ATTR(47), - DECLARE_SFP_TRANSCEIVER_ATTR(48), - NULL -}; - -static const struct attribute_group as5812_54x_cpld3_group = { - .attrs = as5812_54x_cpld3_attributes, -}; - -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf) -{ - int i, status, num_regs = 0; - u8 values[4] = {0}; - u8 regs[] = {0x6, 0x7, 0x8, 0x14}; - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - num_regs = (data->type == as5812_54x_cpld2) ? 3 : 4; - - for (i = 0; i < num_regs; i++) { - status = as5812_54x_cpld_read_internal(client, regs[i]); - - if (status < 0) { - goto exit; - } - - values[i] = ~(u8)status; - } - - mutex_unlock(&data->update_lock); - - /* Return values 1 -> 54 in order */ - if (data->type == as5812_54x_cpld2) { - status = sprintf(buf, "%.2x %.2x %.2x\n", - values[0], values[1], values[2]); - } - else { /* as5812_54x_cpld3 */ - values[3] &= 0x3F; - status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", - values[0], values[1], values[2], values[3]); - } - - return status; - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, - char *buf) -{ - int i, status; - u8 values[3] = {0}; - u8 regs[] = {0xF, 0x10, 0x11}; - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = as5812_54x_cpld_read_internal(client, regs[i]); - - if (status < 0) { - goto exit; - } - - values[i] = (u8)status; - } - - mutex_unlock(&data->update_lock); - - /* Return values 1 -> 24 in order */ - return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_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 as5812_54x_cpld_data *data = i2c_get_clientdata(client); - int status = 0; - u8 reg = 0, mask = 0, revert = 0; - - switch (attr->index) { - case MODULE_PRESENT_1 ... MODULE_PRESENT_8: - reg = 0x6; - mask = 0x1 << (attr->index - MODULE_PRESENT_1); - break; - case MODULE_PRESENT_9 ... MODULE_PRESENT_16: - reg = 0x7; - mask = 0x1 << (attr->index - MODULE_PRESENT_9); - break; - case MODULE_PRESENT_17 ... MODULE_PRESENT_24: - reg = 0x8; - mask = 0x1 << (attr->index - MODULE_PRESENT_17); - break; - case MODULE_PRESENT_25 ... MODULE_PRESENT_32: - reg = 0x6; - mask = 0x1 << (attr->index - MODULE_PRESENT_25); - break; - case MODULE_PRESENT_33 ... MODULE_PRESENT_40: - reg = 0x7; - mask = 0x1 << (attr->index - MODULE_PRESENT_33); - break; - case MODULE_PRESENT_41 ... MODULE_PRESENT_48: - reg = 0x8; - mask = 0x1 << (attr->index - MODULE_PRESENT_41); - break; - case MODULE_PRESENT_49: - reg = 0x14; - mask = 0x1; - break; - case MODULE_PRESENT_50: - reg = 0x14; - mask = 0x4; - break; - case MODULE_PRESENT_51: - reg = 0x14; - mask = 0x10; - break; - case MODULE_PRESENT_52: - reg = 0x14; - mask = 0x2; - break; - case MODULE_PRESENT_53: - reg = 0x14; - mask = 0x8; - break; - case MODULE_PRESENT_54: - reg = 0x14; - mask = 0x20; - break; - case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: - reg = 0x9; - mask = 0x1 << (attr->index - MODULE_TXFAULT_1); - break; - case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: - reg = 0xA; - mask = 0x1 << (attr->index - MODULE_TXFAULT_9); - break; - case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: - reg = 0xB; - mask = 0x1 << (attr->index - MODULE_TXFAULT_17); - break; - case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: - reg = 0x9; - mask = 0x1 << (attr->index - MODULE_TXFAULT_25); - break; - case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: - reg = 0xA; - mask = 0x1 << (attr->index - MODULE_TXFAULT_33); - break; - case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: - reg = 0xB; - mask = 0x1 << (attr->index - MODULE_TXFAULT_41); - break; - case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); - break; - case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); - break; - case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); - break; - case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); - break; - case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); - break; - case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); - break; - case MODULE_RXLOS_1 ... MODULE_RXLOS_8: - reg = 0xF; - mask = 0x1 << (attr->index - MODULE_RXLOS_1); - break; - case MODULE_RXLOS_9 ... MODULE_RXLOS_16: - reg = 0x10; - mask = 0x1 << (attr->index - MODULE_RXLOS_9); - break; - case MODULE_RXLOS_17 ... MODULE_RXLOS_24: - reg = 0x11; - mask = 0x1 << (attr->index - MODULE_RXLOS_17); - break; - case MODULE_RXLOS_25 ... MODULE_RXLOS_32: - reg = 0xF; - mask = 0x1 << (attr->index - MODULE_RXLOS_25); - break; - case MODULE_RXLOS_33 ... MODULE_RXLOS_40: - reg = 0x10; - mask = 0x1 << (attr->index - MODULE_RXLOS_33); - break; - case MODULE_RXLOS_41 ... MODULE_RXLOS_48: - reg = 0x11; - mask = 0x1 << (attr->index - MODULE_RXLOS_41); - break; - default: - return 0; - } - - if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { - revert = 1; - } - - mutex_lock(&data->update_lock); - status = as5812_54x_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); - long disable; - int status; - u8 reg = 0, mask = 0; - - status = kstrtol(buf, 10, &disable); - if (status) { - return status; - } - - switch (attr->index) { - case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); - break; - case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); - break; - case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); - break; - case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: - reg = 0xC; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); - break; - case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: - reg = 0xD; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); - break; - case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: - reg = 0xE; - mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); - break; - default: - return 0; - } - - /* Read current status */ - mutex_lock(&data->update_lock); - status = as5812_54x_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - - /* Update tx_disable status */ - if (disable) { - status |= mask; - } - else { - status &= ~mask; - } - - status = as5812_54x_cpld_write_internal(client, reg, status); - if (unlikely(status < 0)) { - goto exit; - } - - mutex_unlock(&data->update_lock); - return count; - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int status; - u32 addr, val; - struct i2c_client *client = to_i2c_client(dev); - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); - - if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { - return -EINVAL; - } - - if (addr > 0xFF || val > 0xFF) { - return -EINVAL; - } - - mutex_lock(&data->update_lock); - status = as5812_54x_cpld_write_internal(client, addr, val); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - return count; - -exit: - mutex_unlock(&data->update_lock); - return status; -} +MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int as5812_54x_cpld_mux_reg_write(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, struct i2c_client *client, u8 val) { unsigned long orig_jiffies; @@ -950,35 +149,35 @@ static int as5812_54x_cpld_mux_reg_write(struct i2c_adapter *adap, return res; } -static int as5812_54x_cpld_mux_select_chan(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, void *client, u32 chan) { - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); u8 regval; int ret = 0; regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = as5812_54x_cpld_mux_reg_write(adap, client, regval); + ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int as5812_54x_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return as5812_54x_cpld_mux_reg_write(adap, client, data->last_chan); + return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); } -static void as5812_54x_cpld_add_client(struct i2c_client *client) +static void accton_i2c_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -994,7 +193,7 @@ static void as5812_54x_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void as5812_54x_cpld_remove_client(struct i2c_client *client) +static void accton_i2c_cpld_remove_client(struct i2c_client *client) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -1020,178 +219,107 @@ static void as5812_54x_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) { - int val = 0; - struct i2c_client *client = to_i2c_client(dev); - - val = i2c_smbus_read_byte_data(client, 0x1); + u8 reg = 0x1; + struct i2c_client *client; + int len; - if (val < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); - } - - return sprintf(buf, "%d", val); + client = to_i2c_client(dev); + len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); + + return len; } +static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); + /* * I2C init/probing/exit functions */ -static int as5812_54x_cpld_mux_probe(struct i2c_client *client, +static int accton_i2c_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct as5812_54x_cpld_data *data; + struct accton_i2c_cpld_mux *data; int ret = -ENODEV; - const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto exit; + goto err; - data = kzalloc(sizeof(struct as5812_54x_cpld_data), GFP_KERNEL); + data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto exit; + goto err; } i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); + data->type = id->driver_data; if (data->type == as5812_54x_cpld2 || data->type == as5812_54x_cpld3) { data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ - for (chan = 0; chan < chips[data->type].nchans; chan++) { - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, - as5812_54x_cpld_mux_select_chan, - as5812_54x_cpld_mux_deselect_mux); + /* Now create an adapter for each channel */ + for (chan = 0; chan < chips[data->type].nchans; chan++) { + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + I2C_CLASS_HWMON | I2C_CLASS_SPD, +#endif + accton_i2c_cpld_mux_select_chan, + accton_i2c_cpld_mux_deselect_mux); - if (data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto exit_mux_register; - } - } - - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); - } - - /* Register sysfs hooks */ - switch (data->type) { - case as5812_54x_cpld1: - group = &as5812_54x_cpld1_group; - break; - case as5812_54x_cpld2: - group = &as5812_54x_cpld2_group; - break; - case as5812_54x_cpld3: - group = &as5812_54x_cpld3_group; - break; - default: - break; - } - - - if (group) { - ret = sysfs_create_group(&client->dev.kobj, group); - if (ret) { - goto exit_mux_register; + if (data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); + goto virt_reg_failed; } } - as5812_54x_cpld_add_client(client); + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); + } + + accton_i2c_cpld_add_client(client); + + ret = sysfs_create_file(&client->dev.kobj, &ver.attr); + if (ret) + goto virt_reg_failed; return 0; -exit_mux_register: +virt_reg_failed: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); } - kfree(data); -exit: + + kfree(data); +err: return ret; } -static int as5812_54x_cpld_mux_remove(struct i2c_client *client) +static int accton_i2c_cpld_mux_remove(struct i2c_client *client) { - struct as5812_54x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); const struct chip_desc *chip = &chips[data->type]; int chan; - const struct attribute_group *group = NULL; - as5812_54x_cpld_remove_client(client); - - /* Remove sysfs hooks */ - switch (data->type) { - case as5812_54x_cpld1: - group = &as5812_54x_cpld1_group; - break; - case as5812_54x_cpld2: - group = &as5812_54x_cpld2_group; - break; - case as5812_54x_cpld3: - group = &as5812_54x_cpld3_group; - break; - default: - break; - } - - if (group) { - sysfs_remove_group(&client->dev.kobj, group); - } + sysfs_remove_file(&client->dev.kobj, &ver.attr); for (chan = 0; chan < chip->nchans; ++chan) { - if (data->virt_adaps[chan]) { - i2c_del_mux_adapter(data->virt_adaps[chan]); - data->virt_adaps[chan] = NULL; - } + if (data->virt_adaps[chan]) { + i2c_del_mux_adapter(data->virt_adaps[chan]); + data->virt_adaps[chan] = NULL; + } } kfree(data); + accton_i2c_cpld_remove_client(client); return 0; } -static int as5812_54x_cpld_read_internal(struct i2c_client *client, u8 reg) -{ - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_read_byte_data(client, reg); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -static int as5812_54x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) -{ - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, reg, value); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg) +int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -1201,21 +329,21 @@ int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = as5812_54x_cpld_read_internal(cpld_node->client, reg); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5812_54x_cpld_read); +EXPORT_SYMBOL(as5812_54x_i2c_cpld_read); -int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -1225,45 +353,44 @@ int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = as5812_54x_cpld_write_internal(cpld_node->client, reg, value); - break; - } + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } } mutex_unlock(&list_lock); return ret; } -EXPORT_SYMBOL(as5812_54x_cpld_write); +EXPORT_SYMBOL(as5812_54x_i2c_cpld_write); -static struct i2c_driver as5812_54x_cpld_mux_driver = { +static struct i2c_driver accton_i2c_cpld_mux_driver = { .driver = { .name = "as5812_54x_cpld", .owner = THIS_MODULE, }, - .probe = as5812_54x_cpld_mux_probe, - .remove = as5812_54x_cpld_mux_remove, - .id_table = as5812_54x_cpld_mux_id, + .probe = accton_i2c_cpld_mux_probe, + .remove = accton_i2c_cpld_mux_remove, + .id_table = accton_i2c_cpld_mux_id, }; -static int __init as5812_54x_cpld_mux_init(void) +static int __init accton_i2c_cpld_mux_init(void) { mutex_init(&list_lock); - return i2c_add_driver(&as5812_54x_cpld_mux_driver); + return i2c_add_driver(&accton_i2c_cpld_mux_driver); } -static void __exit as5812_54x_cpld_mux_exit(void) +static void __exit accton_i2c_cpld_mux_exit(void) { - i2c_del_driver(&as5812_54x_cpld_mux_driver); + i2c_del_driver(&accton_i2c_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(as5812_54x_cpld_mux_init); -module_exit(as5812_54x_cpld_mux_exit); - +module_init(accton_i2c_cpld_mux_init); +module_exit(accton_i2c_cpld_mux_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c index 2521a469..4c3cdeab 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-fan.c @@ -131,8 +131,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -258,12 +258,12 @@ static const struct attribute_group accton_as5812_54x_fan_group = { static int accton_as5812_54x_fan_read_value(u8 reg) { - return as5812_54x_cpld_read(0x60, reg); + return as5812_54x_i2c_cpld_read(0x60, reg); } static int accton_as5812_54x_fan_write_value(u8 reg, u8 value) { - return as5812_54x_cpld_write(0x60, reg, value); + return as5812_54x_i2c_cpld_write(0x60, reg, value); } static void accton_as5812_54x_fan_update_device(struct device *dev) @@ -393,7 +393,7 @@ static struct platform_driver accton_as5812_54x_fan_driver = { static int __init accton_as5812_54x_fan_init(void) { int ret; - + ret = platform_driver_register(&accton_as5812_54x_fan_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c index 0b8e46c4..f196f22c 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as5812_54x_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as5812_54x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as5812_54x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -220,12 +220,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as5812_54x_led_read_value(u8 reg) { - return as5812_54x_cpld_read(0x60, reg); + return as5812_54x_i2c_cpld_read(0x60, reg); } static int accton_as5812_54x_led_write_value(u8 reg, u8 value) { - return as5812_54x_cpld_write(0x60, reg, value); + return as5812_54x_i2c_cpld_write(0x60, reg, value); } static void accton_as5812_54x_led_update(void) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c index 9d52e544..2703897f 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-psu.c @@ -44,7 +44,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_serial_number(struct device *dev, struct device_attribute *da,char *buf); static int as5812_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as5812_54x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); static int as5812_54x_psu_model_name_get(struct device *dev , int get_serial); /* Addresses scanned @@ -406,7 +406,7 @@ static struct as5812_54x_psu_data *as5812_54x_psu_update_device(struct device *d /* Read psu status */ - status = as5812_54x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as5812_54x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -426,9 +426,20 @@ exit: return data; } -module_i2c_driver(as5812_54x_psu_driver); +static int __init as5812_54x_psu_init(void) +{ + return i2c_add_driver(&as5812_54x_psu_driver); +} + +static void __exit as5812_54x_psu_exit(void) +{ + i2c_del_driver(&as5812_54x_psu_driver); +} MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("accton as5812_54x_psu driver"); MODULE_LICENSE("GPL"); +module_init(as5812_54x_psu_init); +module_exit(as5812_54x_psu_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c new file mode 100644 index 00000000..44727e22 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/modules/builds/x86-64-accton-as5812-54x-sfp.c @@ -0,0 +1,508 @@ +/* + * An hwmon driver for accton as5812_54x sfp + * + * Copyright (C) 2015 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_OF_SFP_PORT 54 +#define BIT_INDEX(i) (1ULL << (i)) + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as5812_54x_sfp_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + int port; /* Front port index */ + char eeprom[256]; /* eeprom data */ + u64 status[4]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => is_present + 1 => tx_fail + 2 => tx_disable + 3 => rx_loss */ +}; + +/* The table maps active port to cpld port. + * Array index 0 is for active port 1, + * index 1 for active port 2, and so on. + * The array content implies cpld port index. + */ +static const u8 cpld_to_front_port_table[] = +{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 52, 50, 53, 51, 54}; + +#define CPLD_PORT_TO_FRONT_PORT(port) (cpld_to_front_port_table[port]) + +static struct as5812_54x_sfp_data *as5812_54x_sfp_update_device(struct device *dev, int update_eeprom); +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +extern int as5812_54x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5812_54x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +enum as5812_54x_sfp_sysfs_attributes { + SFP_IS_PRESENT, + SFP_TX_FAULT, + SFP_TX_DISABLE, + SFP_RX_LOSS, + SFP_PORT_NUMBER, + SFP_EEPROM, + SFP_RX_LOS_ALL, + SFP_IS_PRESENT_ALL, +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_status, NULL, SFP_IS_PRESENT); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, show_status, NULL, SFP_TX_FAULT); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, show_status, set_tx_disable, SFP_TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_rx_loss, S_IRUGO, show_status,NULL, SFP_RX_LOSS); +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, SFP_PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_eeprom, S_IRUGO, show_eeprom, NULL, SFP_EEPROM); +static SENSOR_DEVICE_ATTR(sfp_rx_los_all, S_IRUGO, show_status,NULL, SFP_RX_LOS_ALL); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_status,NULL, SFP_IS_PRESENT_ALL); + +static struct attribute *as5812_54x_sfp_attributes[] = { + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_rx_loss.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_eeprom.dev_attr.attr, + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los_all.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + NULL +}; + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); + + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5812_54x_sfp_data *data; + u8 val; + int values[7]; + + /* Error-check the CPLD read results. */ +#define VALIDATED_READ(_buf, _rv, _read_expr, _invert) \ + do { \ + _rv = (_read_expr); \ + if(_rv < 0) { \ + return sprintf(_buf, "READ ERROR\n"); \ + } \ + if(_invert) { \ + _rv = ~_rv; \ + } \ + _rv &= 0xFF; \ + } while(0) + + if(attr->index == SFP_RX_LOS_ALL) { + /* + * Report the RX_LOS status for all ports. + * This does not depend on the currently active SFP selector. + */ + + /* RX_LOS Ports 1-8 */ + VALIDATED_READ(buf, values[0], as5812_54x_i2c_cpld_read(0x61, 0x0F), 0); + /* RX_LOS Ports 9-16 */ + VALIDATED_READ(buf, values[1], as5812_54x_i2c_cpld_read(0x61, 0x10), 0); + /* RX_LOS Ports 17-24 */ + VALIDATED_READ(buf, values[2], as5812_54x_i2c_cpld_read(0x61, 0x11), 0); + /* RX_LOS Ports 25-32 */ + VALIDATED_READ(buf, values[3], as5812_54x_i2c_cpld_read(0x62, 0x0F), 0); + /* RX_LOS Ports 33-40 */ + VALIDATED_READ(buf, values[4], as5812_54x_i2c_cpld_read(0x62, 0x10), 0); + /* RX_LOS Ports 41-48 */ + VALIDATED_READ(buf, values[5], as5812_54x_i2c_cpld_read(0x62, 0x11), 0); + + /** Return values 1 -> 48 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5]); + } + + if(attr->index == SFP_IS_PRESENT_ALL) { + /* + * Report the SFP_PRESENCE status for all ports. + * This does not depend on the currently active SFP selector. + */ + + /* SFP_PRESENT Ports 1-8 */ + VALIDATED_READ(buf, values[0], as5812_54x_i2c_cpld_read(0x61, 0x6), 1); + /* SFP_PRESENT Ports 9-16 */ + VALIDATED_READ(buf, values[1], as5812_54x_i2c_cpld_read(0x61, 0x7), 1); + /* SFP_PRESENT Ports 17-24 */ + VALIDATED_READ(buf, values[2], as5812_54x_i2c_cpld_read(0x61, 0x8), 1); + /* SFP_PRESENT Ports 25-32 */ + VALIDATED_READ(buf, values[3], as5812_54x_i2c_cpld_read(0x62, 0x6), 1); + /* SFP_PRESENT Ports 33-40 */ + VALIDATED_READ(buf, values[4], as5812_54x_i2c_cpld_read(0x62, 0x7), 1); + /* SFP_PRESENT Ports 41-48 */ + VALIDATED_READ(buf, values[5], as5812_54x_i2c_cpld_read(0x62, 0x8), 1); + /* QSFP_PRESENT Ports 49-54 */ + VALIDATED_READ(buf, values[6], as5812_54x_i2c_cpld_read(0x62, 0x14), 1); + + /* Return values 1 -> 54 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3], values[4], values[5], + values[6] & 0x3F); + } + /* + * The remaining attributes are gathered on a per-selected-sfp basis. + */ + data = as5812_54x_sfp_update_device(dev, 0); + if (attr->index == SFP_IS_PRESENT) { + val = (data->status[attr->index] & BIT_INDEX(data->port)) ? 0 : 1; + } + else { + val = (data->status[attr->index] & BIT_INDEX(data->port)) ? 1 : 0; + } + + return sprintf(buf, "%d", val); +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); + unsigned short cpld_addr = 0; + u8 cpld_reg = 0, cpld_val = 0, cpld_bit = 0; + long disable; + int error; + + /* Tx disable is not supported for QSFP ports(49-54) */ + if (data->port >= 48) { + return -EINVAL; + } + + error = kstrtol(buf, 10, &disable); + if (error) { + return error; + } + + mutex_lock(&data->update_lock); + + if(data->port < 24) { + cpld_addr = 0x61; + cpld_reg = 0xC + data->port / 8; + cpld_bit = 1 << (data->port % 8); + } + else { + cpld_addr = 0x62; + cpld_reg = 0xC + (data->port - 24) / 8; + cpld_bit = 1 << (data->port % 8); + } + + cpld_val = as5812_54x_i2c_cpld_read(cpld_addr, cpld_reg); + + /* Update tx_disable status */ + if (disable) { + data->status[SFP_TX_DISABLE] |= BIT_INDEX(data->port); + cpld_val |= cpld_bit; + } + else { + data->status[SFP_TX_DISABLE] &= ~BIT_INDEX(data->port); + cpld_val &= ~cpld_bit; + } + + as5812_54x_i2c_cpld_write(cpld_addr, cpld_reg, cpld_val); + + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_eeprom(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as5812_54x_sfp_data *data = as5812_54x_sfp_update_device(dev, 1); + + if (!data->valid) { + return 0; + } + + if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) != 0) { + return 0; + } + + memcpy(buf, data->eeprom, sizeof(data->eeprom)); + + return sizeof(data->eeprom); +} + +static const struct attribute_group as5812_54x_sfp_group = { + .attrs = as5812_54x_sfp_attributes, +}; + +static int as5812_54x_sfp_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as5812_54x_sfp_data *data; + int status; + + extern int platform_accton_as5812_54x(void); + if(!platform_accton_as5812_54x()) { + return -ENODEV; + } + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as5812_54x_sfp_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + i2c_set_clientdata(client, data); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5812_54x_sfp_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sfp '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as5812_54x_sfp_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as5812_54x_sfp_remove(struct i2c_client *client) +{ + struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as5812_54x_sfp_group); + kfree(data); + + return 0; +} + +enum port_numbers { +as5812_54x_sfp1, as5812_54x_sfp2, as5812_54x_sfp3, as5812_54x_sfp4, +as5812_54x_sfp5, as5812_54x_sfp6, as5812_54x_sfp7, as5812_54x_sfp8, +as5812_54x_sfp9, as5812_54x_sfp10, as5812_54x_sfp11,as5812_54x_sfp12, +as5812_54x_sfp13, as5812_54x_sfp14, as5812_54x_sfp15,as5812_54x_sfp16, +as5812_54x_sfp17, as5812_54x_sfp18, as5812_54x_sfp19,as5812_54x_sfp20, +as5812_54x_sfp21, as5812_54x_sfp22, as5812_54x_sfp23,as5812_54x_sfp24, +as5812_54x_sfp25, as5812_54x_sfp26, as5812_54x_sfp27,as5812_54x_sfp28, +as5812_54x_sfp29, as5812_54x_sfp30, as5812_54x_sfp31,as5812_54x_sfp32, +as5812_54x_sfp33, as5812_54x_sfp34, as5812_54x_sfp35,as5812_54x_sfp36, +as5812_54x_sfp37, as5812_54x_sfp38, as5812_54x_sfp39,as5812_54x_sfp40, +as5812_54x_sfp41, as5812_54x_sfp42, as5812_54x_sfp43,as5812_54x_sfp44, +as5812_54x_sfp45, as5812_54x_sfp46, as5812_54x_sfp47,as5812_54x_sfp48, +as5812_54x_sfp49, as5812_54x_sfp52, as5812_54x_sfp50,as5812_54x_sfp53, +as5812_54x_sfp51, as5812_54x_sfp54 +}; + +static const struct i2c_device_id as5812_54x_sfp_id[] = { +{ "as5812_54x_sfp1", as5812_54x_sfp1 }, { "as5812_54x_sfp2", as5812_54x_sfp2 }, +{ "as5812_54x_sfp3", as5812_54x_sfp3 }, { "as5812_54x_sfp4", as5812_54x_sfp4 }, +{ "as5812_54x_sfp5", as5812_54x_sfp5 }, { "as5812_54x_sfp6", as5812_54x_sfp6 }, +{ "as5812_54x_sfp7", as5812_54x_sfp7 }, { "as5812_54x_sfp8", as5812_54x_sfp8 }, +{ "as5812_54x_sfp9", as5812_54x_sfp9 }, { "as5812_54x_sfp10", as5812_54x_sfp10 }, +{ "as5812_54x_sfp11", as5812_54x_sfp11 }, { "as5812_54x_sfp12", as5812_54x_sfp12 }, +{ "as5812_54x_sfp13", as5812_54x_sfp13 }, { "as5812_54x_sfp14", as5812_54x_sfp14 }, +{ "as5812_54x_sfp15", as5812_54x_sfp15 }, { "as5812_54x_sfp16", as5812_54x_sfp16 }, +{ "as5812_54x_sfp17", as5812_54x_sfp17 }, { "as5812_54x_sfp18", as5812_54x_sfp18 }, +{ "as5812_54x_sfp19", as5812_54x_sfp19 }, { "as5812_54x_sfp20", as5812_54x_sfp20 }, +{ "as5812_54x_sfp21", as5812_54x_sfp21 }, { "as5812_54x_sfp22", as5812_54x_sfp22 }, +{ "as5812_54x_sfp23", as5812_54x_sfp23 }, { "as5812_54x_sfp24", as5812_54x_sfp24 }, +{ "as5812_54x_sfp25", as5812_54x_sfp25 }, { "as5812_54x_sfp26", as5812_54x_sfp26 }, +{ "as5812_54x_sfp27", as5812_54x_sfp27 }, { "as5812_54x_sfp28", as5812_54x_sfp28 }, +{ "as5812_54x_sfp29", as5812_54x_sfp29 }, { "as5812_54x_sfp30", as5812_54x_sfp30 }, +{ "as5812_54x_sfp31", as5812_54x_sfp31 }, { "as5812_54x_sfp32", as5812_54x_sfp32 }, +{ "as5812_54x_sfp33", as5812_54x_sfp33 }, { "as5812_54x_sfp34", as5812_54x_sfp34 }, +{ "as5812_54x_sfp35", as5812_54x_sfp35 }, { "as5812_54x_sfp36", as5812_54x_sfp36 }, +{ "as5812_54x_sfp37", as5812_54x_sfp37 }, { "as5812_54x_sfp38", as5812_54x_sfp38 }, +{ "as5812_54x_sfp39", as5812_54x_sfp39 }, { "as5812_54x_sfp40", as5812_54x_sfp40 }, +{ "as5812_54x_sfp41", as5812_54x_sfp41 }, { "as5812_54x_sfp42", as5812_54x_sfp42 }, +{ "as5812_54x_sfp43", as5812_54x_sfp43 }, { "as5812_54x_sfp44", as5812_54x_sfp44 }, +{ "as5812_54x_sfp45", as5812_54x_sfp45 }, { "as5812_54x_sfp46", as5812_54x_sfp46 }, +{ "as5812_54x_sfp47", as5812_54x_sfp47 }, { "as5812_54x_sfp48", as5812_54x_sfp48 }, +{ "as5812_54x_sfp49", as5812_54x_sfp49 }, { "as5812_54x_sfp50", as5812_54x_sfp50 }, +{ "as5812_54x_sfp51", as5812_54x_sfp51 }, { "as5812_54x_sfp52", as5812_54x_sfp52 }, +{ "as5812_54x_sfp53", as5812_54x_sfp53 }, { "as5812_54x_sfp54", as5812_54x_sfp54 }, + +{} +}; +MODULE_DEVICE_TABLE(i2c, as5812_54x_sfp_id); + +static struct i2c_driver as5812_54x_sfp_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as5812_54x_sfp", + }, + .probe = as5812_54x_sfp_probe, + .remove = as5812_54x_sfp_remove, + .id_table = as5812_54x_sfp_id, + .address_list = normal_i2c, +}; + +static int as5812_54x_sfp_read_byte(struct i2c_client *client, u8 command, u8 *data) +{ + int result = i2c_smbus_read_byte_data(client, command); + + if (unlikely(result < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, result); + goto abort; + } + + *data = (u8)result; + result = 0; + +abort: + return result; +} + +#define ALWAYS_UPDATE_DEVICE 1 + +static struct as5812_54x_sfp_data *as5812_54x_sfp_update_device(struct device *dev, int update_eeprom) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5812_54x_sfp_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (ALWAYS_UPDATE_DEVICE || time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status = -1; + int i = 0, j = 0; + + data->valid = 0; + //dev_dbg(&client->dev, "Starting as5812_54x sfp status update\n"); + memset(data->status, 0, sizeof(data->status)); + + /* Read status of port 1~48(SFP port) */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 12; j++) { + status = as5812_54x_i2c_cpld_read(0x61+i, 0x6+j); + + if (status < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); + goto exit; + } + + data->status[j/3] |= (u64)status << ((i*24) + (j%3)*8); + } + } + + /* + * Bring QSFPs out of reset, + * This is a temporary fix until the QSFP+_MOD_RST register + * can be exposed through the driver. + */ + as5812_54x_i2c_cpld_write(0x62, 0x15, 0x3F); + + /* Read present status of port 49-54(QSFP port) */ + status = as5812_54x_i2c_cpld_read(0x62, 0x14); + + if (status < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x%x) err %d\n", 0x61+i, 0x6+j, status); + } + else { + data->status[SFP_IS_PRESENT] |= (u64)status << 48; + } + + if (update_eeprom) { + /* Read eeprom data based on port number */ + memset(data->eeprom, 0, sizeof(data->eeprom)); + + /* Check if the port is present */ + if ((data->status[SFP_IS_PRESENT] & BIT_INDEX(data->port)) == 0) { + /* read eeprom */ + for (i = 0; i < sizeof(data->eeprom); i++) { + status = as5812_54x_sfp_read_byte(client, i, data->eeprom + i); + + if (status < 0) { + dev_dbg(&client->dev, "unable to read eeprom from port(%d)\n", + CPLD_PORT_TO_FRONT_PORT(data->port)); + goto exit; + } + } + } + } + + data->valid = 1; + data->last_updated = jiffies; + } + +exit: + mutex_unlock(&data->update_lock); + + return data; +} + +module_i2c_driver(as5812_54x_sfp_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as5812_54x_sfp driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c index f731e0d3..6cfa29a9 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/onlp/builds/src/module/src/sfpi.c @@ -24,24 +24,20 @@ * ***********************************************************/ #include -#include -#include -#include "x86_64_accton_as5812_54x_int.h" -#include "x86_64_accton_as5812_54x_log.h" +#include /* For O_RDWR && open */ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; #define CPLD_MUX_BUS_START_INDEX 2 -#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" -#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" -#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/0-00%d/module_rx_los_%d" -#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_fault_%d" -#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/0-00%d/module_tx_disable_%d" -#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_present_all" -#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_present_all" -#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0061/module_rx_los_all" -#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0062/module_rx_los_all" - -static int front_port_bus_index(int port) +static int front_port_to_cpld_mux_index(int port) { int rport = 0; @@ -67,6 +63,38 @@ static int front_port_bus_index(int port) return (rport + CPLD_MUX_BUS_START_INDEX); } +static int +as5812_54x_sfp_node_read_int(char *node_path, int *value, int data_len) +{ + int ret = 0; + char buf[8] = {0}; + *value = 0; + + ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len); + + if (ret == 0) { + *value = atoi(buf); + } + + return ret; +} + +static char* +as5812_54x_sfp_get_port_path_addr(int port, int addr, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s", + front_port_to_cpld_mux_index(port), addr, + node_name); + return sfp_node_path; +} + +static char* +as5812_54x_sfp_get_port_path(int port, char *node_name) +{ + return as5812_54x_sfp_get_port_path_addr(port, 50, node_name); +} + + /************************************************************ * * SFPI Entry Points @@ -175,10 +203,10 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - int addr = (port < 24) ? 61 : 62; - - if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + char* path = as5812_54x_sfp_get_port_path(port, "sfp_is_present"); + + if (as5812_54x_sfp_node_read_int(path, &present, 1) != 0) { + AIM_LOG_INFO("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -189,35 +217,29 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[7]; + char* path; FILE* fp; - /* Read present status of port 0~23 */ - fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); + path = as5812_54x_sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); + if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD2."); + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } - - int count = fscanf(fp, "%x %x %x", bytes+0, bytes+1, bytes+2); + int count = fscanf(fp, "%x %x %x %x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3, + bytes+4, + bytes+5, + bytes+6 + ); fclose(fp); - if(count != 3) { + if(count != AIM_ARRAYSIZE(bytes)) { /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD2."); - return ONLP_STATUS_E_INTERNAL; - } - - /* Read present status of port 24~53 */ - fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); - return ONLP_STATUS_E_INTERNAL; - } - - count = fscanf(fp, "%x %x %x %x", bytes+3, bytes+4, bytes+5, bytes+6); - fclose(fp); - if(count != 4) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); return ONLP_STATUS_E_INTERNAL; } @@ -246,39 +268,33 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { - uint32_t bytes[6]; - uint32_t *ptr = bytes; + uint32_t bytes[7]; + char* path; FILE* fp; - /* Read present status of port 0~23 */ - int addr, i = 0; + path = as5812_54x_sfp_get_port_path(0, "sfp_rx_los_all"); + fp = fopen(path, "r"); - for (addr = 61; addr <= 62; addr++) { - if (addr == 61) { - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); - } - else { - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD3, "r"); - } - - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); - fclose(fp); - if(count != 3) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - ptr += count; + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3, + bytes+4, + bytes+5 + ); + fclose(fp); + if(count != 6) { + AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file."); + return ONLP_STATUS_E_INTERNAL; } /* Convert to 64 bit integer in port order */ - i = 0; + int i = 0; uint64_t rx_los_all = 0 ; for(i = 5; i >= 0; i--) { rx_los_all <<= 8; @@ -299,22 +315,18 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { + char* path = as5812_54x_sfp_get_port_path(port, "sfp_eeprom"); + /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ - int size = 0; memset(data, 0, 256); - if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, front_port_bus_index(port)) != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - if (size != 256) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -324,26 +336,11 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256]) int onlp_sfpi_dom_read(int port, uint8_t data[256]) { - FILE* fp; - char file[64] = {0}; - - sprintf(file, PORT_EEPROM_FORMAT, front_port_bus_index(port)); - fp = fopen(file, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } + char* path = as5812_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom"); + memset(data, 0, 256); - if (fseek(fp, 256, SEEK_CUR) != 0) { - fclose(fp); - AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } - - int ret = fread(data, 1, 256, fp); - fclose(fp); - if (ret != 256) { - AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { + AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } @@ -353,28 +350,28 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); } int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) { - int bus = front_port_bus_index(port); + int bus = front_port_to_cpld_mux_index(port); return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); } @@ -387,13 +384,13 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) return ONLP_STATUS_E_UNSUPPORTED; } - int addr = (port < 24) ? 61 : 62; - switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { + char* path = as5812_54x_sfp_get_port_path(port, "sfp_tx_disable"); + + if (deviceNodeWriteInt(path, value, 0) != 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -415,18 +412,19 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) { int rv; + char* path = NULL; if (port < 0 || port >= 48) { return ONLP_STATUS_E_UNSUPPORTED; } - int addr = (port < 24) ? 61 : 62; - switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, addr, (port+1)) < 0) { + path = as5812_54x_sfp_get_port_path(port, "sfp_rx_loss"); + + if (as5812_54x_sfp_node_read_int(path, value, 1) != 0) { AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -438,7 +436,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_FAULT: { - if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, addr, (port+1)) < 0) { + path = as5812_54x_sfp_get_port_path(port, "sfp_tx_fault"); + + if (as5812_54x_sfp_node_read_int(path, value, 1) != 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -450,7 +450,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) case ONLP_SFP_CONTROL_TX_DISABLE: { - if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, addr, (port+1)) < 0) { + path = as5812_54x_sfp_get_port_path(port, "sfp_tx_disable"); + + if (as5812_54x_sfp_node_read_int(path, value, 0) != 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py index b6505028..5eee6748 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5812-54x/platform-config/r0/src/python/x86_64_accton_as5812_54x_r0/__init__.py @@ -9,10 +9,9 @@ class OnlPlatform_x86_64_accton_as5812_54x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".5812.54.1" def baseconfig(self): - self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: self.insmod("x86-64-accton-as5812-54x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -27,18 +26,16 @@ class OnlPlatform_x86_64_accton_as5812_54x_r0(OnlPlatformAccton, ) # initialize SFP devices for port in range(1, 49): - self.new_i2c_device('optoe2', 0x50, port+1) - subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) + self.new_i2c_device('as5812_54x_sfp%d' % port, 0x50, port+1) + self.new_i2c_device('as5812_54x_sfp%d' % port, 0x51, port+1) # Initialize QSFP devices - for port in range(49, 55): - self.new_i2c_device('optoe1', 0x50, port+1) - subprocess.call('echo port49 > /sys/bus/i2c/devices/50-0050/port_name', shell=True) - subprocess.call('echo port52 > /sys/bus/i2c/devices/51-0050/port_name', shell=True) - subprocess.call('echo port50 > /sys/bus/i2c/devices/52-0050/port_name', shell=True) - subprocess.call('echo port53 > /sys/bus/i2c/devices/53-0050/port_name', shell=True) - subprocess.call('echo port51 > /sys/bus/i2c/devices/54-0050/port_name', shell=True) - subprocess.call('echo port54 > /sys/bus/i2c/devices/55-0050/port_name', shell=True) + self.new_i2c_device('as5812_54x_sfp49', 0x50, 50) + self.new_i2c_device('as5812_54x_sfp52', 0x50, 51) + self.new_i2c_device('as5812_54x_sfp50', 0x50, 52) + self.new_i2c_device('as5812_54x_sfp53', 0x50, 53) + self.new_i2c_device('as5812_54x_sfp51', 0x50, 54) + self.new_i2c_device('as5812_54x_sfp54', 0x50, 55) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From 53002164da5d6a839797f50cbfb366524c9bd179 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 11 Apr 2018 14:06:55 -0700 Subject: [PATCH 216/244] Revert "[as6812-32x] Add support for OOM" --- .../builds/x86-64-accton-as6812-32x-cpld.c | 639 ++----- .../builds/x86-64-accton-as6812-32x-fan.c | 13 +- .../builds/x86-64-accton-as6812-32x-leds.c | 13 +- .../builds/x86-64-accton-as6812-32x-psu.c | 16 +- .../builds/x86-64-accton-as6812-32x-sfp.c | 1532 +++++++++++++++++ .../onlp/builds/src/module/src/sfpi.c | 95 +- .../x86_64_accton_as6812_32x_r0/__init__.py | 8 +- 7 files changed, 1771 insertions(+), 545 deletions(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c index b42e5c2a..6c146767 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-cpld.c @@ -33,28 +33,44 @@ #include #include #include +#include #include -#include -#include -#include -#define I2C_RW_RETRY_COUNT 10 -#define I2C_RW_RETRY_INTERVAL 60 /* ms */ +static struct dmi_system_id as6812_dmi_table[] = { + { + .ident = "Accton AS6812", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS6812"), + }, + }, + { + .ident = "Accton AS6812", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Accton"), + DMI_MATCH(DMI_PRODUCT_NAME, "AS6812"), + }, + }, +}; + +int platform_accton_as6812_32x(void) +{ + return dmi_check_system(as6812_dmi_table); +} +EXPORT_SYMBOL(platform_accton_as6812_32x); #define NUM_OF_CPLD1_CHANS 0x0 #define NUM_OF_CPLD2_CHANS 0x10 #define NUM_OF_CPLD3_CHANS 0x10 -#define CPLD_CHANNEL_SELECT_REG 0x2 -#define CPLD_DESELECT_CHANNEL 0xFF - -#define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS +#define NUM_OF_ALL_CPLD_CHANS (NUM_OF_CPLD2_CHANS + NUM_OF_CPLD3_CHANS) +#define ACCTON_I2C_CPLD_MUX_MAX_NCHANS NUM_OF_CPLD3_CHANS static LIST_HEAD(cpld_client_list); -static struct mutex list_lock; +static struct mutex list_lock; struct cpld_client_node { - struct i2c_client *client; - struct list_head list; + struct i2c_client *client; + struct list_head list; }; enum cpld_mux_type { @@ -63,13 +79,10 @@ enum cpld_mux_type { as6812_32x_cpld1 }; -struct as6812_32x_cpld_data { - enum cpld_mux_type type; - struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; - u8 last_chan; /* last register value */ - - struct device *hwmon_dev; - struct mutex update_lock; +struct accton_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[ACCTON_I2C_CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ }; struct chip_desc { @@ -93,289 +106,18 @@ static const struct chip_desc chips[] = { } }; -static const struct i2c_device_id as6812_32x_cpld_mux_id[] = { +static const struct i2c_device_id accton_i2c_cpld_mux_id[] = { { "as6812_32x_cpld1", as6812_32x_cpld1 }, { "as6812_32x_cpld2", as6812_32x_cpld2 }, { "as6812_32x_cpld3", as6812_32x_cpld3 }, { } }; -MODULE_DEVICE_TABLE(i2c, as6812_32x_cpld_mux_id); - -#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index -#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index -#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index -#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index - -enum as6812_32x_cpld_sysfs_attributes { - CPLD_VERSION, - ACCESS, - MODULE_PRESENT_ALL, - MODULE_RXLOS_ALL, - /* transceiver attributes */ - TRANSCEIVER_PRESENT_ATTR_ID(1), - TRANSCEIVER_PRESENT_ATTR_ID(2), - TRANSCEIVER_PRESENT_ATTR_ID(3), - TRANSCEIVER_PRESENT_ATTR_ID(4), - TRANSCEIVER_PRESENT_ATTR_ID(5), - TRANSCEIVER_PRESENT_ATTR_ID(6), - TRANSCEIVER_PRESENT_ATTR_ID(7), - TRANSCEIVER_PRESENT_ATTR_ID(8), - TRANSCEIVER_PRESENT_ATTR_ID(9), - TRANSCEIVER_PRESENT_ATTR_ID(10), - TRANSCEIVER_PRESENT_ATTR_ID(11), - TRANSCEIVER_PRESENT_ATTR_ID(12), - TRANSCEIVER_PRESENT_ATTR_ID(13), - TRANSCEIVER_PRESENT_ATTR_ID(14), - TRANSCEIVER_PRESENT_ATTR_ID(15), - TRANSCEIVER_PRESENT_ATTR_ID(16), - TRANSCEIVER_PRESENT_ATTR_ID(17), - TRANSCEIVER_PRESENT_ATTR_ID(18), - TRANSCEIVER_PRESENT_ATTR_ID(19), - TRANSCEIVER_PRESENT_ATTR_ID(20), - TRANSCEIVER_PRESENT_ATTR_ID(21), - TRANSCEIVER_PRESENT_ATTR_ID(22), - TRANSCEIVER_PRESENT_ATTR_ID(23), - TRANSCEIVER_PRESENT_ATTR_ID(24), - TRANSCEIVER_PRESENT_ATTR_ID(25), - TRANSCEIVER_PRESENT_ATTR_ID(26), - TRANSCEIVER_PRESENT_ATTR_ID(27), - TRANSCEIVER_PRESENT_ATTR_ID(28), - TRANSCEIVER_PRESENT_ATTR_ID(29), - TRANSCEIVER_PRESENT_ATTR_ID(30), - TRANSCEIVER_PRESENT_ATTR_ID(31), - TRANSCEIVER_PRESENT_ATTR_ID(32), -}; - -/* sysfs attributes for hwmon - */ -static ssize_t show_status(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf); -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count); -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf); -static int as6812_32x_cpld_read_internal(struct i2c_client *client, u8 reg); -static int as6812_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); - -/* transceiver attributes */ -#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ - static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) -#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr - - -static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); -/* transceiver attributes */ -static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); -DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); - -static struct attribute *as6812_32x_cpld1_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - NULL -}; - -static const struct attribute_group as6812_32x_cpld1_group = { - .attrs = as6812_32x_cpld1_attributes, -}; - -static struct attribute *as6812_32x_cpld2_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - DECLARE_TRANSCEIVER_PRESENT_ATTR(1), - DECLARE_TRANSCEIVER_PRESENT_ATTR(2), - DECLARE_TRANSCEIVER_PRESENT_ATTR(3), - DECLARE_TRANSCEIVER_PRESENT_ATTR(4), - DECLARE_TRANSCEIVER_PRESENT_ATTR(5), - DECLARE_TRANSCEIVER_PRESENT_ATTR(6), - DECLARE_TRANSCEIVER_PRESENT_ATTR(7), - DECLARE_TRANSCEIVER_PRESENT_ATTR(8), - DECLARE_TRANSCEIVER_PRESENT_ATTR(9), - DECLARE_TRANSCEIVER_PRESENT_ATTR(10), - DECLARE_TRANSCEIVER_PRESENT_ATTR(11), - DECLARE_TRANSCEIVER_PRESENT_ATTR(12), - DECLARE_TRANSCEIVER_PRESENT_ATTR(13), - DECLARE_TRANSCEIVER_PRESENT_ATTR(14), - DECLARE_TRANSCEIVER_PRESENT_ATTR(15), - DECLARE_TRANSCEIVER_PRESENT_ATTR(16), - NULL -}; - -static const struct attribute_group as6812_32x_cpld2_group = { - .attrs = as6812_32x_cpld2_attributes, -}; - -static struct attribute *as6812_32x_cpld3_attributes[] = { - &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_access.dev_attr.attr, - /* transceiver attributes */ - &sensor_dev_attr_module_present_all.dev_attr.attr, - DECLARE_TRANSCEIVER_PRESENT_ATTR(17), - DECLARE_TRANSCEIVER_PRESENT_ATTR(18), - DECLARE_TRANSCEIVER_PRESENT_ATTR(19), - DECLARE_TRANSCEIVER_PRESENT_ATTR(20), - DECLARE_TRANSCEIVER_PRESENT_ATTR(21), - DECLARE_TRANSCEIVER_PRESENT_ATTR(22), - DECLARE_TRANSCEIVER_PRESENT_ATTR(23), - DECLARE_TRANSCEIVER_PRESENT_ATTR(24), - DECLARE_TRANSCEIVER_PRESENT_ATTR(25), - DECLARE_TRANSCEIVER_PRESENT_ATTR(26), - DECLARE_TRANSCEIVER_PRESENT_ATTR(27), - DECLARE_TRANSCEIVER_PRESENT_ATTR(28), - DECLARE_TRANSCEIVER_PRESENT_ATTR(29), - DECLARE_TRANSCEIVER_PRESENT_ATTR(30), - DECLARE_TRANSCEIVER_PRESENT_ATTR(31), - DECLARE_TRANSCEIVER_PRESENT_ATTR(32), - NULL -}; - -static const struct attribute_group as6812_32x_cpld3_group = { - .attrs = as6812_32x_cpld3_attributes, -}; - -static ssize_t show_present_all(struct device *dev, struct device_attribute *da, - char *buf) -{ - int i, status; - u8 values[2] = {0}; - u8 regs[] = {0xA, 0xB}; - struct i2c_client *client = to_i2c_client(dev); - struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - status = as6812_32x_cpld_read_internal(client, regs[i]); - - if (status < 0) { - goto exit; - } - - values[i] = ~(u8)status; - } - - mutex_unlock(&data->update_lock); - - /* Return values 1 -> 32 in order */ - return sprintf(buf, "%.2x %.2x\n", values[0], values[1]); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t show_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 as6812_32x_cpld_data *data = i2c_get_clientdata(client); - int status = 0; - u8 reg = 0, mask = 0; - - switch (attr->index) { - case MODULE_PRESENT_1 ... MODULE_PRESENT_8: - reg = 0xA; - mask = 0x1 << (attr->index - MODULE_PRESENT_1); - break; - case MODULE_PRESENT_9 ... MODULE_PRESENT_16: - reg = 0xB; - mask = 0x1 << (attr->index - MODULE_PRESENT_9); - break; - case MODULE_PRESENT_17 ... MODULE_PRESENT_24: - reg = 0xA; - mask = 0x1 << (attr->index - MODULE_PRESENT_17); - break; - case MODULE_PRESENT_25 ... MODULE_PRESENT_32: - reg = 0xB; - mask = 0x1 << (attr->index - MODULE_PRESENT_25); - break; - default: - return 0; - } - - mutex_lock(&data->update_lock); - status = as6812_32x_cpld_read_internal(client, reg); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", !(status & mask)); - -exit: - mutex_unlock(&data->update_lock); - return status; -} - -static ssize_t access(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - int status; - u32 addr, val; - struct i2c_client *client = to_i2c_client(dev); - struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); - - if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { - return -EINVAL; - } - - if (addr > 0xFF || val > 0xFF) { - return -EINVAL; - } - - mutex_lock(&data->update_lock); - status = as6812_32x_cpld_write_internal(client, addr, val); - if (unlikely(status < 0)) { - goto exit; - } - mutex_unlock(&data->update_lock); - return count; - -exit: - mutex_unlock(&data->update_lock); - return status; -} +MODULE_DEVICE_TABLE(i2c, accton_i2c_cpld_mux_id); /* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() for this as they will try to lock adapter a second time */ -static int as6812_32x_cpld_mux_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, u8 val) +static int accton_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) { unsigned long orig_jiffies; unsigned short flags; @@ -392,8 +134,8 @@ static int as6812_32x_cpld_mux_reg_write(struct i2c_adapter *adap, orig_jiffies = jiffies; for (res = 0, try = 0; try <= adap->retries; try++) { res = adap->algo->smbus_xfer(adap, client->addr, flags, - I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, - I2C_SMBUS_BYTE_DATA, &data); + I2C_SMBUS_WRITE, 0x2, + I2C_SMBUS_BYTE_DATA, &data); if (res != -EAGAIN) break; if (time_after(jiffies, @@ -405,35 +147,35 @@ static int as6812_32x_cpld_mux_reg_write(struct i2c_adapter *adap, return res; } -static int as6812_32x_cpld_mux_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) +static int accton_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) { - struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); u8 regval; int ret = 0; regval = chan; /* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { - ret = as6812_32x_cpld_mux_reg_write(adap, client, regval); + ret = accton_i2c_cpld_mux_reg_write(adap, client, regval); data->last_chan = regval; } return ret; } -static int as6812_32x_cpld_mux_deselect_mux(struct i2c_adapter *adap, +static int accton_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) { - struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); /* Deselect active channel */ data->last_chan = chips[data->type].deselectChan; - return as6812_32x_cpld_mux_reg_write(adap, client, data->last_chan); + return accton_i2c_cpld_mux_reg_write(adap, client, data->last_chan); } -static void as6812_32x_cpld_add_client(struct i2c_client *client) +static void accton_i2c_cpld_add_client(struct i2c_client *client) { struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); @@ -449,7 +191,7 @@ static void as6812_32x_cpld_add_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static void as6812_32x_cpld_remove_client(struct i2c_client *client) +static void accton_i2c_cpld_remove_client(struct i2c_client *client) { struct list_head *list_node = NULL; struct cpld_client_node *cpld_node = NULL; @@ -475,250 +217,177 @@ static void as6812_32x_cpld_remove_client(struct i2c_client *client) mutex_unlock(&list_lock); } -static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_cpld_version(struct device *dev, struct device_attribute *attr, char *buf) { - int val = 0; - struct i2c_client *client = to_i2c_client(dev); - - val = i2c_smbus_read_byte_data(client, 0x1); + u8 reg = 0x1; + struct i2c_client *client; + int len; - if (val < 0) { - dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); - } - - return sprintf(buf, "%d", val); + client = to_i2c_client(dev); + len = sprintf(buf, "%d", i2c_smbus_read_byte_data(client, reg)); + + return len; } +static struct device_attribute ver = __ATTR(version, 0600, show_cpld_version, NULL); + /* * I2C init/probing/exit functions */ -static int as6812_32x_cpld_mux_probe(struct i2c_client *client, +static int accton_i2c_cpld_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); int chan=0; - struct as6812_32x_cpld_data *data; + struct accton_i2c_cpld_mux *data; int ret = -ENODEV; - const struct attribute_group *group = NULL; if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto exit; + goto err; - data = kzalloc(sizeof(struct as6812_32x_cpld_data), GFP_KERNEL); + data = kzalloc(sizeof(struct accton_i2c_cpld_mux), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto exit; + goto err; } i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); + data->type = id->driver_data; - if (data->type == as6812_32x_cpld2 || data->type == as6812_32x_cpld3) { - data->last_chan = chips[data->type].deselectChan; /* force the first selection */ + if (data->type == as6812_32x_cpld2 || data->type == as6812_32x_cpld3) { + data->last_chan = chips[data->type].deselectChan; /* force the first selection */ - /* Now create an adapter for each channel */ - for (chan = 0; chan < chips[data->type].nchans; chan++) { - data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, 0, - as6812_32x_cpld_mux_select_chan, - as6812_32x_cpld_mux_deselect_mux); + /* Now create an adapter for each channel */ + for (chan = 0; chan < chips[data->type].nchans; chan++) { + data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &client->dev, client, 0, chan, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + I2C_CLASS_HWMON | I2C_CLASS_SPD, +#endif + accton_i2c_cpld_mux_select_chan, + accton_i2c_cpld_mux_deselect_mux); - if (data->virt_adaps[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); - goto exit_mux_register; - } - } + if (data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "failed to register multiplexed adapter %d\n", chan); + goto virt_reg_failed; + } + } - dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", - chan, client->name); - } + dev_info(&client->dev, "registered %d multiplexed busses for I2C mux %s\n", + chan, client->name); + } - /* Register sysfs hooks */ - switch (data->type) { - case as6812_32x_cpld1: - group = &as6812_32x_cpld1_group; - break; - case as6812_32x_cpld2: - group = &as6812_32x_cpld2_group; - break; - case as6812_32x_cpld3: - group = &as6812_32x_cpld3_group; - break; - default: - break; - } + accton_i2c_cpld_add_client(client); - - if (group) { - ret = sysfs_create_group(&client->dev.kobj, group); - if (ret) { - goto exit_mux_register; - } - } + ret = sysfs_create_file(&client->dev.kobj, &ver.attr); + if (ret) + goto virt_reg_failed; - as6812_32x_cpld_add_client(client); + return 0; - return 0; - -exit_mux_register: +virt_reg_failed: for (chan--; chan >= 0; chan--) { i2c_del_mux_adapter(data->virt_adaps[chan]); - } - kfree(data); -exit: + } + kfree(data); +err: return ret; -} - -static int as6812_32x_cpld_mux_remove(struct i2c_client *client) -{ - struct as6812_32x_cpld_data *data = i2c_get_clientdata(client); - const struct chip_desc *chip = &chips[data->type]; - int chan; - const struct attribute_group *group = NULL; - - as6812_32x_cpld_remove_client(client); - - /* Remove sysfs hooks */ - switch (data->type) { - case as6812_32x_cpld1: - group = &as6812_32x_cpld1_group; - break; - case as6812_32x_cpld2: - group = &as6812_32x_cpld2_group; - break; - case as6812_32x_cpld3: - group = &as6812_32x_cpld3_group; - break; - default: - break; - } - - if (group) { - sysfs_remove_group(&client->dev.kobj, group); - } - - for (chan = 0; chan < chip->nchans; ++chan) { - if (data->virt_adaps[chan]) { - i2c_del_mux_adapter(data->virt_adaps[chan]); - data->virt_adaps[chan] = NULL; - } - } - - kfree(data); - - return 0; } -static int as6812_32x_cpld_read_internal(struct i2c_client *client, u8 reg) +static int accton_i2c_cpld_mux_remove(struct i2c_client *client) { - int status = 0, retry = I2C_RW_RETRY_COUNT; + struct accton_i2c_cpld_mux *data = i2c_get_clientdata(client); + const struct chip_desc *chip = &chips[data->type]; + int chan; - while (retry) { - status = i2c_smbus_read_byte_data(client, reg); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; + sysfs_remove_file(&client->dev.kobj, &ver.attr); + + for (chan = 0; chan < chip->nchans; ++chan) { + if (data->virt_adaps[chan]) { + i2c_del_mux_adapter(data->virt_adaps[chan]); + data->virt_adaps[chan] = NULL; } - - break; } - return status; + kfree(data); + accton_i2c_cpld_remove_client(client); + + return 0; } -static int as6812_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg) { - int status = 0, retry = I2C_RW_RETRY_COUNT; - - while (retry) { - status = i2c_smbus_write_byte_data(client, reg, value); - if (unlikely(status < 0)) { - msleep(I2C_RW_RETRY_INTERVAL); - retry--; - continue; - } - - break; - } - - return status; -} - -int as6812_32x_cpld_read(unsigned short cpld_addr, u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - - mutex_lock(&list_lock); - - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); - - if (cpld_node->client->addr == cpld_addr) { - ret = as6812_32x_cpld_read_internal(cpld_node->client, reg); - break; - } - } - - mutex_unlock(&list_lock); - - return ret; -} -EXPORT_SYMBOL(as6812_32x_cpld_read); - -int as6812_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; mutex_lock(&list_lock); - list_for_each(list_node, &cpld_client_list) - { - cpld_node = list_entry(list_node, struct cpld_client_node, list); + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); - if (cpld_node->client->addr == cpld_addr) { - ret = as6812_32x_cpld_write_internal(cpld_node->client, reg, value); - break; - } - } + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } mutex_unlock(&list_lock); - return ret; + return ret; } -EXPORT_SYMBOL(as6812_32x_cpld_write); +EXPORT_SYMBOL(as6812_32x_i2c_cpld_read); -static struct i2c_driver as6812_32x_cpld_mux_driver = { +int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as6812_32x_i2c_cpld_write); + +static struct i2c_driver accton_i2c_cpld_mux_driver = { .driver = { .name = "as6812_32x_cpld", .owner = THIS_MODULE, }, - .probe = as6812_32x_cpld_mux_probe, - .remove = as6812_32x_cpld_mux_remove, - .id_table = as6812_32x_cpld_mux_id, + .probe = accton_i2c_cpld_mux_probe, + .remove = accton_i2c_cpld_mux_remove, + .id_table = accton_i2c_cpld_mux_id, }; -static int __init as6812_32x_cpld_mux_init(void) +static int __init accton_i2c_cpld_mux_init(void) { - mutex_init(&list_lock); - return i2c_add_driver(&as6812_32x_cpld_mux_driver); + mutex_init(&list_lock); + return i2c_add_driver(&accton_i2c_cpld_mux_driver); } -static void __exit as6812_32x_cpld_mux_exit(void) +static void __exit accton_i2c_cpld_mux_exit(void) { - i2c_del_driver(&as6812_32x_cpld_mux_driver); + i2c_del_driver(&accton_i2c_cpld_mux_driver); } MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("Accton I2C CPLD mux driver"); MODULE_LICENSE("GPL"); -module_init(as6812_32x_cpld_mux_init); -module_exit(as6812_32x_cpld_mux_exit); - +module_init(accton_i2c_cpld_mux_init); +module_exit(accton_i2c_cpld_mux_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c index 7e5567df..f0555674 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c @@ -137,8 +137,8 @@ static ssize_t fan_set_duty_cycle(struct device *dev, static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); -extern int as6812_32x_cpld_read(unsigned short cpld_addr, u8 reg); -extern int as6812_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); /*******************/ @@ -257,12 +257,12 @@ static const struct attribute_group accton_as6812_32x_fan_group = { static int accton_as6812_32x_fan_read_value(u8 reg) { - return as6812_32x_cpld_read(0x60, reg); + return as6812_32x_i2c_cpld_read(0x60, reg); } static int accton_as6812_32x_fan_write_value(u8 reg, u8 value) { - return as6812_32x_cpld_write(0x60, reg, value); + return as6812_32x_i2c_cpld_write(0x60, reg, value); } static void accton_as6812_32x_fan_update_device(struct device *dev) @@ -385,6 +385,11 @@ static struct platform_driver accton_as6812_32x_fan_driver = { static int __init accton_as6812_32x_fan_init(void) { int ret; + + extern int platform_accton_as6812_32x(void); + if(!platform_accton_as6812_32x()) { + return -ENODEV; + } ret = platform_driver_register(&accton_as6812_32x_fan_driver); if (ret < 0) { diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c index 691af597..fd54ce06 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-leds.c @@ -29,8 +29,8 @@ #include #include -extern int as6812_32x_cpld_read (unsigned short cpld_addr, u8 reg); -extern int as6812_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int as6812_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as6812_32x_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); extern void led_classdev_unregister(struct led_classdev *led_cdev); extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); @@ -239,12 +239,12 @@ static u8 led_light_mode_to_reg_val(enum led_type type, static int accton_as6812_32x_led_read_value(u8 reg) { - return as6812_32x_cpld_read(0x60, reg); + return as6812_32x_i2c_cpld_read(0x60, reg); } static int accton_as6812_32x_led_write_value(u8 reg, u8 value) { - return as6812_32x_cpld_write(0x60, reg, value); + return as6812_32x_i2c_cpld_write(0x60, reg, value); } static void accton_as6812_32x_led_update(void) @@ -571,6 +571,11 @@ static int __init accton_as6812_32x_led_init(void) { int ret; + extern int platform_accton_as6812_32x(void); + if(!platform_accton_as6812_32x()) { + return -ENODEV; + } + ret = platform_driver_register(&accton_as6812_32x_led_driver); if (ret < 0) { goto exit; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c index 40d86b1c..a782870e 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-psu.c @@ -44,7 +44,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); static ssize_t show_serial_number(struct device *dev, struct device_attribute *da,char *buf); static int as6812_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); -extern int as6812_32x_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as6812_32x_i2c_cpld_read(unsigned short cpld_addr, u8 reg); static int as6812_32x_psu_model_name_get(struct device *dev, int get_serial); /* Addresses scanned @@ -415,7 +415,7 @@ static struct as6812_32x_psu_data *as6812_32x_psu_update_device(struct device *d data->valid = 0; /* Read psu status */ - status = as6812_32x_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); + status = as6812_32x_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET); if (status < 0) { dev_dbg(&client->dev, "cpld reg (0x%x) err %d\n", PSU_STATUS_I2C_ADDR, status); @@ -435,9 +435,19 @@ exit: return data; } -module_i2c_driver(as6812_32x_psu_driver); +static int __init as6812_32x_psu_init(void) +{ + return i2c_add_driver(&as6812_32x_psu_driver); +} + +static void __exit as6812_32x_psu_exit(void) +{ + i2c_del_driver(&as6812_32x_psu_driver); +} MODULE_AUTHOR("Brandon Chuang "); MODULE_DESCRIPTION("as6812_32x_psu driver"); MODULE_LICENSE("GPL"); +module_init(as6812_32x_psu_init); +module_exit(as6812_32x_psu_exit); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c new file mode 100644 index 00000000..362d87db --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-sfp.c @@ -0,0 +1,1532 @@ +/* + * SFP driver for accton as6812_32x sfp + * + * Copyright (C) Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "as6812_32x_sfp" + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#define NUM_OF_SFP_PORT 32 +#define EEPROM_NAME "sfp_eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ +#define BIT_INDEX(i) (1ULL << (i)) +#define USE_I2C_BLOCK_READ 1 /* Platform dependent */ +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +#define SFP_EEPROM_A0_I2C_ADDR (0xA0 >> 1) + +#define SFF8024_PHYSICAL_DEVICE_ID_ADDR 0x0 +#define SFF8024_DEVICE_ID_SFP 0x3 +#define SFF8024_DEVICE_ID_QSFP 0xC +#define SFF8024_DEVICE_ID_QSFP_PLUS 0xD +#define SFF8024_DEVICE_ID_QSFP28 0x11 + +#define SFF8436_RX_LOS_ADDR 3 +#define SFF8436_TX_FAULT_ADDR 4 +#define SFF8436_TX_DISABLE_ADDR 86 + +#define MULTIPAGE_SUPPORT 1 + +#if (MULTIPAGE_SUPPORT == 1) +/* fundamental unit of addressing for SFF_8472/SFF_8436 */ +#define SFF_8436_PAGE_SIZE 128 +/* + * The current 8436 (QSFP) spec provides for only 4 supported + * pages (pages 0-3). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8436_SPECED_PAGES 4 +#define SFF_8436_EEPROM_SIZE ((1 + SFF_8436_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8436_EEPROM_UNPAGED_SIZE (2 * SFF_8436_PAGE_SIZE) +/* + * The current 8472 (SFP) spec provides for only 3 supported + * pages (pages 0-2). + * This driver is prepared to support more, but needs a register in the + * EEPROM to indicate how many pages are supported before it is safe + * to implement more pages in the driver. + */ +#define SFF_8472_SPECED_PAGES 3 +#define SFF_8472_EEPROM_SIZE ((3 + SFF_8472_SPECED_PAGES) * SFF_8436_PAGE_SIZE) +#define SFF_8472_EEPROM_UNPAGED_SIZE (4 * SFF_8436_PAGE_SIZE) + +/* a few constants to find our way around the EEPROM */ +#define SFF_8436_PAGE_SELECT_REG 0x7F +#define SFF_8436_PAGEABLE_REG 0x02 +#define SFF_8436_NOT_PAGEABLE (1<<2) +#define SFF_8472_PAGEABLE_REG 0x40 +#define SFF_8472_PAGEABLE (1<<4) + +/* + * This parameter is to help this driver avoid blocking other drivers out + * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C + * clock, one 256 byte read takes about 1/43 second which is excessive; + * but the 1/170 second it takes at 400 kHz may be quite reasonable; and + * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. + * + * This value is forced to be a power of two so that writes align on pages. + */ +static unsigned io_limit = SFF_8436_PAGE_SIZE; + +/* + * specs often allow 5 msec for a page write, sometimes 20 msec; + * it's important to recover from write timeouts. + */ +static unsigned write_timeout = 25; + +typedef enum qsfp_opcode { + QSFP_READ_OP = 0, + QSFP_WRITE_OP = 1 +} qsfp_opcode_e; +#endif + +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count);; +static ssize_t sfp_eeprom_read(struct i2c_client *, u8, u8 *,int); +static ssize_t sfp_eeprom_write(struct i2c_client *, u8 , const char *,int); +extern int as6812_32x_i2c_cpld_read (unsigned short cpld_addr, u8 reg); + +enum sfp_sysfs_attributes { + PRESENT, + PRESENT_ALL, + PORT_NUMBER, + PORT_TYPE, + DDM_IMPLEMENTED, + TX_FAULT, + TX_FAULT1, + TX_FAULT2, + TX_FAULT3, + TX_FAULT4, + TX_DISABLE, + TX_DISABLE1, + TX_DISABLE2, + TX_DISABLE3, + TX_DISABLE4, + RX_LOS, + RX_LOS1, + RX_LOS2, + RX_LOS3, + RX_LOS4, + RX_LOS_ALL +}; + +/* SFP/QSFP common attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_port_number, S_IRUGO, show_port_number, NULL, PORT_NUMBER); +static SENSOR_DEVICE_ATTR(sfp_is_present, S_IRUGO, show_present, NULL, PRESENT); +static SENSOR_DEVICE_ATTR(sfp_is_present_all, S_IRUGO, show_present, NULL, PRESENT_ALL); +static SENSOR_DEVICE_ATTR(sfp_tx_disable, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE); +static SENSOR_DEVICE_ATTR(sfp_tx_fault, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT); + +/* QSFP attributes for sysfs */ +static SENSOR_DEVICE_ATTR(sfp_rx_los, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS); +static SENSOR_DEVICE_ATTR(sfp_rx_los1, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS1); +static SENSOR_DEVICE_ATTR(sfp_rx_los2, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS2); +static SENSOR_DEVICE_ATTR(sfp_rx_los3, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS3); +static SENSOR_DEVICE_ATTR(sfp_rx_los4, S_IRUGO, qsfp_show_tx_rx_status, NULL, RX_LOS4); +static SENSOR_DEVICE_ATTR(sfp_tx_disable1, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE1); +static SENSOR_DEVICE_ATTR(sfp_tx_disable2, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE2); +static SENSOR_DEVICE_ATTR(sfp_tx_disable3, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE3); +static SENSOR_DEVICE_ATTR(sfp_tx_disable4, S_IWUSR | S_IRUGO, qsfp_show_tx_rx_status, qsfp_set_tx_disable, TX_DISABLE4); +static SENSOR_DEVICE_ATTR(sfp_tx_fault1, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT1); +static SENSOR_DEVICE_ATTR(sfp_tx_fault2, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT2); +static SENSOR_DEVICE_ATTR(sfp_tx_fault3, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT3); +static SENSOR_DEVICE_ATTR(sfp_tx_fault4, S_IRUGO, qsfp_show_tx_rx_status, NULL, TX_FAULT4); +static struct attribute *qsfp_attributes[] = { + &sensor_dev_attr_sfp_port_number.dev_attr.attr, + &sensor_dev_attr_sfp_is_present.dev_attr.attr, + &sensor_dev_attr_sfp_is_present_all.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los1.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los2.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los3.dev_attr.attr, + &sensor_dev_attr_sfp_rx_los4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_disable4.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault1.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault2.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault3.dev_attr.attr, + &sensor_dev_attr_sfp_tx_fault4.dev_attr.attr, + NULL +}; + +/* Platform dependent +++ */ +#define CPLD_PORT_TO_FRONT_PORT(port) (port+1) + +enum port_numbers { +as6812_32x_port1, as6812_32x_port2, as6812_32x_port3, as6812_32x_port4, as6812_32x_port5, as6812_32x_port6, as6812_32x_port7, as6812_32x_port8, +as6812_32x_port9, as6812_32x_port10, as6812_32x_port11, as6812_32x_port12, as6812_32x_port13, as6812_32x_port14, as6812_32x_port15, as6812_32x_port16, +as6812_32x_port17, as6812_32x_port18, as6812_32x_port19, as6812_32x_port20, as6812_32x_port21, as6812_32x_port22, as6812_32x_port23, as6812_32x_port24, +as6812_32x_port25, as6812_32x_port26, as6812_32x_port27, as6812_32x_port28, as6812_32x_port29, as6812_32x_port30, as6812_32x_port31, as6812_32x_port32 +}; + +#define I2C_DEV_ID(x) { #x, x} + +static const struct i2c_device_id sfp_device_id[] = { +I2C_DEV_ID(as6812_32x_port1), +I2C_DEV_ID(as6812_32x_port2), +I2C_DEV_ID(as6812_32x_port3), +I2C_DEV_ID(as6812_32x_port4), +I2C_DEV_ID(as6812_32x_port5), +I2C_DEV_ID(as6812_32x_port6), +I2C_DEV_ID(as6812_32x_port7), +I2C_DEV_ID(as6812_32x_port8), +I2C_DEV_ID(as6812_32x_port9), +I2C_DEV_ID(as6812_32x_port10), +I2C_DEV_ID(as6812_32x_port11), +I2C_DEV_ID(as6812_32x_port12), +I2C_DEV_ID(as6812_32x_port13), +I2C_DEV_ID(as6812_32x_port14), +I2C_DEV_ID(as6812_32x_port15), +I2C_DEV_ID(as6812_32x_port16), +I2C_DEV_ID(as6812_32x_port17), +I2C_DEV_ID(as6812_32x_port18), +I2C_DEV_ID(as6812_32x_port19), +I2C_DEV_ID(as6812_32x_port20), +I2C_DEV_ID(as6812_32x_port21), +I2C_DEV_ID(as6812_32x_port22), +I2C_DEV_ID(as6812_32x_port23), +I2C_DEV_ID(as6812_32x_port24), +I2C_DEV_ID(as6812_32x_port25), +I2C_DEV_ID(as6812_32x_port26), +I2C_DEV_ID(as6812_32x_port27), +I2C_DEV_ID(as6812_32x_port28), +I2C_DEV_ID(as6812_32x_port29), +I2C_DEV_ID(as6812_32x_port30), +I2C_DEV_ID(as6812_32x_port31), +I2C_DEV_ID(as6812_32x_port32), +{ /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, sfp_device_id); +/* Platform dependent --- */ + +enum driver_type_e { + DRIVER_TYPE_SFP_MSA, + DRIVER_TYPE_SFP_DDM, + DRIVER_TYPE_QSFP +}; + +/* Each client has this additional data + */ +struct eeprom_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + struct bin_attribute bin; /* eeprom data */ +}; + +struct qsfp_data { + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 status[3]; /* bit0:port0, bit1:port1 and so on */ + /* index 0 => tx_fail + 1 => tx_disable + 2 => rx_loss */ + u8 device_id; + struct eeprom_data eeprom; +}; + +struct sfp_port_data { + struct mutex update_lock; + enum driver_type_e driver_type; + int port; /* CPLD port index */ + u64 present; /* present status, bit0:port0, bit1:port1 and so on */ + + struct qsfp_data *qsfp; + + struct i2c_client *client; +#if (MULTIPAGE_SUPPORT == 1) + int use_smbus; + u8 *writebuf; + unsigned write_max; +#endif +}; + +#if (MULTIPAGE_SUPPORT == 1) +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode); +#endif +static ssize_t show_port_number(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + return sprintf(buf, "%d\n", CPLD_PORT_TO_FRONT_PORT(data->port)); +} +/* Platform dependent +++ */ +static struct sfp_port_data *sfp_update_present(struct i2c_client *client) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + int i = 0, j = 0; + int status = -1; + + DEBUG_PRINT("Starting sfp present status update"); + mutex_lock(&data->update_lock); + + /* Read present status of port 1~32 */ + data->present = 0; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + status = as6812_32x_i2c_cpld_read(0x62+i*2, 0xA+j); + + if (status < 0) { + DEBUG_PRINT("cpld(0x%x) reg(0x%x) err %d", 0x62+i*2, 0xA+j, status); + goto exit; + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); + data->present |= (u64)status << ((i*16) + (j*8)); + } + } + + DEBUG_PRINT("Present status = 0x%lx", data->present); +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +/* Platform dependent --- */ + +static int sfp_is_port_present(struct i2c_client *client, int port) +{ + struct sfp_port_data *data = i2c_get_clientdata(client); + + data = sfp_update_present(client); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + return (data->present & BIT_INDEX(data->port)) ? 0 : 1; /* Platform dependent */ +} + +/* Platform dependent +++ */ +static ssize_t show_present(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); + + if (PRESENT_ALL == attr->index) { + int i; + u8 values[4] = {0}; + struct sfp_port_data *data = sfp_update_present(client); + + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + for (i = 0; i < ARRAY_SIZE(values); i++) { + values[i] = ~(u8)(data->present >> (i * 8)); + } + + /* Return values 1 -> 32 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], + values[3]); + } + else { + struct sfp_port_data *data = i2c_get_clientdata(client); + int present = sfp_is_port_present(client, data->port); + + if (IS_ERR_VALUE(present)) { + return present; + } + + /* PRESENT */ + return sprintf(buf, "%d", present); + } +} +/* Platform dependent --- */ + +static struct sfp_port_data *qsfp_update_tx_rx_status(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + int i, status = -1; + u8 buf = 0; + u8 reg[] = {SFF8436_TX_FAULT_ADDR, SFF8436_TX_DISABLE_ADDR, SFF8436_RX_LOS_ADDR}; + + if (time_before(jiffies, data->qsfp->last_updated + HZ + HZ / 2) && data->qsfp->valid) { + return data; + } + + DEBUG_PRINT("Starting sfp tx rx status update"); + mutex_lock(&data->update_lock); + data->qsfp->valid = 0; + memset(data->qsfp->status, 0, sizeof(data->qsfp->status)); + + /* Notify device to update tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + } + msleep(200); + + /* Read actual tx fault/ tx disable/ rx los status */ + for (i = 0; i < ARRAY_SIZE(reg); i++) { + status = sfp_eeprom_read(client, reg[i], &buf, sizeof(buf)); + if (unlikely(status < 0)) { + goto exit; + } + + DEBUG_PRINT("qsfp reg(0x%x) status = (0x%x)", reg[i], data->qsfp->status[i]); + data->qsfp->status[i] = (buf & 0xF); + } + + data->qsfp->valid = 1; + data->qsfp->last_updated = jiffies; + +exit: + mutex_unlock(&data->update_lock); + return (status < 0) ? ERR_PTR(status) : data; +} + +static ssize_t qsfp_show_tx_rx_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + int present; + u8 val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + present = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENXIO; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + switch (attr->index) { + case TX_FAULT: + val = !!(data->qsfp->status[2] & 0xF); + break; + case TX_FAULT1: + case TX_FAULT2: + case TX_FAULT3: + case TX_FAULT4: + val = !!(data->qsfp->status[2] & BIT_INDEX(attr->index - TX_FAULT1)); + break; + case TX_DISABLE: + val = data->qsfp->status[1] & 0xF; + break; + case TX_DISABLE1: + case TX_DISABLE2: + case TX_DISABLE3: + case TX_DISABLE4: + val = !!(data->qsfp->status[1] & BIT_INDEX(attr->index - TX_DISABLE1)); + break; + case RX_LOS: + val = !!(data->qsfp->status[0] & 0xF); + break; + case RX_LOS1: + case RX_LOS2: + case RX_LOS3: + case RX_LOS4: + val = !!(data->qsfp->status[0] & BIT_INDEX(attr->index - RX_LOS1)); + break; + default: + break; + } + + return sprintf(buf, "%d\n", val); +} + +static ssize_t qsfp_set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct sfp_port_data *data = i2c_get_clientdata(client); + + status = sfp_is_port_present(client, data->port); + if (IS_ERR_VALUE(status)) { + return status; + } + + if (!status) { + /* port is not present */ + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + data = qsfp_update_tx_rx_status(dev); + if (IS_ERR(data)) { + return PTR_ERR(data); + } + + mutex_lock(&data->update_lock); + + if (attr->index == TX_DISABLE) { + if (disable) { + data->qsfp->status[1] |= 0xF; + } + else { + data->qsfp->status[1] &= ~0xF; + } + } + else {/* TX_DISABLE1 ~ TX_DISABLE4*/ + if (disable) { + data->qsfp->status[1] |= (1 << (attr->index - TX_DISABLE1)); + } + else { + data->qsfp->status[1] &= ~(1 << (attr->index - TX_DISABLE1)); + } + } + + DEBUG_PRINT("index = (%d), status = (0x%x)", attr->index, data->qsfp->status[1]); + status = sfp_eeprom_write(data->client, SFF8436_TX_DISABLE_ADDR, &data->qsfp->status[1], sizeof(data->qsfp->status[1])); + if (unlikely(status < 0)) { + count = status; + } + + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t sfp_eeprom_write(struct i2c_client *client, u8 command, const char *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_write_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return data_len; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, command, *data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + return status; + } + + return 1; +#endif + + +} + +#if (MULTIPAGE_SUPPORT == 0) +static ssize_t sfp_port_write(struct sfp_port_data *data, + const char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Write data to chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_write(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; +} +#endif + +static ssize_t sfp_bin_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("%s(%d) offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_WRITE_OP); +#else + return sfp_port_write(data, buf, off, count); +#endif +} + +static ssize_t sfp_eeprom_read(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ +#if USE_I2C_BLOCK_READ + int status, retry = I2C_RW_RETRY_COUNT; + + if (data_len > I2C_SMBUS_BLOCK_MAX) { + data_len = I2C_SMBUS_BLOCK_MAX; + } + + while (retry) { + status = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + goto abort; + } + if (unlikely(status != data_len)) { + status = -EIO; + goto abort; + } + + //result = data_len; + +abort: + return status; +#else + int status, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + status = 1; + +abort: + return status; +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +/*-------------------------------------------------------------------------*/ +/* + * This routine computes the addressing information to be used for + * a given r/w request. + * + * Task is to calculate the client (0 = i2c addr 50, 1 = i2c addr 51), + * the page, and the offset. + * + * Handles both SFP and QSFP. + * For SFP, offset 0-255 are on client[0], >255 is on client[1] + * Offset 256-383 are on the lower half of client[1] + * Pages are accessible on the upper half of client[1]. + * Offset >383 are in 128 byte pages mapped into the upper half + * + * For QSFP, all offsets are on client[0] + * offset 0-127 are on the lower half of client[0] (no paging) + * Pages are accessible on the upper half of client[1]. + * Offset >127 are in 128 byte pages mapped into the upper half + * + * Callers must not read/write beyond the end of a client or a page + * without recomputing the client/page. Hence offset (within page) + * plus length must be less than or equal to 128. (Note that this + * routine does not have access to the length of the call, hence + * cannot do the validity check.) + * + * Offset within Lower Page 00h and Upper Page 00h are not recomputed + */ +static uint8_t sff_8436_translate_offset(struct sfp_port_data *port_data, + loff_t *offset, struct i2c_client **client) +{ + unsigned page = 0; + + *client = port_data->client; + + /* + * if offset is in the range 0-128... + * page doesn't matter (using lower half), return 0. + * offset is already correct (don't add 128 to get to paged area) + */ + if (*offset < SFF_8436_PAGE_SIZE) + return page; + + /* note, page will always be positive since *offset >= 128 */ + page = (*offset >> 7)-1; + /* 0x80 places the offset in the top half, offset is last 7 bits */ + *offset = SFF_8436_PAGE_SIZE + (*offset & 0x7f); + + return page; /* note also returning client and offset */ +} + +static ssize_t sff_8436_eeprom_read(struct sfp_port_data *port_data, + struct i2c_client *client, + char *buf, unsigned offset, size_t count) +{ + struct i2c_msg msg[2]; + u8 msgbuf[2]; + unsigned long timeout, read_time; + int status, i; + + memset(msg, 0, sizeof(msg)); + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* + * When we have a better choice than SMBus calls, use a + * combined I2C message. Write address; then read up to + * io_limit data bytes. msgbuf is u8 and will cast to our + * needs. + */ + i = 0; + msgbuf[i++] = offset; + + msg[0].addr = client->addr; + msg[0].buf = msgbuf; + msg[0].len = i; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + read_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_read_i2c_block_data(client, offset, + count, buf); + break; + case I2C_SMBUS_WORD_DATA: + status = i2c_smbus_read_word_data(client, offset); + if (status >= 0) { + buf[0] = status & 0xff; + if (count == 2) + buf[1] = status >> 8; + status = count; + } + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_read_byte_data(client, offset); + if (status >= 0) { + buf[0] = status; + status = count; + } + break; + default: + status = i2c_transfer(client->adapter, msg, 2); + if (status == 2) + status = count; + } + + dev_dbg(&client->dev, "eeprom read %zu@%d --> %d (%ld)\n", + count, offset, status, jiffies); + + if (status == count) /* happy path */ + return count; + + if (status == -ENXIO) /* no module present */ + return status; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(read_time, timeout)); + + return -ETIMEDOUT; +} + +static ssize_t sff_8436_eeprom_write(struct sfp_port_data *port_data, + struct i2c_client *client, + const char *buf, + unsigned offset, size_t count) +{ + struct i2c_msg msg; + ssize_t status; + unsigned long timeout, write_time; + unsigned next_page_start; + int i = 0; + + /* write max is at most a page + * (In this driver, write_max is actually one byte!) + */ + if (count > port_data->write_max) + count = port_data->write_max; + + /* shorten count if necessary to avoid crossing page boundary */ + next_page_start = roundup(offset + 1, SFF_8436_PAGE_SIZE); + if (offset + count > next_page_start) + count = next_page_start - offset; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + /*smaller eeproms can work given some SMBus extension calls */ + if (count > I2C_SMBUS_BLOCK_MAX) + count = I2C_SMBUS_BLOCK_MAX; + break; + case I2C_SMBUS_WORD_DATA: + /* Check for odd length transaction */ + count = (count == 1) ? 1 : 2; + break; + case I2C_SMBUS_BYTE_DATA: + count = 1; + break; + default: + /* If we'll use I2C calls for I/O, set up the message */ + msg.addr = client->addr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = port_data->writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + break; + } + + /* + * Reads fail if the previous write didn't complete yet. We may + * loop a few times until this one succeeds, waiting at least + * long enough for one entire page write to work. + */ + timeout = jiffies + msecs_to_jiffies(write_timeout); + do { + write_time = jiffies; + + switch (port_data->use_smbus) { + case I2C_SMBUS_I2C_BLOCK_DATA: + status = i2c_smbus_write_i2c_block_data(client, + offset, count, buf); + if (status == 0) + status = count; + break; + case I2C_SMBUS_WORD_DATA: + if (count == 2) { + status = i2c_smbus_write_word_data(client, + offset, (u16)((buf[0])|(buf[1] << 8))); + } else { + /* count = 1 */ + status = i2c_smbus_write_byte_data(client, + offset, buf[0]); + } + if (status == 0) + status = count; + break; + case I2C_SMBUS_BYTE_DATA: + status = i2c_smbus_write_byte_data(client, offset, + buf[0]); + if (status == 0) + status = count; + break; + default: + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + break; + } + + dev_dbg(&client->dev, "eeprom write %zu@%d --> %ld (%lu)\n", + count, offset, (long int) status, jiffies); + + if (status == count) + return count; + + /* REVISIT: at HZ=100, this is sloooow */ + msleep(1); + } while (time_before(write_time, timeout)); + + return -ETIMEDOUT; +} + + +static ssize_t sff_8436_eeprom_update_client(struct sfp_port_data *port_data, + char *buf, loff_t off, + size_t count, qsfp_opcode_e opcode) +{ + struct i2c_client *client; + ssize_t retval = 0; + u8 page = 0; + loff_t phy_offset = off; + int ret = 0; + + page = sff_8436_translate_offset(port_data, &phy_offset, &client); + + dev_dbg(&client->dev, + "sff_8436_eeprom_update_client off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", + off, page, phy_offset, (long int) count, opcode); + if (page > 0) { + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, + "Write page register for page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + + while (count) { + ssize_t status; + + if (opcode == QSFP_READ_OP) { + status = sff_8436_eeprom_read(port_data, client, + buf, phy_offset, count); + } else { + status = sff_8436_eeprom_write(port_data, client, + buf, phy_offset, count); + } + if (status <= 0) { + if (retval == 0) + retval = status; + break; + } + buf += status; + phy_offset += status; + count -= status; + retval += status; + } + + + if (page > 0) { + /* return the page register to page 0 (why?) */ + page = 0; + ret = sff_8436_eeprom_write(port_data, client, &page, + SFF_8436_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_err(&client->dev, + "Restore page register to page %d failed ret:%d!\n", + page, ret); + return ret; + } + } + return retval; +} + + +/* + * Figure out if this access is within the range of supported pages. + * Note this is called on every access because we don't know if the + * module has been replaced since the last call. + * If/when modules support more pages, this is the routine to update + * to validate and allow access to additional pages. + * + * Returns updated len for this access: + * - entire access is legal, original len is returned. + * - access begins legal but is too long, len is truncated to fit. + * - initial offset exceeds supported pages, return -EINVAL + */ +static ssize_t sff_8436_page_legal(struct sfp_port_data *port_data, + loff_t off, size_t len) +{ + struct i2c_client *client = port_data->client; + u8 regval; + int status; + size_t maxlen; + + if (off < 0) return -EINVAL; + if (port_data->driver_type == DRIVER_TYPE_SFP_MSA) { + /* SFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8472_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8472_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8472_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8472_PAGEABLE) { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8472_EEPROM_SIZE - off; + } else { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8472_EEPROM_UNPAGED_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, SFP, off %lld len %ld\n", + off, (long int) len); + } + else if (port_data->driver_type == DRIVER_TYPE_QSFP) { + /* QSFP case */ + /* if no pages needed, we're good */ + if ((off + len) <= SFF_8436_EEPROM_UNPAGED_SIZE) return len; + /* if offset exceeds possible pages, we're not good */ + if (off >= SFF_8436_EEPROM_SIZE) return -EINVAL; + /* in between, are pages supported? */ + status = sff_8436_eeprom_read(port_data, client, ®val, + SFF_8436_PAGEABLE_REG, 1); + if (status < 0) return status; /* error out (no module?) */ + if (regval & SFF_8436_NOT_PAGEABLE) { + /* pages not supported, trim len to unpaged size */ + maxlen = SFF_8436_EEPROM_UNPAGED_SIZE - off; + } else { + /* Pages supported, trim len to the end of pages */ + maxlen = SFF_8436_EEPROM_SIZE - off; + } + len = (len > maxlen) ? maxlen : len; + dev_dbg(&client->dev, + "page_legal, QSFP, off %lld len %ld\n", + off, (long int) len); + } + else { + return -EINVAL; + } + return len; +} + + +static ssize_t sfp_port_read_write(struct sfp_port_data *port_data, + char *buf, loff_t off, size_t len, qsfp_opcode_e opcode) +{ + struct i2c_client *client = port_data->client; + int chunk; + int status = 0; + ssize_t retval; + size_t pending_len = 0, chunk_len = 0; + loff_t chunk_offset = 0, chunk_start_offset = 0; + + if (unlikely(!len)) + return len; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&port_data->update_lock); + + /* + * Confirm this access fits within the device suppored addr range + */ + len = sff_8436_page_legal(port_data, off, len); + if (len < 0) { + status = len; + goto err; + } + + /* + * For each (128 byte) chunk involved in this request, issue a + * separate call to sff_eeprom_update_client(), to + * ensure that each access recalculates the client/page + * and writes the page register as needed. + * Note that chunk to page mapping is confusing, is different for + * QSFP and SFP, and never needs to be done. Don't try! + */ + pending_len = len; /* amount remaining to transfer */ + retval = 0; /* amount transferred */ + for (chunk = off >> 7; chunk <= (off + len - 1) >> 7; chunk++) { + + /* + * Compute the offset and number of bytes to be read/write + * + * 1. start at offset 0 (within the chunk), and read/write + * the entire chunk + * 2. start at offset 0 (within the chunk) and read/write less + * than entire chunk + * 3. start at an offset not equal to 0 and read/write the rest + * of the chunk + * 4. start at an offset not equal to 0 and read/write less than + * (end of chunk - offset) + */ + chunk_start_offset = chunk * SFF_8436_PAGE_SIZE; + + if (chunk_start_offset < off) { + chunk_offset = off; + if ((off + pending_len) < (chunk_start_offset + + SFF_8436_PAGE_SIZE)) + chunk_len = pending_len; + else + chunk_len = (chunk+1)*SFF_8436_PAGE_SIZE - off;/*SFF_8436_PAGE_SIZE - off;*/ + } else { + chunk_offset = chunk_start_offset; + if (pending_len > SFF_8436_PAGE_SIZE) + chunk_len = SFF_8436_PAGE_SIZE; + else + chunk_len = pending_len; + } + + dev_dbg(&client->dev, + "sff_r/w: off %lld, len %ld, chunk_start_offset %lld, chunk_offset %lld, chunk_len %ld, pending_len %ld\n", + off, (long int) len, chunk_start_offset, chunk_offset, + (long int) chunk_len, (long int) pending_len); + + /* + * note: chunk_offset is from the start of the EEPROM, + * not the start of the chunk + */ + status = sff_8436_eeprom_update_client(port_data, buf, + chunk_offset, chunk_len, opcode); + if (status != chunk_len) { + /* This is another 'no device present' path */ + dev_dbg(&client->dev, + "sff_8436_update_client for chunk %d chunk_offset %lld chunk_len %ld failed %d!\n", + chunk, chunk_offset, (long int) chunk_len, status); + goto err; + } + buf += status; + pending_len -= status; + retval += status; + } + mutex_unlock(&port_data->update_lock); + + return retval; + +err: + mutex_unlock(&port_data->update_lock); + + return status; +} + +#else +static ssize_t sfp_port_read(struct sfp_port_data *data, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + DEBUG_PRINT("Count = 0, return"); + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sfp_eeprom_read(data->client, off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} +#endif + +static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + int present; + struct sfp_port_data *data; + DEBUG_PRINT("offset = (%d), count = (%d)", off, count); + data = dev_get_drvdata(container_of(kobj, struct device, kobj)); + present = sfp_is_port_present(data->client, data->port); + if (IS_ERR_VALUE(present)) { + return present; + } + + if (present == 0) { + /* port is not present */ + return -ENODEV; + } + +#if (MULTIPAGE_SUPPORT == 1) + return sfp_port_read_write(data, buf, off, count, QSFP_READ_OP); +#else + return sfp_port_read(data, buf, off, count); +#endif +} + +#if (MULTIPAGE_SUPPORT == 1) +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom, size_t size) +#else +static int sfp_sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +#endif +{ + int err; + + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IWUSR | S_IRUGO; + eeprom->read = sfp_bin_read; + eeprom->write = sfp_bin_write; +#if (MULTIPAGE_SUPPORT == 1) + eeprom->size = size; +#else + eeprom->size = EEPROM_SIZE; +#endif + + /* Create eeprom file */ + err = sysfs_create_bin_file(kobj, eeprom); + if (err) { + return err; + } + + return 0; +} + +static int sfp_sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + + +#if (MULTIPAGE_SUPPORT == 0) +static int sfp_i2c_check_functionality(struct i2c_client *client) +{ +#if USE_I2C_BLOCK_READ + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK); +#else + return i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); +#endif +} +#endif + + +static const struct attribute_group qsfp_group = { + .attrs = qsfp_attributes, +}; + +static int qsfp_probe(struct i2c_client *client, const struct i2c_device_id *dev_id, + struct qsfp_data **data) +{ + int status; + struct qsfp_data *qsfp; + +#if (MULTIPAGE_SUPPORT == 0) + if (!sfp_i2c_check_functionality(client)) { + status = -EIO; + goto exit; + } +#endif + + qsfp = kzalloc(sizeof(struct qsfp_data), GFP_KERNEL); + if (!qsfp) { + status = -ENOMEM; + goto exit; + } + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &qsfp_group); + if (status) { + goto exit_free; + } + + /* init eeprom */ +#if (MULTIPAGE_SUPPORT == 1) + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin, SFF_8436_EEPROM_SIZE); +#else + status = sfp_sysfs_eeprom_init(&client->dev.kobj, &qsfp->eeprom.bin); +#endif + if (status) { + goto exit_remove; + } + + *data = qsfp; + dev_info(&client->dev, "qsfp '%s'\n", client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &qsfp_group); +exit_free: + kfree(qsfp); +exit: + + return status; +} + +/* Platform dependent +++ */ +static int sfp_device_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + int ret = 0; + struct sfp_port_data *data = NULL; + + if (client->addr != SFP_EEPROM_A0_I2C_ADDR) { + return -ENODEV; + } + + if (dev_id->driver_data < as6812_32x_port1 || dev_id->driver_data > as6812_32x_port32) { + return -ENXIO; + } + + data = kzalloc(sizeof(struct sfp_port_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + +#if (MULTIPAGE_SUPPORT == 1) + data->use_smbus = 0; + + /* Use I2C operations unless we're stuck with SMBus extensions. */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + data->use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_WORD_DATA)) { + data->use_smbus = I2C_SMBUS_WORD_DATA; + } else if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA)) { + data->use_smbus = I2C_SMBUS_BYTE_DATA; + } else { + ret = -EPFNOSUPPORT; + goto exit_kfree; + } + } + + if (!data->use_smbus || + (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_WORD_DATA) || + i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + /* + * NOTE: AN-2079 + * Finisar recommends that the host implement 1 byte writes + * only since this module only supports 32 byte page boundaries. + * 2 byte writes are acceptable for PE and Vout changes per + * Application Note AN-2071. + */ + unsigned write_max = 1; + + if (write_max > io_limit) + write_max = io_limit; + if (data->use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) + write_max = I2C_SMBUS_BLOCK_MAX; + data->write_max = write_max; + + /* buffer (data + address at the beginning) */ + data->writebuf = kmalloc(write_max + 2, GFP_KERNEL); + if (!data->writebuf) { + ret = -ENOMEM; + goto exit_kfree; + } + } else { + dev_warn(&client->dev, + "cannot write due to controller restrictions."); + } + + if (data->use_smbus == I2C_SMBUS_WORD_DATA || + data->use_smbus == I2C_SMBUS_BYTE_DATA) { + dev_notice(&client->dev, "Falling back to %s reads, " + "performance will suffer\n", data->use_smbus == + I2C_SMBUS_WORD_DATA ? "word" : "byte"); + } +#endif + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->port = dev_id->driver_data; + data->client = client; + data->driver_type = DRIVER_TYPE_QSFP; + + ret = qsfp_probe(client, dev_id, &data->qsfp); + if (ret < 0) { + goto exit_kfree_buf; + } + + return ret; + +exit_kfree_buf: +#if (MULTIPAGE_SUPPORT == 1) + if (data->writebuf) kfree(data->writebuf); +#endif + +exit_kfree: + kfree(data); + return ret; +} +/* Platform dependent --- */ + +static int qsfp_remove(struct i2c_client *client, struct qsfp_data *data) +{ + sfp_sysfs_eeprom_cleanup(&client->dev.kobj, &data->eeprom.bin); + sysfs_remove_group(&client->dev.kobj, &qsfp_group); + kfree(data); + return 0; +} + +static int sfp_device_remove(struct i2c_client *client) +{ + int ret = 0; + struct sfp_port_data *data = i2c_get_clientdata(client); +#if (MULTIPAGE_SUPPORT == 1) + kfree(data->writebuf); +#endif + + if (data->driver_type == DRIVER_TYPE_QSFP) { + ret = qsfp_remove(client, data->qsfp); + } + + kfree(data); + return ret; +} + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +static struct i2c_driver sfp_driver = { + .driver = { + .name = DRIVER_NAME, + }, + .probe = sfp_device_probe, + .remove = sfp_device_remove, + .id_table = sfp_device_id, + .address_list = normal_i2c, +}; + +static int __init sfp_init(void) +{ + return i2c_add_driver(&sfp_driver); +} + +static void __exit sfp_exit(void) +{ + i2c_del_driver(&sfp_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton as6812_32x_sfp driver"); +MODULE_LICENSE("GPL"); + +module_init(sfp_init); +module_exit(sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c index 20a5a884..10288992 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/onlp/builds/src/module/src/sfpi.c @@ -24,17 +24,35 @@ * ***********************************************************/ #include -#include + +#include /* For O_RDWR && open */ +#include +#include +#include +#include + +#include "platform_lib.h" #include -#include "x86_64_accton_as6812_32x_int.h" -#include "x86_64_accton_as6812_32x_log.h" -#define PORT_BUS_INDEX(port) (port+2) -#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" -#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-00%d/module_present_%d" -#define MODULE_PRESENT_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/0-0062/module_present_all" -#define MODULE_PRESENT_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/0-0064/module_present_all" +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; +#define FRONT_PORT_TO_CPLD_MUX_INDEX(port) (port+2) +static int +as6812_32x_sfp_node_read_int(char *node_path, int *value, int data_len) +{ + return onlp_file_read_int(value, node_path); +} + +static char* +as6812_32x_sfp_get_port_path(int port, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", + FRONT_PORT_TO_CPLD_MUX_INDEX(port), + node_name); + + return sfp_node_path; +} /************************************************************ * @@ -73,13 +91,12 @@ onlp_sfpi_is_present(int port) * Return < 0 if error. */ int present; - int addr = (port < 16) ? 62 : 64; - - if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, addr, (port+1)) < 0) { + char* path = as6812_32x_sfp_get_port_path(port, "sfp_is_present"); + + if (as6812_32x_sfp_node_read_int(path, &present, 1) != 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } - return present; } @@ -87,34 +104,27 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { uint32_t bytes[4]; - uint32_t *ptr = bytes; + char* path; FILE* fp; - /* Read present status of port 0~31 */ - int addr; + path = as6812_32x_sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); - for (addr = 62; addr <= 64; addr+=2) { - if (addr == 62) { - fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD2, "r"); - } - else { - fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD3, "r"); - } - - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - int count = fscanf(fp, "%x %x", ptr+0, ptr+1); - fclose(fp); - if(count != 2) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the module_present_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - ptr += count; + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3 + ); + fclose(fp); + if(count != AIM_ARRAYSIZE(bytes)) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; } /* Convert to 64 bit integer in port order */ @@ -143,25 +153,21 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) { + char* path = as6812_32x_sfp_get_port_path(port, "sfp_eeprom"); + /* * Read the SFP eeprom into data[] * * Return MISSING if SFP is missing. * Return OK if eeprom is read */ - int size = 0; memset(data, 0, 256); - if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { + if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) { AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } - if (size != 256) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; } @@ -170,4 +176,3 @@ onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py index 115f08b9..43c9b7d8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/platform-config/r0/src/python/x86_64_accton_as6812_32x_r0/__init__.py @@ -8,10 +8,9 @@ class OnlPlatform_x86_64_accton_as6812_32x_r0(OnlPlatformAccton, SYS_OBJECT_ID=".6812.32" def baseconfig(self): - self.insmod('optoe') self.insmod('cpr_4011_4mxx') self.insmod("ym2651y") - for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + for m in [ 'cpld', 'fan', 'psu', 'leds', 'sfp' ]: self.insmod("x86-64-accton-as6812-32x-%s.ko" % m) ########### initialize I2C bus 0 ########### @@ -26,8 +25,9 @@ class OnlPlatform_x86_64_accton_as6812_32x_r0(OnlPlatformAccton, # initialize QSFP port 1~32 for port in range(1, 33): - self.new_i2c_device('optoe1', 0x50, port+1) - subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+1), shell=True) + self.new_i2c_device('as6812_32x_port%d' % port, + 0x50, + port+1) ########### initialize I2C bus 1 ########### self.new_i2c_devices( From 0012b203db323542f7e47a79c6122d2e01d1081f Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 12 Apr 2018 17:49:57 +0000 Subject: [PATCH 217/244] If the first blkid lookup fails we can't take an exception if the following ubi lookup also fails. --- .../src/python/onl/mounts/__init__.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py index e6d24391..f1ac74d1 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py @@ -161,31 +161,36 @@ class OnlMountManager(object): if useUbiDev == True: if k == 'EFI-BOOT': return False - output = subprocess.check_output("ubinfo -d 0 -N %s" % k, shell=True).splitlines() + try: + output = subprocess.check_output("ubinfo -d 0 -N %s" % k, , + stderr=subprocess.STDOUT, shell=True).splitlines() + except subprocess.CalledProcessError: + return False + volumeId = None device = None for line in output: line = line.strip() p = line.find(':') if p < 0: - self.logger.debug("Invaild ubinfo output %s" % line) - + self.logger.debug("Invalid ubinfo output %s" % line) + name, value = line[:p], line[p+1:].strip() if 'Volume ID' in name: p = value.find('(') if p < 0: self.logger.debug("Invalid Volume ID %s" % value) - + volumeId = value[:p].strip() p = value.find('on') if p < 0: self.logger.debug("Invalid ubi devicde %s" % value) - + device = value[p+2:-1].strip() if 'Name' in name: v['device'] = "/dev/" + device + "_" + volumeId - - + + if not os.path.isdir(v['dir']): self.logger.debug("Make directory '%s'...", v['dir']) os.makedirs(v['dir']) From 15520e4dd68aa08844773c3c0dcb620a98d37f74 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 12 Apr 2018 15:04:08 -0700 Subject: [PATCH 218/244] Remove accidental changes. --- .../all/vendor-config-onl/src/python/onl/mounts/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py index f1ac74d1..32e952b4 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py @@ -162,8 +162,7 @@ class OnlMountManager(object): if k == 'EFI-BOOT': return False try: - output = subprocess.check_output("ubinfo -d 0 -N %s" % k, , - stderr=subprocess.STDOUT, shell=True).splitlines() + output = subprocess.check_output("ubinfo -d 0 -N %s" % k, shell=True).splitlines() except subprocess.CalledProcessError: return False From fca1b92a9f1cc61d56a666cc71983700747bb49a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Apr 2018 22:32:34 +0000 Subject: [PATCH 219/244] The postinst script now checks /usr/sbin/policy-rc.d Some complicated service dependencies will fail to configure under normal circumstances because invoke-rc.d will kill service start based on policy-rc.d but this is not taken into account when configuring services that are dependent on that service. The dependency check fails prior to the policy-rc.d check and as a result some packages will remain unconfigured after we have finished constructing the root filesystem. This is ok for most cases but precludes dynamic modification of that filesystem post-creation and will even cause those unconfigured services to be restarted the first time a new package is installed. Checking policy-rc.d first in the postinst script allows the configuration step to complete for all services and their dependents to fix these problems. --- tools/onlpm.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index 523287f0..4784fb79 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -69,10 +69,17 @@ class OnlPackageServiceScript(object): class OnlPackageAfterInstallScript(OnlPackageServiceScript): SCRIPT = """#!/bin/sh -set -e if [ -x "/etc/init.d/%(service)s" ]; then - update-rc.d %(service)s defaults >/dev/null - invoke-rc.d %(service)s start || exit $? + if [ -x "/usr/sbin/policy-rc.d" ]; then + /usr/sbin/policy-rc.d + if [ $? -eq 101 ]; then + echo "warning: service %(service)s: postinst: ignored due to policy-rc.d" + exit 0; + fi + fi + set -e + update-rc.d %(service)s defaults >/dev/null + invoke-rc.d %(service)s start || exit $? fi """ @@ -80,7 +87,7 @@ class OnlPackageBeforeRemoveScript(OnlPackageServiceScript): SCRIPT = """#!/bin/sh set -e if [ -x "/etc/init.d/%(service)s" ]; then - invoke-rc.d %(service)s stop || exit $? + invoke-rc.d %(service)s stop || exit $? fi """ @@ -88,7 +95,7 @@ class OnlPackageAfterRemoveScript(OnlPackageServiceScript): SCRIPT = """#!/bin/sh set -e if [ "$1" = "purge" ] ; then - update-rc.d %(service)s remove >/dev/null + update-rc.d %(service)s remove >/dev/null fi """ From 736eeadb4d640b4cc73c26c0dca687a68bbb4fd3 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Apr 2018 22:41:28 +0000 Subject: [PATCH 220/244] Use onldebni to automatically run debian operations non-interactively under policy-rc.d protection. This is useful for automated RFS modifications after first creation. --- packages/base/all/vendor-config-onl/src/bin/onldebni | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 packages/base/all/vendor-config-onl/src/bin/onldebni diff --git a/packages/base/all/vendor-config-onl/src/bin/onldebni b/packages/base/all/vendor-config-onl/src/bin/onldebni new file mode 100755 index 00000000..1d02eeac --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/bin/onldebni @@ -0,0 +1,9 @@ +#!/bin/bash +/bin/echo -e "#!/bin/sh\\nexit 101" >/usr/sbin/policy-rc.d +chmod +x /usr/sbin/policy-rc.d +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true +$@ +rc=$? +rm -f /usr/sbin/policy-rc.d +exit $rc From 43d76e58f6994d28f3e60e4a72b0ebcddfb23c2e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Apr 2018 22:43:43 +0000 Subject: [PATCH 221/244] RFS Management Enhancements This is a baby step in reorganizing the RFS tools to support arbitrary automation and modification after the initial multistrap configuration has been performed. - All RFS modifications are now done under the new OnlRfsContext object. - This object mounts/unmounts /dev and /proc - This object installs and removes the local resolv.conf so network operations can be performed in the chroot context. --- tools/onlrfs.py | 72 ++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index 2f471ea0..f05a5f0e 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -243,6 +243,37 @@ class OnlMultistrapConfig(object): return handle.getvalue() + +class OnlRfsContext(object): + def __init__(self, directory): + self.directory = directory + self.dev = os.path.join(self.directory, "dev") + self.proc = os.path.join(self.directory, "proc") + self.resolv = os.path.join(self.directory, "etc", "resolv.conf") + self.resolvb = "%s.backup" % self.resolv + + def __enter__(self): + onlu.execute("sudo mount -t devtmpfs dev %s" % self.dev, + ex=OnlRfsError("Could not mount dev in rfs.")) + onlu.execute("sudo mount -t proc proc %s" % self.proc, + ex=OnlRfsError("Could not mount proc in rfs.")) + if os.path.islink(self.resolv) or os.path.exists(self.resolv): + onlu.execute("sudo mv %s %s" % (self.resolv, self.resolvb), + ex=OnlRfsError("Could not backup %s" % (self.resolv))) + onlu.execute("sudo cp /etc/resolv.conf %s" % (self.resolv), + ex=OnlRfsError("Could not copy resolv.conf")) + return self + + def __exit__(self, eType, eValue, eTrace): + onlu.execute("sudo umount -l %s %s" % (self.dev, self.proc), + ex=OnlRfsError("Could not unmount dev and proc")) + onlu.execute("sudo rm %s" % (self.resolv), + ex=OnlRfsError("Could not remove resolv.conf")) + + if os.path.islink("%s" % self.resolvb) or os.path.exists(resolvb): + onlu.execute("sudo mv %s %s" % (self.resolvb, self.resolv), + ex=OnlRfsError("Could not restore the resolv.conf backup")) + class OnlRfsBuilder(object): DEFAULTS = dict( @@ -368,13 +399,7 @@ rm -f /usr/sbin/policy-rc.d def configure(self, dir_): - try: - - onlu.execute("sudo mount -t devtmpfs dev %s" % os.path.join(dir_, "dev"), - ex=OnlRfsError("Could not mount dev in new filesystem.")) - - onlu.execute("sudo mount -t proc proc %s" % os.path.join(dir_, "proc"), - ex=OnlRfsError("Could not mount proc in new filesystem.")) + with OnlRfsContext(dir_): if not os.getenv('NO_DPKG_CONFIGURE'): self.dpkg_configure(dir_) @@ -393,6 +418,11 @@ rm -f /usr/sbin/policy-rc.d Configure = self.config.get('Configure', None) if Configure: + + for cmd in Configure.get('run', []): + onlu.execute("sudo chroot %s %s" % (dir_, cmd), + ex=OnlRfsError("run command '%s' failed" % cmd)) + for overlay in Configure.get('overlays', []): logger.info("Overlay %s..." % overlay) onlu.execute('tar -C %s -c --exclude "*~" . | sudo tar -C %s -x -v --no-same-owner' % (overlay, dir_), @@ -552,22 +582,11 @@ rm -f /usr/sbin/policy-rc.d onlu.execute("sudo chmod a-w %s" % fn) - - finally: - onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc"))) - def update(self, dir_, packages): ONLPM = "%s/tools/onlpm.py" % os.getenv('ONL') - try: - - onlu.execute("sudo mount -t devtmpfs dev %s" % os.path.join(dir_, "dev"), - ex=OnlRfsError("Could not mount dev in new filesystem.")) - - onlu.execute("sudo mount -t proc proc %s" % os.path.join(dir_, "proc"), - ex=OnlRfsError("Could not mount proc in new filesystem.")) - + with OnlRfsContext(dir_): for pspec in packages: for pkg in pspec.split(','): logger.info("updating %s into %s", pkg, dir_) @@ -577,21 +596,11 @@ rm -f /usr/sbin/policy-rc.d onlu.execute(cmd, ex=OnlRfsError("update of %s failed" % pkg)) - finally: - onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc"))) - def install(self, dir_, packages): ONLPM = "%s/tools/onlpm.py" % os.getenv('ONL') - try: - - onlu.execute("sudo mount -t devtmpfs dev %s" % os.path.join(dir_, "dev"), - ex=OnlRfsError("Could not mount dev in new filesystem.")) - - onlu.execute("sudo mount -t proc proc %s" % os.path.join(dir_, "proc"), - ex=OnlRfsError("Could not mount proc in new filesystem.")) - + with OnlRfsContext(dir_): for pspec in packages: for pkg in pspec.split(','): @@ -623,9 +632,6 @@ rm -f /usr/sbin/policy-rc.d chroot=dir_, ex=OnlRfsError("install of %s failed" % pkg)) - finally: - onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc"))) - if __name__ == '__main__': From b0f4a6f20943a536a1f59dab5733d0729314976a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Apr 2018 23:39:29 +0000 Subject: [PATCH 222/244] Fix resolv.conf restoration. --- tools/onlrfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index f05a5f0e..6946eea7 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -270,7 +270,7 @@ class OnlRfsContext(object): onlu.execute("sudo rm %s" % (self.resolv), ex=OnlRfsError("Could not remove resolv.conf")) - if os.path.islink("%s" % self.resolvb) or os.path.exists(resolvb): + if os.path.islink(self.resolvb) or os.path.exists(self.resolvb): onlu.execute("sudo mv %s %s" % (self.resolvb, self.resolv), ex=OnlRfsError("Could not restore the resolv.conf backup")) From 463bfdd3b3c80fb117fc884b5ee4de60e1b74b13 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Mon, 16 Apr 2018 15:35:23 +0800 Subject: [PATCH 223/244] Add as7726-32x onlp code --- .../x86-64-accton-as7726-32x/.gitignore | 3 + .../x86-64/x86-64-accton-as7726-32x/Makefile | 1 + .../x86-64-accton-as7726-32x/modules/Makefile | 1 + .../x86-64-accton-as7726-32x/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as7726-32x-cpld.c | 740 ++++++++++++++++++ .../builds/x86-64-accton-as7726-32x-fan.c | 472 +++++++++++ .../builds/x86-64-accton-as7726-32x-leds.c | 438 +++++++++++ .../builds/x86-64-accton-as7726-32x-psu.c | 276 +++++++ .../x86-64-accton-as7726-32x/onlp/Makefile | 1 + .../x86-64-accton-as7726-32x/onlp/PKG.yml | 2 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++ .../onlp/builds/onlpdump/Makefile | 46 ++ .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../module/auto/x86_64_accton_as7726_32x.yml | 50 ++ .../x86_64_accton_as7726_32x.x | 14 + .../x86_64_accton_as7726_32x_config.h | 137 ++++ .../x86_64_accton_as7726_32x_dox.h | 26 + .../x86_64_accton_as7726_32x_porting.h | 107 +++ .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/debug.c | 45 ++ .../onlp/builds/src/module/src/fani.c | 367 +++++++++ .../onlp/builds/src/module/src/ledi.c | 261 ++++++ .../onlp/builds/src/module/src/platform_lib.c | 202 +++++ .../onlp/builds/src/module/src/platform_lib.h | 87 ++ .../onlp/builds/src/module/src/psui.c | 185 +++++ .../onlp/builds/src/module/src/sfpi.c | 422 ++++++++++ .../onlp/builds/src/module/src/sysi.c | 490 ++++++++++++ .../onlp/builds/src/module/src/thermali.c | 174 ++++ .../src/x86_64_accton_as7726_32x_config.c | 81 ++ .../src/x86_64_accton_as7726_32x_enums.c | 10 + .../module/src/x86_64_accton_as7726_32x_int.h | 12 + .../module/src/x86_64_accton_as7726_32x_log.c | 17 + .../module/src/x86_64_accton_as7726_32x_log.h | 12 + .../src/x86_64_accton_as7726_32x_module.c | 24 + .../src/x86_64_accton_as7726_32x_ucli.c | 50 ++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-as7726-32x-r0.yml | 31 + .../x86_64_accton_as7726_32x_r0/__init__.py | 104 +++ 46 files changed, 4972 insertions(+) create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/.gitignore create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/PKG.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/.gitignore create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-cpld.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-fan.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-leds.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-psu.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/PKG.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/lib/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/onlpdump/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/PKG.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/lib/x86-64-accton-as7726-32x-r0.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/python/x86_64_accton_as7726_32x_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/.gitignore new file mode 100755 index 00000000..7491357a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/.gitignore @@ -0,0 +1,3 @@ +*x86*64*accton*as7726*32x*.mk +onlpdump.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/PKG.yml new file mode 100755 index 00000000..0ad0654b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as7726-32x ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/.gitignore new file mode 100755 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/Makefile new file mode 100755 index 00000000..7befc368 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as7726-32x +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-cpld.c new file mode 100755 index 00000000..ab0b9c45 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-cpld.c @@ -0,0 +1,740 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as7726_32x CPLD1/CPLD2/CPLD3 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as7726_32x_cpld1, + as7726_32x_cpld2, + as7726_32x_cpld3 +}; + +struct as7726_32x_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +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 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as7726_32x_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +//#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as7726_32x_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34) +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as7726_32x_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as7726_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); + +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr + + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); + + +static struct attribute *as7726_32x_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + NULL +}; + +static const struct attribute_group as7726_32x_cpld1_group = { + .attrs = as7726_32x_cpld1_attributes, +}; + +static struct attribute *as7726_32x_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7726_32x_cpld2_group = { + .attrs = as7726_32x_cpld2_attributes, +}; + +static struct attribute *as7726_32x_cpld3_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + NULL +}; + +static const struct attribute_group as7726_32x_cpld3_group = { + .attrs = as7726_32x_cpld3_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[5] = {0}; + u8 regs[] = {0x30, 0x31, 0x32, 0x33, 0x50}; + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as7726_32x_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 54 in order */ + //if (data->type == as7726_32x_cpld2) { + // values[3] &= 0xF; + // } + //else { /* as7726_32x_cpld3 */ + //values[3] &= 0x3; + // } + values[4] &= 0x3; + return sprintf(buf, "%.2x %.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3], values[4]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 value=0; + u8 reg = 0x50; + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + status = as7726_32x_cpld_read_internal(client, reg); + + if (status < 0) + goto exit; + + value = (u8)status; + value &= 0x0C; + value = value >> 2; + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 34 in order */ + return sprintf(buf, "00 00 00 00 %.2x\n", value); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_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 as7726_32x_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x31; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x33; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33: + reg = 0x50; + mask = 0x1; + break; + case MODULE_PRESENT_34: + reg = 0x50; + mask = 0x2; + break; + case MODULE_RXLOS_33: + reg = 0x50; + mask = 0x4; + break; + case MODULE_RXLOS_34: + reg = 0x50; + mask = 0x8; + break; + case MODULE_TXDISABLE_33: + reg = 0x49; + mask = 0x1; + break; + case MODULE_TXDISABLE_34: + reg = 0x49; + mask = 0x2; + break; + + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_34) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as7726_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_33: + reg = 0x49; + mask = 0x1; + break; + case MODULE_TXDISABLE_34: + reg = 0x49; + mask = 0x2; + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as7726_32x_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as7726_32x_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as7726_32x_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as7726_32x_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as7726_32x_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d\n", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as7726_32x_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as7726_32x_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as7726_32x_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as7726_32x_cpld1: + group = &as7726_32x_cpld1_group; + break; + case as7726_32x_cpld2: + group = &as7726_32x_cpld2_group; + break; + case as7726_32x_cpld3: + group = &as7726_32x_cpld3_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as7726_32x_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as7726_32x_cpld_remove(struct i2c_client *client) +{ + struct as7726_32x_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as7726_32x_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as7726_32x_cpld1: + group = &as7726_32x_cpld1_group; + break; + case as7726_32x_cpld2: + group = &as7726_32x_cpld2_group; + break; + case as7726_32x_cpld3: + group = &as7726_32x_cpld3_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as7726_32x_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as7726_32x_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as7726_32x_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7726_32x_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7726_32x_cpld_read); + +int as7726_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as7726_32x_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as7726_32x_cpld_write); + +static struct i2c_driver as7726_32x_cpld_driver = { + .driver = { + .name = "as7726_32x_cpld", + .owner = THIS_MODULE, + }, + .probe = as7726_32x_cpld_probe, + .remove = as7726_32x_cpld_remove, + .id_table = as7726_32x_cpld_id, +}; + +static int __init as7726_32x_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as7726_32x_cpld_driver); +} + +static void __exit as7726_32x_cpld_exit(void) +{ + i2c_del_driver(&as7726_32x_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as7726_32x_cpld_init); +module_exit(as7726_32x_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-fan.c new file mode 100755 index 00000000..53c3f405 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-fan.c @@ -0,0 +1,472 @@ +/* + * A hwmon driver for the Accton as7726 32x fan + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as7726_32x_fan" + +static struct as7726_32x_fan_data *as7726_32x_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x0F, /* fan 1-6 present status */ + 0x10, /* fan 1-6 direction(0:F2B 1:B2F) */ + 0x11, /* fan PWM(for all fan) */ + 0x12, /* front fan 1 speed(rpm) */ + 0x13, /* front fan 2 speed(rpm) */ + 0x14, /* front fan 3 speed(rpm) */ + 0x15, /* front fan 4 speed(rpm) */ + 0x16, /* front fan 5 speed(rpm) */ + 0x17, /* front fan 6 speed(rpm) */ + 0x22, /* rear fan 1 speed(rpm) */ + 0x23, /* rear fan 2 speed(rpm) */ + 0x24, /* rear fan 3 speed(rpm) */ + 0x25, /* rear fan 4 speed(rpm) */ + 0x26, /* rear fan 5 speed(rpm) */ + 0x27, /* rear fan 6 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as7726_32x_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID, + FAN5_ID, + FAN6_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DIRECTION_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN5_FRONT_SPEED_RPM, + FAN6_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN5_REAR_SPEED_RPM, + FAN6_REAR_SPEED_RPM, + FAN1_DIRECTION, + FAN2_DIRECTION, + FAN3_DIRECTION, + FAN4_DIRECTION, + FAN5_DIRECTION, + FAN6_DIRECTION, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN6_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT, + FAN5_FAULT, + FAN6_FAULT +}; + +/* Define attributes + */ +#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 + +#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); +/* 6 fan direction attribute in this platform */ +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); + +static struct attribute *as7726_32x_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_FAULT_ATTR(4), + DECLARE_FAN_FAULT_ATTR(5), + DECLARE_FAN_FAULT_ATTR(6), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(4), + DECLARE_FAN_SPEED_RPM_ATTR(5), + DECLARE_FAN_SPEED_RPM_ATTR(6), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(5), + DECLARE_FAN_PRESENT_ATTR(6), + DECLARE_FAN_DIRECTION_ATTR(1), + DECLARE_FAN_DIRECTION_ATTR(2), + DECLARE_FAN_DIRECTION_ATTR(3), + DECLARE_FAN_DIRECTION_ATTR(4), + DECLARE_FAN_DIRECTION_ATTR(5), + DECLARE_FAN_DIRECTION_ATTR(6), + DECLARE_FAN_DUTY_CYCLE_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as7726_32x_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as7726_32x_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val+1) * 625 + 75)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + return ((u32)duty_cycle * 100 / 625) - 1; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 1 : 0; +} +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 0 : 1; +} + +static u8 is_fan_fault(struct as7726_32x_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as7726_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as7726_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7726_32x_fan_data *data = as7726_32x_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN5_FRONT_SPEED_RPM: + case FAN6_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + case FAN5_REAR_SPEED_RPM: + case FAN6_REAR_SPEED_RPM: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + case FAN6_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + case FAN5_FAULT: + case FAN6_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIRECTION: + case FAN2_DIRECTION: + case FAN3_DIRECTION: + case FAN4_DIRECTION: + case FAN5_DIRECTION: + case FAN6_DIRECTION: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], + attr->index - FAN1_DIRECTION)); + break; + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as7726_32x_fan_group = { + .attrs = as7726_32x_fan_attributes, +}; + +static struct as7726_32x_fan_data *as7726_32x_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as7726_32x_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as7726_32x_fan_read_value(client, fan_reg[i]); + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as7726_32x_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7726_32x_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7726_32x_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7726_32x_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7726_32x_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7726_32x_fan_remove(struct i2c_client *client) +{ + struct as7726_32x_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7726_32x_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; + +static const struct i2c_device_id as7726_32x_fan_id[] = { + { "as7726_32x_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7726_32x_fan_id); + +static struct i2c_driver as7726_32x_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as7726_32x_fan_probe, + .remove = as7726_32x_fan_remove, + .id_table = as7726_32x_fan_id, + .address_list = normal_i2c, +}; + +module_i2c_driver(as7726_32x_fan_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7726_32x_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-leds.c new file mode 100755 index 00000000..040d96b9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-leds.c @@ -0,0 +1,438 @@ +/* + * A LED driver for the accton_as7726_32x_led + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*#define DEBUG*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int as7726_32x_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as7726_32x_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +extern void led_classdev_unregister(struct led_classdev *led_cdev); +extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); +extern void led_classdev_resume(struct led_classdev *led_cdev); +extern void led_classdev_suspend(struct led_classdev *led_cdev); + +#define DRVNAME "accton_as7726_32x_led" + +struct accton_as7726_32x_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[1]; /* only 1 register*/ +}; + +static struct accton_as7726_32x_led_data *ledctl = NULL; + +/* LED related data + */ + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x3) +#define LED_MODE_DIAG_GREEN_VALUE (0x02) +#define LED_MODE_DIAG_RED_VALUE (0x01) +#define LED_MODE_DIAG_AMBER_VALUE (0x00) /*It's yellow actually. Green+Red=Yellow*/ +#define LED_MODE_DIAG_OFF_VALUE (0x03) + + +#define LED_TYPE_LOC_REG_MASK (0x80) +#define LED_MODE_LOC_ON_VALUE (0) +#define LED_MODE_LOC_OFF_VALUE (0x80) + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +struct led_reg { + u32 types; + u8 reg_addr; +}; + +static const struct led_reg led_reg_map[] = { + {(1<update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as7726_32x_led update\n"); + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as7726_32x_led_read_value(led_reg_map[i].reg_addr); + + if (status < 0) { + ledctl->valid = 0; + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); + goto exit; + } + else + { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as7726_32x_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + enum led_type type) +{ + int reg_val; + u8 reg ; + mutex_lock(&ledctl->update_lock); + + if( !accton_getLedReg(type, ®)) + { + dev_dbg(&ledctl->pdev->dev, "Not match item for %d.\n", type); + } + + reg_val = accton_as7726_32x_led_read_value(reg); + + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + accton_as7726_32x_led_write_value(reg, reg_val); + + /* to prevent the slow-update issue */ + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + + +static void accton_as7726_32x_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7726_32x_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); +} + +static enum led_brightness accton_as7726_32x_led_diag_get(struct led_classdev *cdev) +{ + accton_as7726_32x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static void accton_as7726_32x_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as7726_32x_led_set(led_cdev, led_light_mode, LED_TYPE_LOC); +} + +static enum led_brightness accton_as7726_32x_led_loc_get(struct led_classdev *cdev) +{ + accton_as7726_32x_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void accton_as7726_32x_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness accton_as7726_32x_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static struct led_classdev accton_as7726_32x_leds[] = { + [LED_TYPE_DIAG] = { + .name = "accton_as7726_32x_led::diag", + .default_trigger = "unused", + .brightness_set = accton_as7726_32x_led_diag_set, + .brightness_get = accton_as7726_32x_led_diag_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_RED, + }, + [LED_TYPE_LOC] = { + .name = "accton_as7726_32x_led::loc", + .default_trigger = "unused", + .brightness_set = accton_as7726_32x_led_loc_set, + .brightness_get = accton_as7726_32x_led_loc_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_BLUE, + }, + [LED_TYPE_FAN] = { + .name = "accton_as7726_32x_led::fan", + .default_trigger = "unused", + .brightness_set = accton_as7726_32x_led_auto_set, + .brightness_get = accton_as7726_32x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU1] = { + .name = "accton_as7726_32x_led::psu1", + .default_trigger = "unused", + .brightness_set = accton_as7726_32x_led_auto_set, + .brightness_get = accton_as7726_32x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "accton_as7726_32x_led::psu2", + .default_trigger = "unused", + .brightness_set = accton_as7726_32x_led_auto_set, + .brightness_get = accton_as7726_32x_led_auto_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as7726_32x_led_suspend(struct platform_device *dev, + pm_message_t state) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7726_32x_leds); i++) { + led_classdev_suspend(&accton_as7726_32x_leds[i]); + } + + return 0; +} + +static int accton_as7726_32x_led_resume(struct platform_device *dev) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as7726_32x_leds); i++) { + led_classdev_resume(&accton_as7726_32x_leds[i]); + } + + return 0; +} + +static int accton_as7726_32x_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as7726_32x_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as7726_32x_leds[i]); + + if (ret < 0) + break; + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as7726_32x_leds)) { + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as7726_32x_leds[i]); + } + } + + return ret; +} + +static int accton_as7726_32x_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as7726_32x_leds); i++) { + led_classdev_unregister(&accton_as7726_32x_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as7726_32x_led_driver = { + .probe = accton_as7726_32x_led_probe, + .remove = accton_as7726_32x_led_remove, + .suspend = accton_as7726_32x_led_suspend, + .resume = accton_as7726_32x_led_resume, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as7726_32x_led_init(void) +{ + int ret; + + ret = platform_driver_register(&accton_as7726_32x_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as7726_32x_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + platform_driver_unregister(&accton_as7726_32x_led_driver); + goto exit; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + platform_driver_unregister(&accton_as7726_32x_led_driver); + kfree(ledctl); + goto exit; + } + +exit: + return ret; +} + +static void __exit accton_as7726_32x_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as7726_32x_led_driver); + kfree(ledctl); +} + +module_init(accton_as7726_32x_led_init); +module_exit(accton_as7726_32x_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as7726_32x_led driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-psu.c new file mode 100755 index 00000000..358e032c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/modules/builds/x86-64-accton-as7726-32x-psu.c @@ -0,0 +1,276 @@ +/* + * An hwmon driver for accton as7726_32x Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static int as7726_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int as7726_32x_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x50, 0x53, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as7726_32x_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[9]; /* Model name, read from eeprom */ +}; + +static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *dev); + +enum as7726_32x_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as7726_32x_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as7726_32x_psu_data *data = as7726_32x_psu_update_device(dev); + u8 status = 0; + + if (attr->index == PSU_PRESENT) { + status = !(data->status >> (1-data->index) & 0x1); + } + else { /* PSU_POWER_GOOD */ + status = (data->status >> (3-data->index) & 0x1); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as7726_32x_psu_data *data = as7726_32x_psu_update_device(dev); + + return sprintf(buf, "%s\n", data->model_name); +} + +static const struct attribute_group as7726_32x_psu_group = { + .attrs = as7726_32x_psu_attributes, +}; + +static int as7726_32x_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as7726_32x_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as7726_32x_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as7726_32x_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as7726_32x_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as7726_32x_psu_remove(struct i2c_client *client) +{ + struct as7726_32x_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as7726_32x_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as7726_32x_psu1, + as7726_32x_psu2 +}; + +static const struct i2c_device_id as7726_32x_psu_id[] = { + { "as7726_32x_psu1", as7726_32x_psu1 }, + { "as7726_32x_psu2", as7726_32x_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as7726_32x_psu_id); + +static struct i2c_driver as7726_32x_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as7726_32x_psu", + }, + .probe = as7726_32x_psu_probe, + .remove = as7726_32x_psu_remove, + .id_table = as7726_32x_psu_id, + .address_list = normal_i2c, +}; + +static int as7726_32x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as7726_32x_psu_data *as7726_32x_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as7726_32x_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as7726_32x update\n"); + + /* Read psu status */ + status = as7726_32x_cpld_read(0x60, 0x2); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + power_good = (data->status >> (3-data->index) & 0x1); + + if (power_good) { + status = as7726_32x_psu_read_block(client, 0x20, data->model_name, + ARRAY_SIZE(data->model_name)-1); + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +module_i2c_driver(as7726_32x_psu_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as7726_32x_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/PKG.yml new file mode 100755 index 00000000..e1a658e8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7726-32x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/Makefile new file mode 100755 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/lib/Makefile new file mode 100755 index 00000000..be977f95 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as7726-32x +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as7726_32x onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as7726-32x.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..ab39002a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as7726_32x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore new file mode 100755 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module new file mode 100755 index 00000000..28f927de --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as7726_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile new file mode 100755 index 00000000..9dfffde1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_accton_as7726_32x +AUTOMODULE := x86_64_accton_as77262_32x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README new file mode 100755 index 00000000..5aad1403 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as7726_32x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml new file mode 100755 index 00000000..d53b22b2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_accton_as7726_32x Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: x86_64_accton_as7726_32x_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + x86_64_accton_as7726_32x_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as7726_32x_config + + portingmacro: + x86_64_accton_as7726_32x: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x new file mode 100755 index 00000000..b0e04177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h new file mode 100755 index 00000000..72cb2aa4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7726_32x Configuration Header + * + * @addtogroup x86_64_accton_as7726_32x-config + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7726_32x_CONFIG_H__ +#define __x86_64_accton_as7726_32x_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef x86_64_accton_as7726_32x_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7726_32x_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as7726_32x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as7726_32x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as7726_32x_config_settings table. */ +extern x86_64_accton_as7726_32x_config_settings_t x86_64_accton_as7726_32x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as7726_32x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as7726_32x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as7726_32x_porting.h" + +#endif /* __x86_64_accton_as7726_32x_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h new file mode 100755 index 00000000..d92d6638 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as7726_32x Doxygen Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7726_32x_DOX_H__ +#define __x86_64_accton_as7726_32x_DOX_H__ + +/** + * @defgroup x86_64_accton_as7726_32x x86_64_accton_as7726_32x - x86_64_accton_as7726_32x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as7726_32x-x86_64_accton_as7726_32x Public Interface + * @defgroup x86_64_accton_as7726_32x-config Compile Time Configuration + * @defgroup x86_64_accton_as7726_32x-porting Porting Macros + * + * @} + * + */ + +#endif /* __x86_64_accton_as7726_32x_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h new file mode 100755 index 00000000..8893de7f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7726_32x Porting Macros. + * + * @addtogroup x86_64_accton_as7726_32x-porting + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7726_32x_PORTING_H__ +#define __x86_64_accton_as7726_32x_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_ACCTON_AS7726_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_MALLOC malloc + #else + #error The macro X86_64_ACCTON_AS7726_32X_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_FREE + #if defined(GLOBAL_FREE) + #define X86_64_ACCTON_AS7726_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_FREE free + #else + #error The macro X86_64_ACCTON_AS7726_32X_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_ACCTON_AS7726_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_MEMSET memset + #else + #error The macro X86_64_ACCTON_AS7726_32X_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_ACCTON_AS7726_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_MEMCPY memcpy + #else + #error The macro X86_64_ACCTON_AS7726_32X_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_ACCTON_AS7726_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_STRNCPY strncpy + #else + #error The macro X86_64_ACCTON_AS7726_32X_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_ACCTON_AS7726_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_VSNPRINTF vsnprintf + #else + #error The macro X86_64_ACCTON_AS7726_32X_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_ACCTON_AS7726_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_SNPRINTF snprintf + #else + #error The macro X86_64_ACCTON_AS7726_32X_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_ACCTON_AS7726_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_STRLEN strlen + #else + #error The macro X86_64_ACCTON_AS7726_32X_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __x86_64_accton_as7726_32x_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile new file mode 100755 index 00000000..b1a02144 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as7726_32x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c new file mode 100755 index 00000000..92890fb7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c @@ -0,0 +1,45 @@ +#include "x86_64_accton_as7726_32x_int.h" + +#if x86_64_accton_as7726_32x_CONFIG_INCLUDE_DEBUG == 1 + +#include + +static char help__[] = + "Usage: debug [options]\n" + " -c CPLD Versions\n" + " -h Help\n" + ; + +int +x86_64_accton_as7726_32x_debug_main(int argc, char* argv[]) +{ + int c = 0; + int help = 0; + int rv = 0; + + while( (c = getopt(argc, argv, "ch")) != -1) { + switch(c) + { + case 'c': c = 1; break; + case 'h': help = 1; rv = 0; break; + default: help = 1; rv = 1; break; + } + + } + + if(help || argc == 1) { + printf("%s", help__); + return rv; + } + + if(c) { + printf("Not implemented.\n"); + } + + + return 0; +} + +#endif + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c new file mode 100755 index 00000000..e82f8a77 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c @@ -0,0 +1,367 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#define PSU_PREFIX_PATH "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + CHASSIS_FAN_INFO(6), + PSU_FAN_INFO(1,1), + PSU_FAN_INFO(2,1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value; + char path[64] = {0}; + + /* get fan present status + */ + sprintf(path, "%s""fan%d_present", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), present path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + sprintf(path, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), fault path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + sprintf(path, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), direction path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; + + + /* get front fan speed + */ + sprintf(path, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), front speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + sprintf(path, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), rear speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan fault status + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + DEBUG_PRINT("Fan path = (%s)", path); + + if (onlp_file_write_integer(path, p) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..85856aa3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,261 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/accton_as7726_32x_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c new file mode 100755 index 00000000..fc7a5f2c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,202 @@ +#include +#include +#include +#include +#include "platform_lib.h" +#include +#include "x86_64_accton_as7726_32x_log.h" + + +static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { + return -1; + } + + if ((len = write(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_write_integer(char *filename, int value) +{ + char buf[8] = {0}; + sprintf(buf, "%d", value); + + return _onlp_file_write(filename, buf, (int)strlen(buf), 0); +} + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_RDONLY)) == -1) { + return -1; + } + + if ((len = read(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 9 +#define I2C_PSU_FAN_DIR_LEN 3 + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model); + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (modelname) { + strncpy(modelname, model_name, modelname_len-1); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_integer(path, value) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..96c817bb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,87 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include +#include "x86_64_accton_as7726_32x_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 6 +#define CHASSIS_PSU_COUNT 2 +#define CHASSIS_LED_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/50-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/49-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/50-0053/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/49-0050/" + + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/54-0066/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom" + +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); + + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); + +//#define DEBUG_MODE 1 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c new file mode 100755 index 00000000..5185a145 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c @@ -0,0 +1,185 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +//#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + + + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + psu_serial_number_get(index, info->serial, sizeof(info->serial)); + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c new file mode 100755 index 00000000..f9d671b0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,422 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "x86_64_accton_as7726_32x_int.h" +#include "x86_64_accton_as7726_32x_log.h" + +#define PORT_BUS_INDEX(port) (port+18) + +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD "/sys/bus/i2c/devices/11-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/6-0064/module_rx_los_all" + + +int sfp_map_bus[] ={21, 22, 23, 24, 26, 25, 28, 27, + 17, 18, 19, 20, 29, 30, 31, 32, + 33, 34, 35, 36, 45, 46, 47, 48, + 37, 38, 39, 40, 41, 42, 43, 44, + 15, 16}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ + +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} +int +onlp_sfpi_map_bus_index(int port) +{ + if(port < 0 || port >=34) + return ONLP_STATUS_E_INTERNAL; + return sfp_map_bus[port]; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 34} + */ + int p; + + for(p = 0; p < 34; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus, addr; + + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + + addr = 60; + bus = 11; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[5], *ptr = NULL; + FILE* fp; + int addr=60; + int bus=11; + char file[64] = {0}; + int count; + + ptr = bytes; + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + count = fscanf(fp, "%x %x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3, ptr+4); + fclose(fp); + if(count != 5) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + uint64_t presence_all = 0 ; + int i = 0; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[5]; + uint32_t *ptr = bytes; + FILE* fp; + + int addr=60, i = 0; + + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3, ptr+4); + fclose(fp); + if(count != 5) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + uint64_t rx_los_all = 0; + bytes[0]=bytes[1]=bytes[2]=bytes[3]=0xff; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + int addr = 60; + int bus = 11; + + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if(port==32 || port==33) + { + if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else if(port >=0) + { + if(!onlp_sfpi_is_present(port)) + return ONLP_STATUS_OK; + rv=onlp_sfpi_dev_writeb(port, 0x50, 86, 1); + if(rv < 0) + { + AIM_LOG_ERROR("Fail to read onlp_sfpi_dev_writeb, port=%d\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else + { + rv = ONLP_STATUS_OK; + } + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + int addr = 60; + int bus = 11; + + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if(port==32 || port==33) + { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else + return ONLP_STATUS_E_UNSUPPORTED; + + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if(port==32 || port==33) + { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else + return ONLP_STATUS_E_UNSUPPORTED; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if(port==32 || port==33) + { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else + { + if(port >= 0) + { + if(!onlp_sfpi_is_present(port)) + { + *value=0; + return ONLP_STATUS_OK; + } + rv=onlp_sfpi_dev_readb(port, 0x50, 86); + if(rv < 0) + { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else + { + *value= (rv & 0x1); + rv = ONLP_STATUS_OK; + } + } + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..4e16b3ad --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,490 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_accton_as7726_32x_int.h" +#include "x86_64_accton_as7726_32x_log.h" + + +#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" +#define NUM_OF_CPLD 3 +#define FAN_DUTY_CYCLE_MAX (100) +#define FAN_DUTY_CYCLE_DEFAULT (32) +#define FAN_DUTY_PLUS_FOR_DIR (13) +/* Note, all chassis fans share 1 single duty setting. + * Here use fan 1 to represent global fan duty value.*/ +#define FAN_ID_FOR_SET_FAN_DUTY (1) +#define CELSIUS_RECORD_NUMBER (2) /*Must >= 2*/ + +typedef struct fan_ctrl_policy { + int duty_cycle; /* In percetage */ + int step_up_thermal; /* In mini-Celsius */ + int step_dn_thermal; /* In mini-Celsius */ +} fan_ctrl_policy_t; + +static char arr_cplddev_name[NUM_OF_CPLD][10] = +{ + "4-0060", + "5-0062", + "6-0064" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as7726-32x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 6 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +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); +} + +/* Thermal plan: + * $TMP = (CPU_core + LM75_1+ LM75_2 + LM75_3 + LM75_4)/5 + * 1. If any FAN failed, set all the other fans as full speed, 100%. + * 2. If any sensor is high than 45 degrees, set fan speed to duty 62.5%. + * 3. If any sensor is high than 50 degrees, set fan speed to duty 100%. + * 4. When $TMP >= 40 C, set fan speed to duty 62.5%. + * 5. When $TMP >= 45 C, set fan speed to duty 100%. + * 6. When $TMP < 35 C, set fan speed to duty 31.25%. + * 7. Direction factor, when B2F, duty + 12.5%. + * + * Note, all chassis fans share 1 single duty setting. + */ +fan_ctrl_policy_t fan_ctrl_policy_avg[] = { +{FAN_DUTY_CYCLE_MAX , 45000, INT_MIN}, +{63 , 40000, INT_MIN}, +{32 , INT_MAX, 35000}, +}; + +fan_ctrl_policy_t fan_ctrl_policy_single[] = { +{FAN_DUTY_CYCLE_MAX , 50000, INT_MIN}, +{63 , 45000, INT_MIN}, +}; + +struct fan_control_data_s { + int duty_cycle; + int dir_plus; + int mc_avg_pre[CELSIUS_RECORD_NUMBER]; + int mc_high_pre[CELSIUS_RECORD_NUMBER]; + +} fan_control_data_pre = +{ + .duty_cycle = FAN_DUTY_CYCLE_DEFAULT, + .dir_plus = 0, + .mc_avg_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + .mc_high_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + +}; + +static int +sysi_check_fan(uint32_t *fan_dir){ + int i, present; + + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + present = fan_info.status & ONLP_FAN_STATUS_PRESENT; + if ((fan_info.status & ONLP_FAN_STATUS_FAILED) || !present) { + AIM_LOG_WARN("Fan(%d) is not working, set the other fans as full speed\r\n", i); + int ret = onlp_fani_percentage_set( + ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY), FAN_DUTY_CYCLE_MAX); + if (ret != ONLP_STATUS_OK) + return ret; + else + return ONLP_STATUS_E_MISSING; + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + *fan_dir = fan_info.status & (ONLP_FAN_STATUS_F2B|ONLP_FAN_STATUS_B2F); + } + } + + return ONLP_STATUS_OK; +} + +static int +sysi_get_fan_duty(int *cur_duty_cycle){ + int fd, len; + char buf[10] = {0}; + char *node = FAN_NODE(fan_duty_cycle_percentage); + + /* Get current fan duty*/ + fd = open(node, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + *cur_duty_cycle = atoi(buf); + + return ONLP_STATUS_OK; +} + +static int +sysi_get_thermal_sum(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i; + + *mcelsius = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + *mcelsius += thermal_info.mcelsius; + + DEBUG_PRINT("Thermal %d: %d \n ", i, thermal_info.mcelsius); + + } + + return ONLP_STATUS_OK; + +} + +static int +sysi_get_highest_thermal(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i, highest; + + highest = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + highest = (thermal_info.mcelsius > highest)? + thermal_info.mcelsius : highest; + } + *mcelsius = highest; + return ONLP_STATUS_OK; +} + +/* Anaylze thermal changing history to judge if the change is a stable trend. */ +static int _is_thermal_a_trend(int *mc_history){ + int i, trend, trended; + + if (mc_history == NULL) { + AIM_LOG_ERROR("Unable to get history of thermal\n"); + return 0; + } + + /* Get heat up/down trend. */ + trend = 0; + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + if (( mc_history[i+1] < mc_history[i])){ + trend++; + }else if (( mc_history[i+1] > mc_history[i])){ + trend--; + } + } + + trended = (abs(trend) >= ((CELSIUS_RECORD_NUMBER+1)/2))? 1:0; +#if (DEBUG_MODE == 1) + DEBUG_PRINT("[INFO]%s#%d, trended: %d, UP/DW: %d mcelsius:", + __func__, __LINE__, trended, trend ); + for (i = 0; i <= CELSIUS_RECORD_NUMBER; i++) { + DEBUG_PRINT(" %d =>", mc_history[i]); + } + DEBUG_PRINT("%c\n", ' '); +#endif + + /*For more than half changes are same direction, it's a firm trend.*/ + return trended; +} + + +/* Decide duty by highest value of thermal sensors.*/ +static int +sysi_get_duty_by_highest(int *duty_cycle){ + int i, ret, maxtrix_len; + int new_duty_cycle = 0 ; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + ret = sysi_get_highest_thermal(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_high_pre, + sizeof(fan_control_data_pre.mc_high_pre)); + + DEBUG_PRINT("[INFO]%s#%d, highest mcelsius:%d!\n", + __func__, __LINE__, *mcelsius_now_p); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_high_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_single); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((*mcelsius_now_p > fan_ctrl_policy_single[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_single[i].duty_cycle; + matched = !matched; + break; + } + } +/* if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, *mcelsius_now_p); + } */ + } + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +/* Decide duty by average value of thermal sensors.*/ +static int +sysi_get_duty_by_average(int *duty_cycle){ + int i, mcelsius_avg, ret, maxtrix_len; + int new_duty_cycle=0; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + *mcelsius_now_p = 0; + ret = sysi_get_thermal_sum(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + mcelsius_avg = (*mcelsius_now_p)/CHASSIS_THERMAL_COUNT; + + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_avg_pre, + sizeof(fan_control_data_pre.mc_avg_pre)); + + DEBUG_PRINT("[INFO]%s#%d, mcelsius:%d!\n", __func__, __LINE__, mcelsius_avg); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_avg_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_avg); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((mcelsius_avg >= fan_ctrl_policy_avg[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + for (i = maxtrix_len-1; i>=0; i--) { + if ((mcelsius_avg < fan_ctrl_policy_avg[i].step_dn_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + /*if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, mcelsius_avg); + } */ + } + + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_fans(void) +{ + uint32_t fan_dir; + int ret; + int cur_duty_cycle, new_duty_cycle, tmp; + int direct_addon = 0; + onlp_oid_t fan_duty_oid = ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY); + + /********************************************************** + * Decision 1: Set fan as full speed if any fan is failed. + **********************************************************/ + ret = sysi_check_fan(&fan_dir); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + if (fan_dir & ONLP_FAN_STATUS_B2F) { + direct_addon = FAN_DUTY_PLUS_FOR_DIR; + } + + /********************************************************** + * Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + **********************************************************/ + ret = sysi_get_fan_duty(&cur_duty_cycle); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + /********************************************************** + * Decision 3: Decide new fan speed depend on fan direction and temperature + **********************************************************/ + ret = sysi_get_duty_by_average(&new_duty_cycle); + if (ONLP_STATUS_OK != ret){ + return ret; + } + ret = sysi_get_duty_by_highest(&tmp); + if (ONLP_STATUS_OK != ret){ + return ret; + } + + new_duty_cycle = (tmp > new_duty_cycle)? tmp : new_duty_cycle; + if (new_duty_cycle == 0) + { + new_duty_cycle = fan_control_data_pre.duty_cycle; + } else { + fan_control_data_pre.duty_cycle = new_duty_cycle; + } + fan_control_data_pre.dir_plus = direct_addon; + DEBUG_PRINT("[INFO]%s#%d, new duty: %d = %d + %d (%d)!\n", __func__, __LINE__, + new_duty_cycle + direct_addon, new_duty_cycle, direct_addon, cur_duty_cycle); + + new_duty_cycle += direct_addon; + new_duty_cycle = (new_duty_cycle > FAN_DUTY_CYCLE_MAX)? + FAN_DUTY_CYCLE_MAX : new_duty_cycle; + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(fan_duty_oid, new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c new file mode 100755 index 00000000..c3c548cd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,174 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +//#include +#include +#include +#include "platform_lib.h" + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*temp1_input" +#define PSU_THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*psu_temp1_input" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "55-0048", + "55-0049", + "55-004a", + "55-004b", + "54-004c", + "50-005b", + "49-0058", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "LM75-4-4B", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "LM75-5-4C", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char *format = NULL; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + if(tid == THERMAL_CPU_CORE) { + return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + } + + switch (tid) { + case THERMAL_1_ON_MAIN_BROAD: + case THERMAL_2_ON_MAIN_BROAD: + case THERMAL_3_ON_MAIN_BROAD: + case THERMAL_4_ON_MAIN_BROAD: + case THERMAL_5_ON_MAIN_BROAD: + format = THERMAL_PATH_FORMAT; + break; + case THERMAL_1_ON_PSU1: + case THERMAL_1_ON_PSU2: + format = PSU_THERMAL_PATH_FORMAT; + break; + default: + return ONLP_STATUS_E_INVALID; + }; + + /* get path */ + sprintf(path, format, directory[tid], tid); + if (onlp_file_read_int(&info->mcelsius, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c new file mode 100755 index 00000000..5f01b6d9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(_x) +x86_64_accton_as7726_32x_config_settings_t x86_64_accton_as7726_32x_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE +#undef __x86_64_accton_as7726_32x_config_STRINGIFY_NAME + +const char* +x86_64_accton_as7726_32x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as7726_32x_config_settings[i].name; i++) { + if(!strcmp(x86_64_accton_as7726_32x_config_settings[i].name, setting)) { + return x86_64_accton_as7726_32x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as7726_32x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as7726_32x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as7726_32x_config_settings[i].name, x86_64_accton_as7726_32x_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c new file mode 100755 index 00000000..3230f78d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h new file mode 100755 index 00000000..a4568088 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as7726_32x Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7726_32x_INT_H__ +#define __x86_64_accton_as7726_32x_INT_H__ + +#include + + +#endif /* __x86_64_accton_as7726_32x_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c new file mode 100755 index 00000000..c2eb34e4 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c @@ -0,0 +1,17 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7726_32x_log.h" +/* + * x86_64_accton_as7726_32x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h new file mode 100755 index 00000000..ae099f84 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as7726_32x_LOG_H__ +#define __x86_64_accton_as7726_32x_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as7726_32x +#include + +#endif /* __x86_64_accton_as7726_32x_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c new file mode 100755 index 00000000..3b434422 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7726_32x_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as7726_32x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as7726_32x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c new file mode 100755 index 00000000..3786e3e6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as7726_32x_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as7726_32x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7726_32x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as7726_32x_ucli_module__ = + { + "x86_64_accton_as7726_32x_ucli", + NULL, + x86_64_accton_as7726_32x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as7726_32x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as7726_32x_ucli_module__); + n = ucli_node_create("x86_64_accton_as7726_32x", NULL, &x86_64_accton_as7726_32x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7726_32x")); + return n; +} + +#else +void* +x86_64_accton_as7726_32x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/PKG.yml new file mode 100755 index 00000000..a3c9a1b3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as7726-32x REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/lib/x86-64-accton-as7726-32x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/lib/x86-64-accton-as7726-32x-r0.yml new file mode 100755 index 00000000..6637e549 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/lib/x86-64-accton-as7726-32x-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for AS7726 +# +###################################################################### + +x86-64-accton-as7726-32x-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/python/x86_64_accton_as7726_32x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/python/x86_64_accton_as7726_32x_r0/__init__.py new file mode 100755 index 00000000..6e62efda --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/platform-config/r0/src/python/x86_64_accton_as7726_32x_r0/__init__.py @@ -0,0 +1,104 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as7726_32x_r0(OnlPlatformAccton, + OnlPlatformPortConfig_48x25_6x100): + + PLATFORM='x86-64-accton-as7726-32x-r0' + MODEL="AS7726-32X" + SYS_OBJECT_ID=".7726.32" + + def baseconfig(self): + #self.insmod('optoe') + #self.insmod('ym2651y') + #for m in [ 'cpld', 'fan', 'psu', 'leds' ]: + # self.insmod("x86-64-accton-as7726-32x-%s.ko" % m) + + ########### initialize I2C bus 0 ########### + # initialize multiplexer (PCA9548) + self.new_i2c_device('pca9548', 0x77, 0) + # initiate multiplexer (PCA9548) + self.new_i2c_devices( + [ + # initiate multiplexer (PCA9548) + ('pca9548', 0x76, 1), + ('pca9548', 0x72, 1), + ('pca9548', 0x73, 1), + ('pca9548', 0x74, 1), + ('pca9548', 0x75, 1), + ('pca9548', 0x71, 2) + ] + ) + + self.new_i2c_devices([ + # initialize CPLD + ('as7726_32x_cpld1', 0x60, 11), + ('as7726_32x_cpld2', 0x62, 12), + ('as7726_32x_cpld3', 0x64, 13), + ]) + self.new_i2c_devices([ + # initiate fan + ('as7726_32x_fan', 0x66, 54), + ('lm75', 0x4c, 54), + + # inititate LM75 + ('lm75', 0x48, 55), + ('lm75', 0x49, 55), + ('lm75', 0x4a, 55), + ('lm75', 0x4b, 55), + ]) + + self.new_i2c_devices([ + # initiate PSU-1 + ('as7726_32x_psu1', 0x53, 50), + ('ym2651', 0x5B, 50), + + # initiate PSU-2 + ('as7726_32x_psu2', 0x50, 49), + ('ym2651', 0x58, 49), + ]) + + # initialize QSFP port 1~8 + for port in range(1, 5): + self.new_i2c_device('optoe1', 0x50, port+20) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+20), shell=True) + + self.new_i2c_device('optoe1', 0x50, 26) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (5, 26), shell=True) + self.new_i2c_device('optoe1', 0x50, 25) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (6, 25), shell=True) + self.new_i2c_device('optoe1', 0x50, 28) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (7, 28), shell=True) + self.new_i2c_device('optoe1', 0x50, 27) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (8, 27), shell=True) + + # initialize QSFP port 9~16 + for port in range(9, 13): + self.new_i2c_device('optoe1', 0x50, port+8) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+8), shell=True) + for port in range(13, 17): + self.new_i2c_device('optoe1', 0x50, port+16) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+16), shell=True) + + # initialize QSFP port 17~24 + for port in range(17, 21): + self.new_i2c_device('optoe1', 0x50, port+16) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+16), shell=True) + for port in range(21, 25): + self.new_i2c_device('optoe1', 0x50, port+24) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+24), shell=True) + + # initialize QSFP port 25~32 + for port in range(25, 33): + self.new_i2c_device('optoe1', 0x50, port+12) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+12), shell=True) + + # initialize SFP port 33~34 + for port in range(33, 35): + self.new_i2c_device('optoe1', 0x50, port-18) + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port-18), shell=True) + + + + self.new_i2c_device('24c02', 0x56, 0) + return True From d0473f4a153db2d780ca2c30f551f3ea89c4bfc3 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Mon, 16 Apr 2018 16:17:09 +0800 Subject: [PATCH 224/244] Update ledi.c --- .../x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c index 85856aa3..94926527 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c @@ -110,7 +110,7 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_LOC), "LED 2 (LOC LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE, }, { { ONLP_LED_ID_CREATE(LED_FAN), "LED 3 (FAN LED)", 0 }, From ad81a5d8725b195128e3f91fe5e5a11f311d5915 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Tue, 17 Apr 2018 16:46:43 +0800 Subject: [PATCH 225/244] [onlpdump] ledi.c: correct LOC led to be amber colored. support onlp_ledi_mode_set for turning on. Signed-off-by: roy_lee --- .../onlp/builds/src/module/src/ledi.c | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c index a4d1cbc2..9357e422 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c @@ -80,7 +80,7 @@ led_light_mode_map_t led_map[] = { {LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, {LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, {LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_LOC, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, {LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, {LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, {LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} @@ -159,15 +159,27 @@ static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led return 0; } +/* Get the highest bit position of input value.*/ +static int _log2(int val) { + int bits = sizeof(val)*8 - 1; + int i, t; + + for (i = bits; i>=0; i--) { + t = (val >> i); + if ( t & 1) + return i; + } + return i; +} + /* * This function will be called prior to any other onlp_ledi_* functions. */ int onlp_ledi_init(void) { - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); - + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); return ONLP_STATUS_OK; } @@ -220,9 +232,19 @@ onlp_ledi_set(onlp_oid_t id, int on_or_off) if (!on_or_off) { return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - } + } else { + int rv; - return ONLP_STATUS_E_UNSUPPORTED; + onlp_led_mode_t mode = ONLP_LED_MODE_OFF; + onlp_led_info_t led_info; + rv = onlp_ledi_info_get(id, &led_info); + if (rv < 0) + return rv; + + /*If multiple color is supported, take the mode at highest bit.*/ + mode = _log2(led_info.caps); + return onlp_ledi_mode_set(id, mode); + } } /* From 64d353a1ee1b3642fa9b8e072f567b7ae980ffe5 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Tue, 17 Apr 2018 17:13:00 +0800 Subject: [PATCH 226/244] [platform] correct SYS_OBJECT_ID and replace local file write API to one in onlplib. Signed-off-by: roy_lee --- .../onlp/builds/src/module/src/platform_lib.c | 31 +------------------ .../x86_64_accton_as7326_56x_r0/__init__.py | 2 +- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c index 2758d9b3..c3e61500 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c @@ -5,41 +5,12 @@ #include "x86_64_accton_as7326_56x_log.h" -static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) -{ - int fd; - int len; - - if ((buffer == NULL) || (buf_size < 0)) { - return -1; - } - - if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { - return -1; - } - - if ((len = write(fd, buffer, buf_size)) < 0) { - close(fd); - return -1; - } - - if ((close(fd) == -1)) { - return -1; - } - - if ((len > buf_size) || (data_len != 0 && len != data_len)) { - return -1; - } - - return 0; -} - int onlp_file_write_integer(char *filename, int value) { char buf[8] = {0}; sprintf(buf, "%d", value); - return _onlp_file_write(filename, buf, (int)strlen(buf), 0); + return onlp_file_write((uint8_t*)buf, strlen(buf), filename); } int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py index 24e9a914..3f34ef71 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py @@ -6,7 +6,7 @@ class OnlPlatform_x86_64_accton_as7326_56x_r0(OnlPlatformAccton, PLATFORM='x86-64-accton-as7326-56x-r0' MODEL="AS7326-56X" - SYS_OBJECT_ID=".7326.54" + SYS_OBJECT_ID=".7326.56" def baseconfig(self): self.insmod('optoe') From 1d6448567122a53530f8cc588f34787db11c707e Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Tue, 17 Apr 2018 22:29:59 -0700 Subject: [PATCH 227/244] Retry fan speed read when we see zero RPM, to make sure it's not a glitch --- .../builds/x86-64-accton-as6812-32x-fan.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c index f0555674..43d3fe32 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c @@ -32,6 +32,7 @@ #include #include #include +#include #define FAN_MAX_NUMBER 5 #define FAN_SPEED_CPLD_TO_RPM_STEP 150 @@ -268,7 +269,7 @@ static int accton_as6812_32x_fan_write_value(u8 reg, u8 value) static void accton_as6812_32x_fan_update_device(struct device *dev) { int speed, r_speed, fault, r_fault, direction, ctrl_speed; - int i; + int i, retry_count; mutex_lock(&fan_data->update_lock); @@ -298,6 +299,7 @@ static void accton_as6812_32x_fan_update_device(struct device *dev) for (i = 0; i < FAN_MAX_NUMBER; i++) { + retry_count = 5; /* Update fan data */ @@ -314,12 +316,21 @@ static void accton_as6812_32x_fan_update_device(struct device *dev) /* fan speed */ - speed = accton_as6812_32x_fan_read_value(fan_speed_reg[i]); - r_speed = accton_as6812_32x_fan_read_value(fanr_speed_reg[i]); - if ( (speed < 0) || (r_speed < 0) ) - { - DEBUG_PRINT("[Error!!][%s][%d] \n", __FUNCTION__, __LINE__); - goto _exit; /* error */ + while (retry_count) { + retry_count--; + speed = accton_as6812_32x_fan_read_value(fan_speed_reg[i]); + r_speed = accton_as6812_32x_fan_read_value(fanr_speed_reg[i]); + if ( (speed < 0) || (r_speed < 0) ) + { + DEBUG_PRINT("[Error!!][%s][%d] \n", __FUNCTION__, __LINE__); + goto _exit; /* error */ + } + if ( (speed == 0) || (r_speed == 0) ) + { + msleep(200); + continue; + } + break; } DEBUG_PRINT("[fan%d:] speed:%d, r_speed=%d \n", i, speed, r_speed); From 90a3efca982a4328ad9a43b36ddde0ebed7095d8 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 15:02:47 +0000 Subject: [PATCH 228/244] The x86_64_as7726_32x module was not generated using the newmodule script. A new module will be generated and the appropriate code moved into it. --- .../onlp/builds/src/.gitignore | 1 - .../onlp/builds/src/.module | 1 - .../onlp/builds/src/Makefile | 9 - .../onlp/builds/src/README | 6 - .../module/auto/x86_64_accton_as7726_32x.yml | 50 -- .../x86_64_accton_as7726_32x.x | 14 - .../x86_64_accton_as7726_32x_config.h | 137 ----- .../x86_64_accton_as7726_32x_dox.h | 26 - .../x86_64_accton_as7726_32x_porting.h | 107 ---- .../onlp/builds/src/module/src/Makefile | 9 - .../onlp/builds/src/module/src/debug.c | 45 -- .../onlp/builds/src/module/src/fani.c | 367 ------------- .../onlp/builds/src/module/src/ledi.c | 261 ---------- .../onlp/builds/src/module/src/platform_lib.c | 202 -------- .../onlp/builds/src/module/src/platform_lib.h | 87 ---- .../onlp/builds/src/module/src/psui.c | 185 ------- .../onlp/builds/src/module/src/sfpi.c | 422 --------------- .../onlp/builds/src/module/src/sysi.c | 490 ------------------ .../onlp/builds/src/module/src/thermali.c | 174 ------- .../src/x86_64_accton_as7726_32x_config.c | 81 --- .../src/x86_64_accton_as7726_32x_enums.c | 10 - .../module/src/x86_64_accton_as7726_32x_int.h | 12 - .../module/src/x86_64_accton_as7726_32x_log.c | 17 - .../module/src/x86_64_accton_as7726_32x_log.h | 12 - .../src/x86_64_accton_as7726_32x_module.c | 24 - .../src/x86_64_accton_as7726_32x_ucli.c | 50 -- 26 files changed, 2799 deletions(-) delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c delete mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore deleted file mode 100755 index c81d16be..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module deleted file mode 100755 index 28f927de..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_accton_as7726_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile deleted file mode 100755 index 9dfffde1..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_accton_as7726_32x -AUTOMODULE := x86_64_accton_as77262_32x -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README deleted file mode 100755 index 5aad1403..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# x86_64_accton_as7726_32x README -# -############################################################################### - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml deleted file mode 100755 index d53b22b2..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/auto/x86_64_accton_as7726_32x.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_accton_as7726_32x Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: x86_64_accton_as7726_32x_CONFIG_PORTING_STDLIB -- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: - doc: "Assume chassis fan direction is the same as the PSU fan direction." - default: 0 - - -definitions: - cdefs: - x86_64_accton_as7726_32x_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_accton_as7726_32x_config - - portingmacro: - x86_64_accton_as7726_32x: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x deleted file mode 100755 index b0e04177..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h deleted file mode 100755 index 72cb2aa4..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_accton_as7726_32x Configuration Header - * - * @addtogroup x86_64_accton_as7726_32x-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_accton_as7726_32x_CONFIG_H__ -#define __x86_64_accton_as7726_32x_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_accton_as7726_32x_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING -#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT -#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB -#define X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7726_32x_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI -#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_accton_as7726_32x_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_accton_as7726_32x_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_accton_as7726_32x_config_settings table. */ -extern x86_64_accton_as7726_32x_config_settings_t x86_64_accton_as7726_32x_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_accton_as7726_32x_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_accton_as7726_32x_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_accton_as7726_32x_porting.h" - -#endif /* __x86_64_accton_as7726_32x_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h deleted file mode 100755 index d92d6638..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_accton_as7726_32x Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_accton_as7726_32x_DOX_H__ -#define __x86_64_accton_as7726_32x_DOX_H__ - -/** - * @defgroup x86_64_accton_as7726_32x x86_64_accton_as7726_32x - x86_64_accton_as7726_32x Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_accton_as7726_32x-x86_64_accton_as7726_32x Public Interface - * @defgroup x86_64_accton_as7726_32x-config Compile Time Configuration - * @defgroup x86_64_accton_as7726_32x-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_accton_as7726_32x_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h deleted file mode 100755 index 8893de7f..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_accton_as7726_32x Porting Macros. - * - * @addtogroup x86_64_accton_as7726_32x-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_accton_as7726_32x_PORTING_H__ -#define __x86_64_accton_as7726_32x_PORTING_H__ - - -/* */ -#if X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_ACCTON_AS7726_32X_MALLOC GLOBAL_MALLOC - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_MALLOC malloc - #else - #error The macro X86_64_ACCTON_AS7726_32X_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_FREE - #if defined(GLOBAL_FREE) - #define X86_64_ACCTON_AS7726_32X_FREE GLOBAL_FREE - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_FREE free - #else - #error The macro X86_64_ACCTON_AS7726_32X_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_ACCTON_AS7726_32X_MEMSET GLOBAL_MEMSET - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_MEMSET memset - #else - #error The macro X86_64_ACCTON_AS7726_32X_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_ACCTON_AS7726_32X_MEMCPY GLOBAL_MEMCPY - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_MEMCPY memcpy - #else - #error The macro X86_64_ACCTON_AS7726_32X_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define X86_64_ACCTON_AS7726_32X_STRNCPY GLOBAL_STRNCPY - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_STRNCPY strncpy - #else - #error The macro X86_64_ACCTON_AS7726_32X_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_ACCTON_AS7726_32X_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_VSNPRINTF vsnprintf - #else - #error The macro X86_64_ACCTON_AS7726_32X_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_ACCTON_AS7726_32X_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_SNPRINTF snprintf - #else - #error The macro X86_64_ACCTON_AS7726_32X_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_ACCTON_AS7726_32X_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_ACCTON_AS7726_32X_STRLEN GLOBAL_STRLEN - #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_ACCTON_AS7726_32X_STRLEN strlen - #else - #error The macro X86_64_ACCTON_AS7726_32X_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_accton_as7726_32x_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile deleted file mode 100755 index b1a02144..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_accton_as7726_32x_ucli.c - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c deleted file mode 100755 index 92890fb7..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_accton_as7726_32x_int.h" - -#if x86_64_accton_as7726_32x_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_accton_as7726_32x_debug_main(int argc, char* argv[]) -{ - int c = 0; - int help = 0; - int rv = 0; - - while( (c = getopt(argc, argv, "ch")) != -1) { - switch(c) - { - case 'c': c = 1; break; - case 'h': help = 1; rv = 0; break; - default: help = 1; rv = 1; break; - } - - } - - if(help || argc == 1) { - printf("%s", help__); - return rv; - } - - if(c) { - printf("Not implemented.\n"); - } - - - return 0; -} - -#endif - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c deleted file mode 100755 index e82f8a77..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/fani.c +++ /dev/null @@ -1,367 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2014 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include "platform_lib.h" - -#define PSU_PREFIX_PATH "/sys/bus/i2c/devices/" - -#define MAX_FAN_SPEED 25500 -#define MAX_PSU_FAN_SPEED 25500 - -enum fan_id { - FAN_1_ON_FAN_BOARD = 1, - FAN_2_ON_FAN_BOARD, - FAN_3_ON_FAN_BOARD, - FAN_4_ON_FAN_BOARD, - FAN_5_ON_FAN_BOARD, - FAN_6_ON_FAN_BOARD, - FAN_1_ON_PSU_1, - FAN_1_ON_PSU_2, -}; - -#define CHASSIS_FAN_INFO(fid) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ - 0x0,\ - ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ - 0,\ - 0,\ - ONLP_FAN_MODE_INVALID,\ - } - -#define PSU_FAN_INFO(pid, fid) \ - { \ - { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ - 0x0,\ - ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ - 0,\ - 0,\ - ONLP_FAN_MODE_INVALID,\ - } - -/* Static fan information */ -onlp_fan_info_t finfo[] = { - { }, /* Not used */ - CHASSIS_FAN_INFO(1), - CHASSIS_FAN_INFO(2), - CHASSIS_FAN_INFO(3), - CHASSIS_FAN_INFO(4), - CHASSIS_FAN_INFO(5), - CHASSIS_FAN_INFO(6), - PSU_FAN_INFO(1,1), - PSU_FAN_INFO(2,1) -}; - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) -{ - int value; - char path[64] = {0}; - - /* get fan present status - */ - sprintf(path, "%s""fan%d_present", FAN_BOARD_PATH, fid); - DEBUG_PRINT("Fan(%d), present path = (%s)", fid, path); - - if (onlp_file_read_int(&value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - if (value == 0) { - return ONLP_STATUS_OK; - } - info->status |= ONLP_FAN_STATUS_PRESENT; - - - /* get fan fault status (turn on when any one fails) - */ - sprintf(path, "%s""fan%d_fault", FAN_BOARD_PATH, fid); - DEBUG_PRINT("Fan(%d), fault path = (%s)", fid, path); - - if (onlp_file_read_int(&value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - if (value > 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - - /* get fan direction (both : the same) - */ - sprintf(path, "%s""fan%d_direction", FAN_BOARD_PATH, fid); - DEBUG_PRINT("Fan(%d), direction path = (%s)", fid, path); - - if (onlp_file_read_int(&value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; - - - /* get front fan speed - */ - sprintf(path, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); - DEBUG_PRINT("Fan (%d), front speed path = (%s)", fid, path); - - if (onlp_file_read_int(&value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - - /* get rear fan speed - */ - sprintf(path, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); - DEBUG_PRINT("Fan (%d), rear speed path = (%s)", fid, path); - - if (onlp_file_read_int(&value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - /* take the min value from front/rear fan speed - */ - if (info->rpm > value) { - info->rpm = value; - } - - /* get speed percentage from rpm - */ - info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; - - return ONLP_STATUS_OK; -} - -static uint32_t -_onlp_get_fan_direction_on_psu(void) -{ - /* Try to read direction from PSU1. - * If PSU1 is not valid, read from PSU2 - */ - int i = 0; - - for (i = PSU1_ID; i <= PSU2_ID; i++) { - psu_type_t psu_type; - psu_type = get_psu_type(i, NULL, 0); - - if (psu_type == PSU_TYPE_UNKNOWN) { - continue; - } - - if (PSU_TYPE_AC_F2B == psu_type) { - return ONLP_FAN_STATUS_F2B; - } - else { - return ONLP_FAN_STATUS_B2F; - } - } - - return 0; -} - -static int -_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) -{ - int val = 0; - - info->status |= ONLP_FAN_STATUS_PRESENT; - - /* get fan direction - */ - info->status |= _onlp_get_fan_direction_on_psu(); - - /* get fan fault status - */ - if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { - info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; - } - - /* get fan speed - */ - if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { - info->rpm = val; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - } - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) -{ - int rc = 0; - int fid; - VALIDATE(id); - - fid = ONLP_OID_ID_GET(id); - *info = finfo[fid]; - - switch (fid) - { - case FAN_1_ON_PSU_1: - rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); - break; - case FAN_1_ON_PSU_2: - rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); - break; - case FAN_1_ON_FAN_BOARD: - case FAN_2_ON_FAN_BOARD: - case FAN_3_ON_FAN_BOARD: - case FAN_4_ON_FAN_BOARD: - case FAN_5_ON_FAN_BOARD: - case FAN_6_ON_FAN_BOARD: - rc =_onlp_fani_info_get_fan(fid, info); - break; - default: - rc = ONLP_STATUS_E_INVALID; - break; - } - - return rc; -} - -/* - * This function sets the speed of the given fan in RPM. - * - * This function will only be called if the fan supprots the RPM_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan speed of the given OID as a percentage. - * - * This will only be called if the OID has the PERCENTAGE_SET - * capability. - * - * It is optional if you have no fans at all with this feature. - */ -int -onlp_fani_percentage_set(onlp_oid_t id, int p) -{ - int fid; - char *path = NULL; - - VALIDATE(id); - - fid = ONLP_OID_ID_GET(id); - - /* reject p=0 (p=0, stop fan) */ - if (p == 0){ - return ONLP_STATUS_E_INVALID; - } - - switch (fid) - { - case FAN_1_ON_PSU_1: - return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan_duty_cycle_percentage", p); - case FAN_1_ON_PSU_2: - return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan_duty_cycle_percentage", p); - case FAN_1_ON_FAN_BOARD: - case FAN_2_ON_FAN_BOARD: - case FAN_3_ON_FAN_BOARD: - case FAN_4_ON_FAN_BOARD: - case FAN_5_ON_FAN_BOARD: - case FAN_6_ON_FAN_BOARD: - path = FAN_NODE(fan_duty_cycle_percentage); - break; - default: - return ONLP_STATUS_E_INVALID; - } - - DEBUG_PRINT("Fan path = (%s)", path); - - if (onlp_file_write_integer(path, p) < 0) { - AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - - -/* - * This function sets the fan speed of the given OID as per - * the predefined ONLP fan speed modes: off, slow, normal, fast, max. - * - * Interpretation of these modes is up to the platform. - * - */ -int -onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function sets the fan direction of the given OID. - * - * This function is only relevant if the fan OID supports both direction - * capabilities. - * - * This function is optional unless the functionality is available. - */ -int -onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c deleted file mode 100755 index 94926527..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/ledi.c +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2014 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -#define prefix_path "/sys/class/leds/accton_as7726_32x_led::" -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_DIAG, - LED_LOC, - LED_FAN, - LED_PSU1, - LED_PSU2 -}; - -enum led_light_mode { - LED_MODE_OFF = 0, - LED_MODE_GREEN, - LED_MODE_AMBER, - LED_MODE_RED, - LED_MODE_BLUE, - LED_MODE_GREEN_BLINK, - LED_MODE_AMBER_BLINK, - LED_MODE_RED_BLINK, - LED_MODE_BLUE_BLINK, - LED_MODE_AUTO, - LED_MODE_UNKNOWN -}; - -typedef struct led_light_mode_map { - enum onlp_led_id id; - enum led_light_mode driver_led_mode; - enum onlp_led_mode_e onlp_led_mode; -} led_light_mode_map_t; - -led_light_mode_map_t led_map[] = { -{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, -{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, -{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, -{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, -{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, -{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} -}; - -static char last_path[][10] = /* must map with onlp_led_id */ -{ - "reserved", - "diag", - "loc", - "fan", - "psu1", - "psu2" -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_DIAG), "LED 1 (DIAG LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, - }, - { - { ONLP_LED_ID_CREATE(LED_LOC), "LED 2 (LOC LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE, - }, - { - { ONLP_LED_ID_CREATE(LED_FAN), "LED 3 (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_PSU1), "LED 4 (PSU1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_PSU2), "LED 4 (PSU2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_AUTO, - }, -}; - -static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) -{ - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - for (i = 0; i < nsize; i++) - { - if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) - { - return led_map[i].onlp_led_mode; - } - } - - return 0; -} - -static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) -{ - int i, nsize = sizeof(led_map)/sizeof(led_map[0]); - - for(i = 0; i < nsize; i++) - { - if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) - { - return led_map[i].driver_led_mode; - } - } - - return 0; -} - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -int -onlp_ledi_init(void) -{ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - char data[2] = {0}; - char fullpath[50] = {0}; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* get fullpath */ - sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - /* Set LED mode */ - if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - return ONLP_STATUS_E_INTERNAL; - } - - info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } - - return ONLP_STATUS_OK; -} - -/* - * Turn an LED on or off. - * - * This function will only be called if the LED OID supports the ONOFF - * capability. - * - * What 'on' means in terms of colors or modes for multimode LEDs is - * up to the platform to decide. This is intended as baseline toggle mechanism. - */ -int -onlp_ledi_set(onlp_oid_t id, int on_or_off) -{ - VALIDATE(id); - - if (!on_or_off) { - return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - } - - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * This function puts the LED into the given mode. It is a more functional - * interface for multimode LEDs. - * - * Only modes reported in the LED's capabilities will be attempted. - */ -int -onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) -{ - int local_id; - char fullpath[50] = {0}; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); - - if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) - { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * Generic LED ioctl interface. - */ -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c deleted file mode 100755 index fc7a5f2c..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.c +++ /dev/null @@ -1,202 +0,0 @@ -#include -#include -#include -#include -#include "platform_lib.h" -#include -#include "x86_64_accton_as7726_32x_log.h" - - -static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) -{ - int fd; - int len; - - if ((buffer == NULL) || (buf_size < 0)) { - return -1; - } - - if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { - return -1; - } - - if ((len = write(fd, buffer, buf_size)) < 0) { - close(fd); - return -1; - } - - if ((close(fd) == -1)) { - return -1; - } - - if ((len > buf_size) || (data_len != 0 && len != data_len)) { - return -1; - } - - return 0; -} - -int onlp_file_write_integer(char *filename, int value) -{ - char buf[8] = {0}; - sprintf(buf, "%d", value); - - return _onlp_file_write(filename, buf, (int)strlen(buf), 0); -} - -int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) -{ - int fd; - int len; - - if ((buffer == NULL) || (buf_size < 0)) { - return -1; - } - - if ((fd = open(filename, O_RDONLY)) == -1) { - return -1; - } - - if ((len = read(fd, buffer, buf_size)) < 0) { - close(fd); - return -1; - } - - if ((close(fd) == -1)) { - return -1; - } - - if ((len > buf_size) || (data_len != 0 && len != data_len)) { - return -1; - } - - return 0; -} - -int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) -{ - int ret; - - if (data_len >= buf_size) { - return -1; - } - - ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); - - if (ret == 0) { - buffer[buf_size-1] = '\0'; - } - - return ret; -} - -#define I2C_PSU_MODEL_NAME_LEN 9 -#define I2C_PSU_FAN_DIR_LEN 3 - -psu_type_t get_psu_type(int id, char* modelname, int modelname_len) -{ - char *node = NULL; - char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; - char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; - - - /* Check AC model name */ - node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model); - if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { - return PSU_TYPE_UNKNOWN; - } - - if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) { - return PSU_TYPE_UNKNOWN; - } - - if (modelname) { - strncpy(modelname, model_name, modelname_len-1); - } - - node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); - - if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { - return PSU_TYPE_UNKNOWN; - } - - if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { - return PSU_TYPE_AC_F2B; - } - - if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { - return PSU_TYPE_AC_B2F; - } - - return PSU_TYPE_UNKNOWN; -} - -int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) -{ - int ret = 0; - char path[PSU_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - - if (PSU1_ID == id) { - sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); - } - else { - sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); - } - - if (onlp_file_read_int(value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - return ret; -} - -int psu_ym2651y_pmbus_info_set(int id, char *node, int value) -{ - char path[PSU_NODE_MAX_PATH_LEN] = {0}; - - switch (id) { - case PSU1_ID: - sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); - break; - case PSU2_ID: - sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - }; - - if (onlp_file_write_integer(path, value) < 0) { - AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -#define PSU_SERIAL_NUMBER_LEN 18 - -int psu_serial_number_get(int id, char *serial, int serial_len) -{ - int size = 0; - int ret = ONLP_STATUS_OK; - char *prefix = NULL; - - if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { - return ONLP_STATUS_E_PARAM; - } - - prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; - - ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); - if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { - return ONLP_STATUS_E_INTERNAL; - - } - - serial[PSU_SERIAL_NUMBER_LEN] = '\0'; - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h deleted file mode 100755 index 96c817bb..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/platform_lib.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2014 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include -#include "x86_64_accton_as7726_32x_log.h" - -#define CHASSIS_FAN_COUNT 6 -#define CHASSIS_THERMAL_COUNT 6 -#define CHASSIS_PSU_COUNT 2 -#define CHASSIS_LED_COUNT 5 - -#define PSU1_ID 1 -#define PSU2_ID 2 - -#define PSU_NODE_MAX_INT_LEN 8 -#define PSU_NODE_MAX_PATH_LEN 64 - -#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/50-005b/" -#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/49-0058/" - -#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node -#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node - -#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/50-0053/" -#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/49-0050/" - - -#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -#define FAN_BOARD_PATH "/sys/bus/i2c/devices/54-0066/" -#define FAN_NODE(node) FAN_BOARD_PATH#node - -#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom" - -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); - - -int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); -int psu_ym2651y_pmbus_info_set(int id, char *node, int value); - -typedef enum psu_type { - PSU_TYPE_UNKNOWN, - PSU_TYPE_AC_F2B, - PSU_TYPE_AC_B2F -} psu_type_t; - -psu_type_t get_psu_type(int id, char* modelname, int modelname_len); -int psu_serial_number_get(int id, char *serial, int serial_len); - -//#define DEBUG_MODE 1 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) -#else - #define DEBUG_PRINT(format, ...) -#endif - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c deleted file mode 100755 index 5185a145..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/psui.c +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2014 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -//#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 - - - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char path[PSU_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - - - if (PSU1_ID == id) { - sprintf(path, "%s%s", PSU1_AC_HWMON_PREFIX, node); - } - else if (PSU2_ID == id) { - sprintf(path, "%s%s", PSU2_AC_HWMON_PREFIX, node); - } - if (onlp_file_read_int(value, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - return ret; -} - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -psu_ym2651y_info_get(onlp_psu_info_t* info) -{ - int val = 0; - int index = ONLP_OID_ID_GET(info->hdr.id); - - /* Set capability - */ - info->caps = ONLP_PSU_CAPS_AC; - - if (info->status & ONLP_PSU_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - /* Set the associated oid_table */ - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); - - /* Read voltage, current and power */ - if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { - info->mvout = val; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { - info->miout = val; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { - info->mpout = val; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - psu_serial_number_get(index, info->serial, sizeof(info->serial)); - - return ONLP_STATUS_OK; -} - -/* - * Get all information about the given PSU oid. - */ -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, - }, - { - { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, - } -}; - -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); - psu_type_t psu_type; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - /* Get the present state */ - if (psu_status_info_get(index, "psu_present", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index); - } - if (val != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - - /* Get power good status */ - if (psu_status_info_get(index, "psu_power_good", &val) != 0) { - AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_power_good)\r\n", index); - } - - if (val != PSU_STATUS_POWER_GOOD) { - info->status |= ONLP_PSU_STATUS_FAILED; - } - - - /* Get PSU type - */ - psu_type = get_psu_type(index, info->model, sizeof(info->model)); - switch (psu_type) { - case PSU_TYPE_AC_F2B: - case PSU_TYPE_AC_B2F: - ret = psu_ym2651y_info_get(info); - break; - case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - info->status &= ~ONLP_PSU_STATUS_FAILED; - ret = ONLP_STATUS_OK; - break; - default: - ret = ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return ret; -} - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c deleted file mode 100755 index f9d671b0..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sfpi.c +++ /dev/null @@ -1,422 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2013 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "x86_64_accton_as7726_32x_int.h" -#include "x86_64_accton_as7726_32x_log.h" - -#define PORT_BUS_INDEX(port) (port+18) - -#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" -#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" -#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" -#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" -#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" -#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" -#define MODULE_RXLOS_ALL_ATTR_CPLD "/sys/bus/i2c/devices/11-0060/module_rx_los_all" -#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/6-0064/module_rx_los_all" - - -int sfp_map_bus[] ={21, 22, 23, 24, 26, 25, 28, 27, - 17, 18, 19, 20, 29, 30, 31, 32, - 33, 34, 35, 36, 45, 46, 47, 48, - 37, 38, 39, 40, 41, 42, 43, 44, - 15, 16}; - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ - -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} -int -onlp_sfpi_map_bus_index(int port) -{ - if(port < 0 || port >=34) - return ONLP_STATUS_E_INTERNAL; - return sfp_map_bus[port]; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {0, 34} - */ - int p; - - for(p = 0; p < 34; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - /* - * Return 1 if present. - * Return 0 if not present. - * Return < 0 if error. - */ - int present; - int bus, addr; - - if(port <0 || port > 34) - return ONLP_STATUS_E_INTERNAL; - - addr = 60; - bus = 11; - - if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t bytes[5], *ptr = NULL; - FILE* fp; - int addr=60; - int bus=11; - char file[64] = {0}; - int count; - - ptr = bytes; - sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); - fp = fopen(file, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); - return ONLP_STATUS_E_INTERNAL; - } - - count = fscanf(fp, "%x %x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3, ptr+4); - fclose(fp); - if(count != 5) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); - return ONLP_STATUS_E_INTERNAL; - } - - /* Convert to 64 bit integer in port order */ - uint64_t presence_all = 0 ; - int i = 0; - for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { - presence_all <<= 8; - presence_all |= bytes[i]; - } - - /* Populate bitmap */ - for(i = 0; presence_all; i++) { - AIM_BITMAP_MOD(dst, i, (presence_all & 1)); - presence_all >>= 1; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t bytes[5]; - uint32_t *ptr = bytes; - FILE* fp; - - int addr=60, i = 0; - - fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - int count = fscanf(fp, "%x %x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3, ptr+4); - fclose(fp); - if(count != 5) { - /* Likely a CPLD read timeout. */ - AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); - return ONLP_STATUS_E_INTERNAL; - } - - uint64_t rx_los_all = 0; - bytes[0]=bytes[1]=bytes[2]=bytes[3]=0xff; - for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { - rx_los_all <<= 8; - rx_los_all |= bytes[i]; - } - - /* Populate bitmap */ - for(i = 0; rx_los_all; i++) { - AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); - rx_los_all >>= 1; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - /* - * Read the SFP eeprom into data[] - * - * Return MISSING if SFP is missing. - * Return OK if eeprom is read - */ - int size = 0; - if(port <0 || port > 34) - return ONLP_STATUS_E_INTERNAL; - memset(data, 0, 256); - - if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)) != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - if (size != 256) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - FILE* fp; - char file[64] = {0}; - - sprintf(file, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)); - fp = fopen(file, "r"); - if(fp == NULL) { - AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } - - if (fseek(fp, 256, SEEK_CUR) != 0) { - fclose(fp); - AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } - - int ret = fread(data, 1, 256, fp); - fclose(fp); - if (ret != 256) { - AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - int bus = onlp_sfpi_map_bus_index(port); - return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) -{ - int bus = onlp_sfpi_map_bus_index(port); - return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) -{ - int bus = onlp_sfpi_map_bus_index(port); - return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - int bus = onlp_sfpi_map_bus_index(port); - return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int rv; - int addr = 60; - int bus = 11; - - if(port <0 || port > 34) - return ONLP_STATUS_E_INTERNAL; - - switch(control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - { - if(port==32 || port==33) - { - if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else { - rv = ONLP_STATUS_OK; - } - } - else if(port >=0) - { - if(!onlp_sfpi_is_present(port)) - return ONLP_STATUS_OK; - rv=onlp_sfpi_dev_writeb(port, 0x50, 86, 1); - if(rv < 0) - { - AIM_LOG_ERROR("Fail to read onlp_sfpi_dev_writeb, port=%d\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else - { - rv = ONLP_STATUS_OK; - } - } - break; - } - - default: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return rv; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int rv; - int addr = 60; - int bus = 11; - - if(port <0 || port > 34) - return ONLP_STATUS_E_INTERNAL; - - switch(control) - { - case ONLP_SFP_CONTROL_RX_LOS: - { - if(port==32 || port==33) - { - if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else { - rv = ONLP_STATUS_OK; - } - } - else - return ONLP_STATUS_E_UNSUPPORTED; - - break; - } - - case ONLP_SFP_CONTROL_TX_FAULT: - { - if(port==32 || port==33) - { - if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else { - rv = ONLP_STATUS_OK; - } - } - else - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - - case ONLP_SFP_CONTROL_TX_DISABLE: - { - if(port==32 || port==33) - { - if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { - AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else { - rv = ONLP_STATUS_OK; - } - } - else - { - if(port >= 0) - { - if(!onlp_sfpi_is_present(port)) - { - *value=0; - return ONLP_STATUS_OK; - } - rv=onlp_sfpi_dev_readb(port, 0x50, 86); - if(rv < 0) - { - AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else - { - *value= (rv & 0x1); - rv = ONLP_STATUS_OK; - } - } - } - break; - } - - default: - rv = ONLP_STATUS_E_UNSUPPORTED; - } - - return rv; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c deleted file mode 100755 index 4e16b3ad..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/sysi.c +++ /dev/null @@ -1,490 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2014 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include "x86_64_accton_as7726_32x_int.h" -#include "x86_64_accton_as7726_32x_log.h" - - -#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" -#define NUM_OF_CPLD 3 -#define FAN_DUTY_CYCLE_MAX (100) -#define FAN_DUTY_CYCLE_DEFAULT (32) -#define FAN_DUTY_PLUS_FOR_DIR (13) -/* Note, all chassis fans share 1 single duty setting. - * Here use fan 1 to represent global fan duty value.*/ -#define FAN_ID_FOR_SET_FAN_DUTY (1) -#define CELSIUS_RECORD_NUMBER (2) /*Must >= 2*/ - -typedef struct fan_ctrl_policy { - int duty_cycle; /* In percetage */ - int step_up_thermal; /* In mini-Celsius */ - int step_dn_thermal; /* In mini-Celsius */ -} fan_ctrl_policy_t; - -static char arr_cplddev_name[NUM_OF_CPLD][10] = -{ - "4-0060", - "5-0062", - "6-0064" -}; - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-accton-as7726-32x-r0"; -} - -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - uint8_t* rdata = aim_zmalloc(256); - - if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { - if(*size == 256) { - *data = rdata; - return ONLP_STATUS_OK; - } - } - - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - int i; - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - - /* 6 Thermal sensors on the chassis */ - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* 5 LEDs on the chassis */ - for (i = 1; i <= CHASSIS_LED_COUNT; i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* 2 PSUs on the chassis */ - for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { - *e++ = ONLP_PSU_ID_CREATE(i); - } - - /* 6 Fans on the chassis */ - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - -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); -} - -/* Thermal plan: - * $TMP = (CPU_core + LM75_1+ LM75_2 + LM75_3 + LM75_4)/5 - * 1. If any FAN failed, set all the other fans as full speed, 100%. - * 2. If any sensor is high than 45 degrees, set fan speed to duty 62.5%. - * 3. If any sensor is high than 50 degrees, set fan speed to duty 100%. - * 4. When $TMP >= 40 C, set fan speed to duty 62.5%. - * 5. When $TMP >= 45 C, set fan speed to duty 100%. - * 6. When $TMP < 35 C, set fan speed to duty 31.25%. - * 7. Direction factor, when B2F, duty + 12.5%. - * - * Note, all chassis fans share 1 single duty setting. - */ -fan_ctrl_policy_t fan_ctrl_policy_avg[] = { -{FAN_DUTY_CYCLE_MAX , 45000, INT_MIN}, -{63 , 40000, INT_MIN}, -{32 , INT_MAX, 35000}, -}; - -fan_ctrl_policy_t fan_ctrl_policy_single[] = { -{FAN_DUTY_CYCLE_MAX , 50000, INT_MIN}, -{63 , 45000, INT_MIN}, -}; - -struct fan_control_data_s { - int duty_cycle; - int dir_plus; - int mc_avg_pre[CELSIUS_RECORD_NUMBER]; - int mc_high_pre[CELSIUS_RECORD_NUMBER]; - -} fan_control_data_pre = -{ - .duty_cycle = FAN_DUTY_CYCLE_DEFAULT, - .dir_plus = 0, - .mc_avg_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ - .mc_high_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ - -}; - -static int -sysi_check_fan(uint32_t *fan_dir){ - int i, present; - - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - { - onlp_fan_info_t fan_info; - - if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); - return ONLP_STATUS_E_INTERNAL; - } - - present = fan_info.status & ONLP_FAN_STATUS_PRESENT; - if ((fan_info.status & ONLP_FAN_STATUS_FAILED) || !present) { - AIM_LOG_WARN("Fan(%d) is not working, set the other fans as full speed\r\n", i); - int ret = onlp_fani_percentage_set( - ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY), FAN_DUTY_CYCLE_MAX); - if (ret != ONLP_STATUS_OK) - return ret; - else - return ONLP_STATUS_E_MISSING; - } - - /* Get fan direction (Only get the first one since all fan direction are the same) - */ - if (i == 1) { - *fan_dir = fan_info.status & (ONLP_FAN_STATUS_F2B|ONLP_FAN_STATUS_B2F); - } - } - - return ONLP_STATUS_OK; -} - -static int -sysi_get_fan_duty(int *cur_duty_cycle){ - int fd, len; - char buf[10] = {0}; - char *node = FAN_NODE(fan_duty_cycle_percentage); - - /* Get current fan duty*/ - fd = open(node, O_RDONLY); - if (fd == -1){ - AIM_LOG_ERROR("Unable to open fan speed control node (%s)", node); - return ONLP_STATUS_E_INTERNAL; - } - - len = read(fd, buf, sizeof(buf)); - close(fd); - if (len <= 0) { - AIM_LOG_ERROR("Unable to read fan speed from (%s)", node); - return ONLP_STATUS_E_INTERNAL; - } - *cur_duty_cycle = atoi(buf); - - return ONLP_STATUS_OK; -} - -static int -sysi_get_thermal_sum(int *mcelsius){ - onlp_thermal_info_t thermal_info; - int i; - - *mcelsius = 0; - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { - if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) - != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read thermal status"); - return ONLP_STATUS_E_INTERNAL; - } - *mcelsius += thermal_info.mcelsius; - - DEBUG_PRINT("Thermal %d: %d \n ", i, thermal_info.mcelsius); - - } - - return ONLP_STATUS_OK; - -} - -static int -sysi_get_highest_thermal(int *mcelsius){ - onlp_thermal_info_t thermal_info; - int i, highest; - - highest = 0; - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { - if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) - != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read thermal status"); - return ONLP_STATUS_E_INTERNAL; - } - highest = (thermal_info.mcelsius > highest)? - thermal_info.mcelsius : highest; - } - *mcelsius = highest; - return ONLP_STATUS_OK; -} - -/* Anaylze thermal changing history to judge if the change is a stable trend. */ -static int _is_thermal_a_trend(int *mc_history){ - int i, trend, trended; - - if (mc_history == NULL) { - AIM_LOG_ERROR("Unable to get history of thermal\n"); - return 0; - } - - /* Get heat up/down trend. */ - trend = 0; - for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { - if (( mc_history[i+1] < mc_history[i])){ - trend++; - }else if (( mc_history[i+1] > mc_history[i])){ - trend--; - } - } - - trended = (abs(trend) >= ((CELSIUS_RECORD_NUMBER+1)/2))? 1:0; -#if (DEBUG_MODE == 1) - DEBUG_PRINT("[INFO]%s#%d, trended: %d, UP/DW: %d mcelsius:", - __func__, __LINE__, trended, trend ); - for (i = 0; i <= CELSIUS_RECORD_NUMBER; i++) { - DEBUG_PRINT(" %d =>", mc_history[i]); - } - DEBUG_PRINT("%c\n", ' '); -#endif - - /*For more than half changes are same direction, it's a firm trend.*/ - return trended; -} - - -/* Decide duty by highest value of thermal sensors.*/ -static int -sysi_get_duty_by_highest(int *duty_cycle){ - int i, ret, maxtrix_len; - int new_duty_cycle = 0 ; - int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; - int *mcelsius_pre_p = &mc_history[1]; - int *mcelsius_now_p = &mc_history[0]; - - /* Fill up mcelsius array, - * [0] is current temperature, others are history. - */ - ret = sysi_get_highest_thermal(mcelsius_now_p); - if(ONLP_STATUS_OK != ret){ - return ret; - } - memcpy (mcelsius_pre_p, fan_control_data_pre.mc_high_pre, - sizeof(fan_control_data_pre.mc_high_pre)); - - DEBUG_PRINT("[INFO]%s#%d, highest mcelsius:%d!\n", - __func__, __LINE__, *mcelsius_now_p); - - /* Shift records to the right */ - for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { - fan_control_data_pre.mc_high_pre[i] = mc_history[i]; - } - - /* Only change duty on consecutive heat rising or falling.*/ - maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_single); - - /* Only change duty when the thermal changing are firm. */ - if (_is_thermal_a_trend(mc_history)) - { - int matched = 0; - for (i = 0; i < maxtrix_len; i++) { - if ((*mcelsius_now_p > fan_ctrl_policy_single[i].step_up_thermal)) { - new_duty_cycle = fan_ctrl_policy_single[i].duty_cycle; - matched = !matched; - break; - } - } -/* if (!matched) { - DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", - __func__, __LINE__, *mcelsius_now_p); - } */ - } - *duty_cycle = new_duty_cycle; - return ONLP_STATUS_OK; -} - -/* Decide duty by average value of thermal sensors.*/ -static int -sysi_get_duty_by_average(int *duty_cycle){ - int i, mcelsius_avg, ret, maxtrix_len; - int new_duty_cycle=0; - int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; - int *mcelsius_pre_p = &mc_history[1]; - int *mcelsius_now_p = &mc_history[0]; - - /* Fill up mcelsius array, - * [0] is current temperature, others are history. - */ - *mcelsius_now_p = 0; - ret = sysi_get_thermal_sum(mcelsius_now_p); - if(ONLP_STATUS_OK != ret){ - return ret; - } - mcelsius_avg = (*mcelsius_now_p)/CHASSIS_THERMAL_COUNT; - - memcpy (mcelsius_pre_p, fan_control_data_pre.mc_avg_pre, - sizeof(fan_control_data_pre.mc_avg_pre)); - - DEBUG_PRINT("[INFO]%s#%d, mcelsius:%d!\n", __func__, __LINE__, mcelsius_avg); - - /* Shift records to the right */ - for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { - fan_control_data_pre.mc_avg_pre[i] = mc_history[i]; - } - - /* Only change duty on consecutive heat rising or falling.*/ - maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_avg); - - /* Only change duty when the thermal changing are firm. */ - if (_is_thermal_a_trend(mc_history)) - { - int matched = 0; - for (i = 0; i < maxtrix_len; i++) { - if ((mcelsius_avg >= fan_ctrl_policy_avg[i].step_up_thermal)) { - new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; - matched = !matched; - break; - } - } - for (i = maxtrix_len-1; i>=0; i--) { - if ((mcelsius_avg < fan_ctrl_policy_avg[i].step_dn_thermal)) { - new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; - matched = !matched; - break; - } - } - /*if (!matched) { - DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", - __func__, __LINE__, mcelsius_avg); - } */ - } - - *duty_cycle = new_duty_cycle; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - uint32_t fan_dir; - int ret; - int cur_duty_cycle, new_duty_cycle, tmp; - int direct_addon = 0; - onlp_oid_t fan_duty_oid = ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY); - - /********************************************************** - * Decision 1: Set fan as full speed if any fan is failed. - **********************************************************/ - ret = sysi_check_fan(&fan_dir); - if(ONLP_STATUS_OK != ret){ - return ret; - } - - if (fan_dir & ONLP_FAN_STATUS_B2F) { - direct_addon = FAN_DUTY_PLUS_FOR_DIR; - } - - /********************************************************** - * Decision 2: If no matched fan speed is found from the policy, - * use FAN_DUTY_CYCLE_MIN as default speed - **********************************************************/ - ret = sysi_get_fan_duty(&cur_duty_cycle); - if(ONLP_STATUS_OK != ret){ - return ret; - } - - /********************************************************** - * Decision 3: Decide new fan speed depend on fan direction and temperature - **********************************************************/ - ret = sysi_get_duty_by_average(&new_duty_cycle); - if (ONLP_STATUS_OK != ret){ - return ret; - } - ret = sysi_get_duty_by_highest(&tmp); - if (ONLP_STATUS_OK != ret){ - return ret; - } - - new_duty_cycle = (tmp > new_duty_cycle)? tmp : new_duty_cycle; - if (new_duty_cycle == 0) - { - new_duty_cycle = fan_control_data_pre.duty_cycle; - } else { - fan_control_data_pre.duty_cycle = new_duty_cycle; - } - fan_control_data_pre.dir_plus = direct_addon; - DEBUG_PRINT("[INFO]%s#%d, new duty: %d = %d + %d (%d)!\n", __func__, __LINE__, - new_duty_cycle + direct_addon, new_duty_cycle, direct_addon, cur_duty_cycle); - - new_duty_cycle += direct_addon; - new_duty_cycle = (new_duty_cycle > FAN_DUTY_CYCLE_MAX)? - FAN_DUTY_CYCLE_MAX : new_duty_cycle; - - if (new_duty_cycle == cur_duty_cycle) { - /* Duty cycle does not change, just return */ - return ONLP_STATUS_OK; - } - - return onlp_fani_percentage_set(fan_duty_oid, new_duty_cycle); -} - -int -onlp_sysi_platform_manage_leds(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c deleted file mode 100755 index c3c548cd..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/thermali.c +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2014 Accton Technology Corporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -//#include -#include -#include -#include "platform_lib.h" - -#define THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*temp1_input" -#define PSU_THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*psu_temp1_input" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -enum onlp_thermal_id -{ - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE, - THERMAL_1_ON_MAIN_BROAD, - THERMAL_2_ON_MAIN_BROAD, - THERMAL_3_ON_MAIN_BROAD, - THERMAL_4_ON_MAIN_BROAD, - THERMAL_5_ON_MAIN_BROAD, - THERMAL_1_ON_PSU1, - THERMAL_1_ON_PSU2, -}; - -static char* directory[] = /* must map with onlp_thermal_id */ -{ - NULL, - NULL, /* CPU_CORE files */ - "55-0048", - "55-0049", - "55-004a", - "55-004b", - "54-004c", - "50-005b", - "49-0058", -}; - -static char* cpu_coretemp_files[] = - { - "/sys/devices/platform/coretemp.0*temp2_input", - "/sys/devices/platform/coretemp.0*temp3_input", - "/sys/devices/platform/coretemp.0*temp4_input", - "/sys/devices/platform/coretemp.0*temp5_input", - NULL, - }; - -/* Static values */ -static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "LM75-4-4B", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "LM75-5-4C", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - } -}; - -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -/* - * Retrieve the information structure for the given thermal OID. - * - * If the OID is invalid, return ONLP_E_STATUS_INVALID. - * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. - * Otherwise, return ONLP_STATUS_OK with the OID's information. - * - * Note -- it is expected that you fill out the information - * structure even if the sensor described by the OID is not present. - */ -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) -{ - int tid; - char *format = NULL; - char path[64] = {0}; - VALIDATE(id); - - tid = ONLP_OID_ID_GET(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[tid]; - if(tid == THERMAL_CPU_CORE) { - return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); - } - - switch (tid) { - case THERMAL_1_ON_MAIN_BROAD: - case THERMAL_2_ON_MAIN_BROAD: - case THERMAL_3_ON_MAIN_BROAD: - case THERMAL_4_ON_MAIN_BROAD: - case THERMAL_5_ON_MAIN_BROAD: - format = THERMAL_PATH_FORMAT; - break; - case THERMAL_1_ON_PSU1: - case THERMAL_1_ON_PSU2: - format = PSU_THERMAL_PATH_FORMAT; - break; - default: - return ONLP_STATUS_E_INVALID; - }; - - /* get path */ - sprintf(path, format, directory[tid], tid); - if (onlp_file_read_int(&info->mcelsius, path) < 0) { - AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c deleted file mode 100755 index 5f01b6d9..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(_x) -x86_64_accton_as7726_32x_config_settings_t x86_64_accton_as7726_32x_config_settings[] = -{ -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE -#undef __x86_64_accton_as7726_32x_config_STRINGIFY_NAME - -const char* -x86_64_accton_as7726_32x_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_accton_as7726_32x_config_settings[i].name; i++) { - if(!strcmp(x86_64_accton_as7726_32x_config_settings[i].name, setting)) { - return x86_64_accton_as7726_32x_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_accton_as7726_32x_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_accton_as7726_32x_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_accton_as7726_32x_config_settings[i].name, x86_64_accton_as7726_32x_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c deleted file mode 100755 index 3230f78d..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h deleted file mode 100755 index a4568088..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_accton_as7726_32x Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_accton_as7726_32x_INT_H__ -#define __x86_64_accton_as7726_32x_INT_H__ - -#include - - -#endif /* __x86_64_accton_as7726_32x_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c deleted file mode 100755 index c2eb34e4..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_accton_as7726_32x_log.h" -/* - * x86_64_accton_as7726_32x log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h deleted file mode 100755 index ae099f84..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_accton_as7726_32x_LOG_H__ -#define __x86_64_accton_as7726_32x_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_accton_as7726_32x -#include - -#endif /* __x86_64_accton_as7726_32x_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c deleted file mode 100755 index 3b434422..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_accton_as7726_32x_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_accton_as7726_32x_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_accton_as7726_32x_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c deleted file mode 100755 index 3786e3e6..00000000 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/module/src/x86_64_accton_as7726_32x_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_accton_as7726_32x_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_accton_as7726_32x_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7726_32x) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_accton_as7726_32x_ucli_module__ = - { - "x86_64_accton_as7726_32x_ucli", - NULL, - x86_64_accton_as7726_32x_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_accton_as7726_32x_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_accton_as7726_32x_ucli_module__); - n = ucli_node_create("x86_64_accton_as7726_32x", NULL, &x86_64_accton_as7726_32x_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7726_32x")); - return n; -} - -#else -void* -x86_64_accton_as7726_32x_ucli_node_create(void) -{ - return NULL; -} -#endif - From 238b5491818e504cfdf35085a1c9e78ed235db9b Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 15:04:54 +0000 Subject: [PATCH 229/244] The x86_64_as7726_32x module has been regenerated using the newmodule script. --- .../src/x86_64_accton_as7726_32x/.module | 1 + .../src/x86_64_accton_as7726_32x/Makefile | 9 + .../src/x86_64_accton_as7726_32x/README | 6 + .../module/auto/make.mk | 9 + .../module/auto/x86_64_accton_as7726_32x.yml | 47 ++ .../x86_64_accton_as7726_32x.x | 14 + .../x86_64_accton_as7726_32x_config.h | 127 +++++ .../x86_64_accton_as7726_32x_dox.h | 26 + .../x86_64_accton_as7726_32x_porting.h | 107 ++++ .../x86_64_accton_as7726_32x/module/make.mk | 10 + .../module/src/Makefile | 9 + .../module/src/fani.c | 367 +++++++++++++ .../module/src/ledi.c | 261 ++++++++++ .../module/src/make.mk | 9 + .../module/src/platform_lib.c | 202 ++++++++ .../module/src/platform_lib.h | 87 ++++ .../module/src/psui.c | 185 +++++++ .../module/src/sfpi.c | 422 +++++++++++++++ .../module/src/sysi.c | 490 ++++++++++++++++++ .../module/src/thermali.c | 174 +++++++ .../src/x86_64_accton_as7726_32x_config.c | 76 +++ .../src/x86_64_accton_as7726_32x_enums.c | 10 + .../module/src/x86_64_accton_as7726_32x_int.h | 12 + .../module/src/x86_64_accton_as7726_32x_log.c | 18 + .../module/src/x86_64_accton_as7726_32x_log.h | 12 + .../src/x86_64_accton_as7726_32x_module.c | 24 + .../src/x86_64_accton_as7726_32x_ucli.c | 50 ++ .../x86_64_accton_as7726_32x/utest/_make.mk | 8 + .../src/x86_64_accton_as7726_32x/utest/main.c | 19 + .../x86_64_accton_as7726_32x.doxy | 0 30 files changed, 2791 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/x86_64_accton_as7726_32x.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/fani.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/make.mk create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/psui.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sysi.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/_make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/main.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.doxy diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/.module b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/.module new file mode 100644 index 00000000..28f927de --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/.module @@ -0,0 +1 @@ +name: x86_64_accton_as7726_32x diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/Makefile new file mode 100644 index 00000000..968f76b6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_accton_as7726_32x +AUTOMODULE := x86_64_accton_as7726_32x +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/README b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/README new file mode 100644 index 00000000..5aad1403 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as7726_32x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/make.mk new file mode 100644 index 00000000..da2cf91f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_as7726_32x Autogeneration +# +############################################################################### +x86_64_accton_as7726_32x_AUTO_DEFS := module/auto/x86_64_accton_as7726_32x.yml +x86_64_accton_as7726_32x_AUTO_DIRS := module/inc/x86_64_accton_as7726_32x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/x86_64_accton_as7726_32x.yml b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/x86_64_accton_as7726_32x.yml new file mode 100644 index 00000000..125063cd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/auto/x86_64_accton_as7726_32x.yml @@ -0,0 +1,47 @@ +############################################################################### +# +# x86_64_accton_as7726_32x Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_AS7726_32X_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as7726_32x_config + + portingmacro: + X86_64_ACCTON_AS7726_32X: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x new file mode 100644 index 00000000..b0e04177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h new file mode 100644 index 00000000..a4c059b7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_config.h @@ -0,0 +1,127 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7726_32x Configuration Header + * + * @addtogroup x86_64_accton_as7726_32x-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7726_32X_CONFIG_H__ +#define __X86_64_ACCTON_AS7726_32X_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_AS7726_32X_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as7726_32x_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as7726_32x_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as7726_32x_config_settings table. */ +extern x86_64_accton_as7726_32x_config_settings_t x86_64_accton_as7726_32x_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as7726_32x_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as7726_32x_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as7726_32x_porting.h" + +#endif /* __X86_64_ACCTON_AS7726_32X_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h new file mode 100644 index 00000000..14f663c0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as7726_32x Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7726_32X_DOX_H__ +#define __X86_64_ACCTON_AS7726_32X_DOX_H__ + +/** + * @defgroup x86_64_accton_as7726_32x x86_64_accton_as7726_32x - x86_64_accton_as7726_32x Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as7726_32x-x86_64_accton_as7726_32x Public Interface + * @defgroup x86_64_accton_as7726_32x-config Compile Time Configuration + * @defgroup x86_64_accton_as7726_32x-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_AS7726_32X_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h new file mode 100644 index 00000000..cef419f3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/inc/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as7726_32x Porting Macros. + * + * @addtogroup x86_64_accton_as7726_32x-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7726_32X_PORTING_H__ +#define __X86_64_ACCTON_AS7726_32X_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_ACCTON_AS7726_32X_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_MALLOC malloc + #else + #error The macro X86_64_ACCTON_AS7726_32X_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_FREE + #if defined(GLOBAL_FREE) + #define X86_64_ACCTON_AS7726_32X_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_FREE free + #else + #error The macro X86_64_ACCTON_AS7726_32X_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_ACCTON_AS7726_32X_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_MEMSET memset + #else + #error The macro X86_64_ACCTON_AS7726_32X_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_ACCTON_AS7726_32X_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_MEMCPY memcpy + #else + #error The macro X86_64_ACCTON_AS7726_32X_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_ACCTON_AS7726_32X_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_STRNCPY strncpy + #else + #error The macro X86_64_ACCTON_AS7726_32X_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_ACCTON_AS7726_32X_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_VSNPRINTF vsnprintf + #else + #error The macro X86_64_ACCTON_AS7726_32X_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_ACCTON_AS7726_32X_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_SNPRINTF snprintf + #else + #error The macro X86_64_ACCTON_AS7726_32X_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS7726_32X_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_ACCTON_AS7726_32X_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS7726_32X_STRLEN strlen + #else + #error The macro X86_64_ACCTON_AS7726_32X_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_AS7726_32X_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/make.mk new file mode 100644 index 00000000..7dd2df7a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as7726_32x_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as7726_32x_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as7726_32x_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7726_32x ucli:x86_64_accton_as7726_32x + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/Makefile new file mode 100644 index 00000000..b1a02144 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as7726_32x_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/fani.c new file mode 100755 index 00000000..e82f8a77 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/fani.c @@ -0,0 +1,367 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#define PSU_PREFIX_PATH "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + CHASSIS_FAN_INFO(6), + PSU_FAN_INFO(1,1), + PSU_FAN_INFO(2,1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value; + char path[64] = {0}; + + /* get fan present status + */ + sprintf(path, "%s""fan%d_present", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), present path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + sprintf(path, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), fault path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + sprintf(path, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan(%d), direction path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; + + + /* get front fan speed + */ + sprintf(path, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), front speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + sprintf(path, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + DEBUG_PRINT("Fan (%d), rear speed path = (%s)", fid, path); + + if (onlp_file_read_int(&value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan fault status + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + DEBUG_PRINT("Fan path = (%s)", path); + + if (onlp_file_write_integer(path, p) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/ledi.c new file mode 100755 index 00000000..94926527 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/ledi.c @@ -0,0 +1,261 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include + +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/accton_as7726_32x_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (onlp_file_write_integer(fullpath, onlp_to_driver_led_mode(local_id, mode)) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/make.mk new file mode 100644 index 00000000..4956dd6a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as7726_32x +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.c new file mode 100755 index 00000000..fc7a5f2c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.c @@ -0,0 +1,202 @@ +#include +#include +#include +#include +#include "platform_lib.h" +#include +#include "x86_64_accton_as7726_32x_log.h" + + +static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { + return -1; + } + + if ((len = write(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_write_integer(char *filename, int value) +{ + char buf[8] = {0}; + sprintf(buf, "%d", value); + + return _onlp_file_write(filename, buf, (int)strlen(buf), 0); +} + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) +{ + int fd; + int len; + + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + if ((fd = open(filename, O_RDONLY)) == -1) { + return -1; + } + + if ((len = read(fd, buffer, buf_size)) < 0) { + close(fd); + return -1; + } + + if ((close(fd) == -1)) { + return -1; + } + + if ((len > buf_size) || (data_len != 0 && len != data_len)) { + return -1; + } + + return 0; +} + +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 9 +#define I2C_PSU_FAN_DIR_LEN 3 + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) : PSU2_AC_PMBUS_NODE(psu_mfr_model); + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (modelname) { + strncpy(modelname, model_name, modelname_len-1); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_integer(path, value) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +#define PSU_SERIAL_NUMBER_LEN 18 + +int psu_serial_number_get(int id, char *serial, int serial_len) +{ + int size = 0; + int ret = ONLP_STATUS_OK; + char *prefix = NULL; + + if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_PARAM; + } + + prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX; + + ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial"); + if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) { + return ONLP_STATUS_E_INTERNAL; + + } + + serial[PSU_SERIAL_NUMBER_LEN] = '\0'; + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.h new file mode 100755 index 00000000..96c817bb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/platform_lib.h @@ -0,0 +1,87 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include +#include "x86_64_accton_as7726_32x_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 6 +#define CHASSIS_PSU_COUNT 2 +#define CHASSIS_LED_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/50-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/49-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/50-0053/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/49-0050/" + + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/54-0066/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom" + +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); + + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_serial_number_get(int id, char *serial, int serial_len); + +//#define DEBUG_MODE 1 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/psui.c new file mode 100755 index 00000000..5185a145 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/psui.c @@ -0,0 +1,185 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +//#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + + + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + + if (PSU1_ID == id) { + sprintf(path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + psu_serial_number_get(index, info->serial, sizeof(info->serial)); + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +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); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + AIM_LOG_ERROR("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c new file mode 100755 index 00000000..f9d671b0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c @@ -0,0 +1,422 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include "x86_64_accton_as7726_32x_int.h" +#include "x86_64_accton_as7726_32x_log.h" + +#define PORT_BUS_INDEX(port) (port+18) + +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD "/sys/bus/i2c/devices/11-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD3 "/sys/bus/i2c/devices/6-0064/module_rx_los_all" + + +int sfp_map_bus[] ={21, 22, 23, 24, 26, 25, 28, 27, + 17, 18, 19, 20, 29, 30, 31, 32, + 33, 34, 35, 36, 45, 46, 47, 48, + 37, 38, 39, 40, 41, 42, 43, 44, + 15, 16}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ + +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} +int +onlp_sfpi_map_bus_index(int port) +{ + if(port < 0 || port >=34) + return ONLP_STATUS_E_INTERNAL; + return sfp_map_bus[port]; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 34} + */ + int p; + + for(p = 0; p < 34; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus, addr; + + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + + addr = 60; + bus = 11; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[5], *ptr = NULL; + FILE* fp; + int addr=60; + int bus=11; + char file[64] = {0}; + int count; + + ptr = bytes; + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + count = fscanf(fp, "%x %x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3, ptr+4); + fclose(fp); + if(count != 5) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + uint64_t presence_all = 0 ; + int i = 0; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[5]; + uint32_t *ptr = bytes; + FILE* fp; + + int addr=60, i = 0; + + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3, ptr+4); + fclose(fp); + if(count != 5) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + uint64_t rx_los_all = 0; + bytes[0]=bytes[1]=bytes[2]=bytes[3]=0xff; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = onlp_sfpi_map_bus_index(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + int addr = 60; + int bus = 11; + + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if(port==32 || port==33) + { + if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else if(port >=0) + { + if(!onlp_sfpi_is_present(port)) + return ONLP_STATUS_OK; + rv=onlp_sfpi_dev_writeb(port, 0x50, 86, 1); + if(rv < 0) + { + AIM_LOG_ERROR("Fail to read onlp_sfpi_dev_writeb, port=%d\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else + { + rv = ONLP_STATUS_OK; + } + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + int addr = 60; + int bus = 11; + + if(port <0 || port > 34) + return ONLP_STATUS_E_INTERNAL; + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if(port==32 || port==33) + { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else + return ONLP_STATUS_E_UNSUPPORTED; + + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if(port==32 || port==33) + { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else + return ONLP_STATUS_E_UNSUPPORTED; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if(port==32 || port==33) + { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + } + else + { + if(port >= 0) + { + if(!onlp_sfpi_is_present(port)) + { + *value=0; + return ONLP_STATUS_OK; + } + rv=onlp_sfpi_dev_readb(port, 0x50, 86); + if(rv < 0) + { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else + { + *value= (rv & 0x1); + rv = ONLP_STATUS_OK; + } + } + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sysi.c new file mode 100755 index 00000000..4e16b3ad --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sysi.c @@ -0,0 +1,490 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include + +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_accton_as7726_32x_int.h" +#include "x86_64_accton_as7726_32x_log.h" + + +#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" +#define NUM_OF_CPLD 3 +#define FAN_DUTY_CYCLE_MAX (100) +#define FAN_DUTY_CYCLE_DEFAULT (32) +#define FAN_DUTY_PLUS_FOR_DIR (13) +/* Note, all chassis fans share 1 single duty setting. + * Here use fan 1 to represent global fan duty value.*/ +#define FAN_ID_FOR_SET_FAN_DUTY (1) +#define CELSIUS_RECORD_NUMBER (2) /*Must >= 2*/ + +typedef struct fan_ctrl_policy { + int duty_cycle; /* In percetage */ + int step_up_thermal; /* In mini-Celsius */ + int step_dn_thermal; /* In mini-Celsius */ +} fan_ctrl_policy_t; + +static char arr_cplddev_name[NUM_OF_CPLD][10] = +{ + "4-0060", + "5-0062", + "6-0064" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as7726-32x-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 6 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +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); +} + +/* Thermal plan: + * $TMP = (CPU_core + LM75_1+ LM75_2 + LM75_3 + LM75_4)/5 + * 1. If any FAN failed, set all the other fans as full speed, 100%. + * 2. If any sensor is high than 45 degrees, set fan speed to duty 62.5%. + * 3. If any sensor is high than 50 degrees, set fan speed to duty 100%. + * 4. When $TMP >= 40 C, set fan speed to duty 62.5%. + * 5. When $TMP >= 45 C, set fan speed to duty 100%. + * 6. When $TMP < 35 C, set fan speed to duty 31.25%. + * 7. Direction factor, when B2F, duty + 12.5%. + * + * Note, all chassis fans share 1 single duty setting. + */ +fan_ctrl_policy_t fan_ctrl_policy_avg[] = { +{FAN_DUTY_CYCLE_MAX , 45000, INT_MIN}, +{63 , 40000, INT_MIN}, +{32 , INT_MAX, 35000}, +}; + +fan_ctrl_policy_t fan_ctrl_policy_single[] = { +{FAN_DUTY_CYCLE_MAX , 50000, INT_MIN}, +{63 , 45000, INT_MIN}, +}; + +struct fan_control_data_s { + int duty_cycle; + int dir_plus; + int mc_avg_pre[CELSIUS_RECORD_NUMBER]; + int mc_high_pre[CELSIUS_RECORD_NUMBER]; + +} fan_control_data_pre = +{ + .duty_cycle = FAN_DUTY_CYCLE_DEFAULT, + .dir_plus = 0, + .mc_avg_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + .mc_high_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ + +}; + +static int +sysi_check_fan(uint32_t *fan_dir){ + int i, present; + + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + present = fan_info.status & ONLP_FAN_STATUS_PRESENT; + if ((fan_info.status & ONLP_FAN_STATUS_FAILED) || !present) { + AIM_LOG_WARN("Fan(%d) is not working, set the other fans as full speed\r\n", i); + int ret = onlp_fani_percentage_set( + ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY), FAN_DUTY_CYCLE_MAX); + if (ret != ONLP_STATUS_OK) + return ret; + else + return ONLP_STATUS_E_MISSING; + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + *fan_dir = fan_info.status & (ONLP_FAN_STATUS_F2B|ONLP_FAN_STATUS_B2F); + } + } + + return ONLP_STATUS_OK; +} + +static int +sysi_get_fan_duty(int *cur_duty_cycle){ + int fd, len; + char buf[10] = {0}; + char *node = FAN_NODE(fan_duty_cycle_percentage); + + /* Get current fan duty*/ + fd = open(node, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", node); + return ONLP_STATUS_E_INTERNAL; + } + *cur_duty_cycle = atoi(buf); + + return ONLP_STATUS_OK; +} + +static int +sysi_get_thermal_sum(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i; + + *mcelsius = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + *mcelsius += thermal_info.mcelsius; + + DEBUG_PRINT("Thermal %d: %d \n ", i, thermal_info.mcelsius); + + } + + return ONLP_STATUS_OK; + +} + +static int +sysi_get_highest_thermal(int *mcelsius){ + onlp_thermal_info_t thermal_info; + int i, highest; + + highest = 0; + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) + != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + highest = (thermal_info.mcelsius > highest)? + thermal_info.mcelsius : highest; + } + *mcelsius = highest; + return ONLP_STATUS_OK; +} + +/* Anaylze thermal changing history to judge if the change is a stable trend. */ +static int _is_thermal_a_trend(int *mc_history){ + int i, trend, trended; + + if (mc_history == NULL) { + AIM_LOG_ERROR("Unable to get history of thermal\n"); + return 0; + } + + /* Get heat up/down trend. */ + trend = 0; + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + if (( mc_history[i+1] < mc_history[i])){ + trend++; + }else if (( mc_history[i+1] > mc_history[i])){ + trend--; + } + } + + trended = (abs(trend) >= ((CELSIUS_RECORD_NUMBER+1)/2))? 1:0; +#if (DEBUG_MODE == 1) + DEBUG_PRINT("[INFO]%s#%d, trended: %d, UP/DW: %d mcelsius:", + __func__, __LINE__, trended, trend ); + for (i = 0; i <= CELSIUS_RECORD_NUMBER; i++) { + DEBUG_PRINT(" %d =>", mc_history[i]); + } + DEBUG_PRINT("%c\n", ' '); +#endif + + /*For more than half changes are same direction, it's a firm trend.*/ + return trended; +} + + +/* Decide duty by highest value of thermal sensors.*/ +static int +sysi_get_duty_by_highest(int *duty_cycle){ + int i, ret, maxtrix_len; + int new_duty_cycle = 0 ; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + ret = sysi_get_highest_thermal(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_high_pre, + sizeof(fan_control_data_pre.mc_high_pre)); + + DEBUG_PRINT("[INFO]%s#%d, highest mcelsius:%d!\n", + __func__, __LINE__, *mcelsius_now_p); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_high_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_single); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((*mcelsius_now_p > fan_ctrl_policy_single[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_single[i].duty_cycle; + matched = !matched; + break; + } + } +/* if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, *mcelsius_now_p); + } */ + } + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +/* Decide duty by average value of thermal sensors.*/ +static int +sysi_get_duty_by_average(int *duty_cycle){ + int i, mcelsius_avg, ret, maxtrix_len; + int new_duty_cycle=0; + int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; + int *mcelsius_pre_p = &mc_history[1]; + int *mcelsius_now_p = &mc_history[0]; + + /* Fill up mcelsius array, + * [0] is current temperature, others are history. + */ + *mcelsius_now_p = 0; + ret = sysi_get_thermal_sum(mcelsius_now_p); + if(ONLP_STATUS_OK != ret){ + return ret; + } + mcelsius_avg = (*mcelsius_now_p)/CHASSIS_THERMAL_COUNT; + + memcpy (mcelsius_pre_p, fan_control_data_pre.mc_avg_pre, + sizeof(fan_control_data_pre.mc_avg_pre)); + + DEBUG_PRINT("[INFO]%s#%d, mcelsius:%d!\n", __func__, __LINE__, mcelsius_avg); + + /* Shift records to the right */ + for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { + fan_control_data_pre.mc_avg_pre[i] = mc_history[i]; + } + + /* Only change duty on consecutive heat rising or falling.*/ + maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_avg); + + /* Only change duty when the thermal changing are firm. */ + if (_is_thermal_a_trend(mc_history)) + { + int matched = 0; + for (i = 0; i < maxtrix_len; i++) { + if ((mcelsius_avg >= fan_ctrl_policy_avg[i].step_up_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + for (i = maxtrix_len-1; i>=0; i--) { + if ((mcelsius_avg < fan_ctrl_policy_avg[i].step_dn_thermal)) { + new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; + matched = !matched; + break; + } + } + /*if (!matched) { + DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", + __func__, __LINE__, mcelsius_avg); + } */ + } + + *duty_cycle = new_duty_cycle; + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_fans(void) +{ + uint32_t fan_dir; + int ret; + int cur_duty_cycle, new_duty_cycle, tmp; + int direct_addon = 0; + onlp_oid_t fan_duty_oid = ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY); + + /********************************************************** + * Decision 1: Set fan as full speed if any fan is failed. + **********************************************************/ + ret = sysi_check_fan(&fan_dir); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + if (fan_dir & ONLP_FAN_STATUS_B2F) { + direct_addon = FAN_DUTY_PLUS_FOR_DIR; + } + + /********************************************************** + * Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + **********************************************************/ + ret = sysi_get_fan_duty(&cur_duty_cycle); + if(ONLP_STATUS_OK != ret){ + return ret; + } + + /********************************************************** + * Decision 3: Decide new fan speed depend on fan direction and temperature + **********************************************************/ + ret = sysi_get_duty_by_average(&new_duty_cycle); + if (ONLP_STATUS_OK != ret){ + return ret; + } + ret = sysi_get_duty_by_highest(&tmp); + if (ONLP_STATUS_OK != ret){ + return ret; + } + + new_duty_cycle = (tmp > new_duty_cycle)? tmp : new_duty_cycle; + if (new_duty_cycle == 0) + { + new_duty_cycle = fan_control_data_pre.duty_cycle; + } else { + fan_control_data_pre.duty_cycle = new_duty_cycle; + } + fan_control_data_pre.dir_plus = direct_addon; + DEBUG_PRINT("[INFO]%s#%d, new duty: %d = %d + %d (%d)!\n", __func__, __LINE__, + new_duty_cycle + direct_addon, new_duty_cycle, direct_addon, cur_duty_cycle); + + new_duty_cycle += direct_addon; + new_duty_cycle = (new_duty_cycle > FAN_DUTY_CYCLE_MAX)? + FAN_DUTY_CYCLE_MAX : new_duty_cycle; + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(fan_duty_oid, new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/thermali.c new file mode 100755 index 00000000..c3c548cd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/thermali.c @@ -0,0 +1,174 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +//#include +#include +#include +#include "platform_lib.h" + +#define THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*temp1_input" +#define PSU_THERMAL_PATH_FORMAT "/sys/bus/i2c/devices/%s/*psu_temp1_input" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* directory[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "55-0048", + "55-0049", + "55-004a", + "55-004b", + "54-004c", + "50-005b", + "49-0058", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "LM75-4-4B", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "LM75-5-4C", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + char *format = NULL; + char path[64] = {0}; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + if(tid == THERMAL_CPU_CORE) { + return onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + } + + switch (tid) { + case THERMAL_1_ON_MAIN_BROAD: + case THERMAL_2_ON_MAIN_BROAD: + case THERMAL_3_ON_MAIN_BROAD: + case THERMAL_4_ON_MAIN_BROAD: + case THERMAL_5_ON_MAIN_BROAD: + format = THERMAL_PATH_FORMAT; + break; + case THERMAL_1_ON_PSU1: + case THERMAL_1_ON_PSU2: + format = PSU_THERMAL_PATH_FORMAT; + break; + default: + return ONLP_STATUS_E_INVALID; + }; + + /* get path */ + sprintf(path, format, directory[tid], tid); + if (onlp_file_read_int(&info->mcelsius, path) < 0) { + AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_config.c new file mode 100644 index 00000000..ed962ca6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_config.c @@ -0,0 +1,76 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(_x) +x86_64_accton_as7726_32x_config_settings_t x86_64_accton_as7726_32x_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_STDLIB(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as7726_32x_config_STRINGIFY_NAME(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7726_32x_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as7726_32x_config_STRINGIFY_VALUE +#undef __x86_64_accton_as7726_32x_config_STRINGIFY_NAME + +const char* +x86_64_accton_as7726_32x_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as7726_32x_config_settings[i].name; i++) { + if(!strcmp(x86_64_accton_as7726_32x_config_settings[i].name, setting)) { + return x86_64_accton_as7726_32x_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as7726_32x_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as7726_32x_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as7726_32x_config_settings[i].name, x86_64_accton_as7726_32x_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_enums.c new file mode 100644 index 00000000..3230f78d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_int.h new file mode 100644 index 00000000..053b752f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as7726_32x Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7726_32X_INT_H__ +#define __X86_64_ACCTON_AS7726_32X_INT_H__ + +#include + + +#endif /* __X86_64_ACCTON_AS7726_32X_INT_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.c new file mode 100644 index 00000000..2c81d205 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7726_32x_log.h" +/* + * x86_64_accton_as7726_32x log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS7726_32X_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS7726_32X_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS7726_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.h new file mode 100644 index 00000000..98f081c5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS7726_32X_LOG_H__ +#define __X86_64_ACCTON_AS7726_32X_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as7726_32x +#include + +#endif /* __X86_64_ACCTON_AS7726_32X_LOG_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_module.c new file mode 100644 index 00000000..173a14ed --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as7726_32x_log.h" + +static int +datatypes_init__(void) +{ +#define X86_64_ACCTON_AS7726_32X_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as7726_32x_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_ucli.c new file mode 100644 index 00000000..b1537c11 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/x86_64_accton_as7726_32x_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_ACCTON_AS7726_32X_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as7726_32x_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7726_32x) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as7726_32x_ucli_module__ = + { + "x86_64_accton_as7726_32x_ucli", + NULL, + x86_64_accton_as7726_32x_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as7726_32x_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as7726_32x_ucli_module__); + n = ucli_node_create("x86_64_accton_as7726_32x", NULL, &x86_64_accton_as7726_32x_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7726_32x")); + return n; +} + +#else +void* +x86_64_accton_as7726_32x_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/_make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/_make.mk new file mode 100644 index 00000000..e21f7699 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/_make.mk @@ -0,0 +1,8 @@ +############################################################################### +# +# x86_64_accton_as7726_32x Unit Test Makefile. +# +############################################################################### +UMODULE := x86_64_accton_as7726_32x +UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/utest.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/main.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/main.c new file mode 100644 index 00000000..8406fbc1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/utest/main.c @@ -0,0 +1,19 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include +#include +#include +#include + +int aim_main(int argc, char* argv[]) +{ + printf("x86_64_accton_as7726_32x Utest Is Empty\n"); + x86_64_accton_as7726_32x_config_show(&aim_pvs_stdout); + return 0; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.doxy b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/x86_64_accton_as7726_32x.doxy new file mode 100644 index 00000000..e69de29b From d9b9856006db1f40fdd0362fe522f9e6566452d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:20:14 +0000 Subject: [PATCH 230/244] [Issue #351] Remove proxy address from the ONL sources url. --- builds/any/rootfs/jessie/standard/standard.yml | 8 +++++++- builds/any/rootfs/stretch/standard/standard.yml | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/builds/any/rootfs/jessie/standard/standard.yml b/builds/any/rootfs/jessie/standard/standard.yml index b7aa4067..d5390fb0 100644 --- a/builds/any/rootfs/jessie/standard/standard.yml +++ b/builds/any/rootfs/jessie/standard/standard.yml @@ -23,7 +23,7 @@ Multistrap: noauth: true explicitsuite: false unpack: true - debootstrap: Debian-Local Local-All Local-Arch ONL + debootstrap: Debian-Local Local-All Local-Arch ONL-Local aptsources: Debian ONL Debian: @@ -41,6 +41,12 @@ Multistrap: omitdebsrc: true ONL: + packages: *Packages + source: http://apt.opennetlinux.org/debian + suite: unstable + omitdebsrc: true + + ONL-Local: packages: *Packages source: http://${APT_CACHE}apt.opennetlinux.org/debian suite: unstable diff --git a/builds/any/rootfs/stretch/standard/standard.yml b/builds/any/rootfs/stretch/standard/standard.yml index b57fe6c7..275b1ce7 100644 --- a/builds/any/rootfs/stretch/standard/standard.yml +++ b/builds/any/rootfs/stretch/standard/standard.yml @@ -23,7 +23,7 @@ Multistrap: noauth: true explicitsuite: false unpack: true - debootstrap: Debian-Local Local-All Local-Arch ONL + debootstrap: Debian-Local Local-All Local-Arch ONL-Local aptsources: Debian ONL Debian: @@ -41,6 +41,12 @@ Multistrap: omitdebsrc: true ONL: + packages: *Packages + source: http://apt.opennetlinux.org/debian + suite: unstable + omitdebsrc: true + + ONL-Local: packages: *Packages source: http://${APT_CACHE}apt.opennetlinux.org/debian suite: unstable From fe855ea1a9e0414dd0b50115604876799d1c7851 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:34:28 +0000 Subject: [PATCH 231/244] Initial gitignores. --- .../x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/.gitignore | 1 + .../x86-64-inventec-d7054q28b/onlp/builds/onlpdump/.gitignore | 1 + .../x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.gitignore | 1 + 3 files changed, 3 insertions(+) create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/.gitignore create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/.gitignore create mode 100644 packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.gitignore diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/.gitignore new file mode 100644 index 00000000..832440b4 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/lib/.gitignore @@ -0,0 +1 @@ +libonlp-x86-64-inventec-d7054q28b.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/.gitignore new file mode 100644 index 00000000..9f7b1342 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/onlpdump/.gitignore @@ -0,0 +1 @@ +onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.gitignore b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.gitignore new file mode 100644 index 00000000..332e166f --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7054q28b/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +x86_64_inventec_d7054q28b.mk From f818730f36e89c3555de678a5fba16c9b4cf5148 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:34:52 +0000 Subject: [PATCH 232/244] Fix makefile. --- .../x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile index 4007d6bd..ad5aa4fe 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/Makefile @@ -1,9 +1,9 @@ ############################################################################### # -# +# # ############################################################################### -include ../../init.mk +include $(ONL)/make/config.mk MODULE := x86_64_accton_as7326_56x AUTOMODULE := x86_64_accton_as7326_56x include $(BUILDER)/definemodule.mk From c43e647c025ef593d9ada587d5f7a61d84381c14 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:35:26 +0000 Subject: [PATCH 233/244] Allow a package to declare its desired symlink behavior. --- tools/onlpm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index 4784fb79..6faa6e2c 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -281,7 +281,7 @@ class OnlPackage(object): return True @staticmethod - def copyf(src, dst, root): + def copyf(src, dst, root, symlinks=False): if dst.startswith('/'): dst = dst[1:] @@ -291,7 +291,7 @@ class OnlPackage(object): # dstpath = os.path.join(root, dst) logger.debug("Copytree %s -> %s" % (src, dstpath)) - shutil.copytree(src, dstpath) + shutil.copytree(src, dstpath, symlinks=symlinks) else: # # If the destination ends in a '/' it means copy the filename @@ -353,7 +353,7 @@ class OnlPackage(object): self.pkg['__workdir'] = workdir for (src,dst) in self.pkg.get('files', {}): - OnlPackage.copyf(src, dst, root) + OnlPackage.copyf(src, dst, root, symlinks=self.pkg.get('symlinks', False)) for (src,dst) in self.pkg.get('optional-files', {}): if os.path.exists(src): From 6eaa1cbd0696eaf403e0785a2147444fdcc25f69 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:36:53 +0000 Subject: [PATCH 234/244] Add kernel config variable for additional modsync directories. --- make/kbuild.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/kbuild.mk b/make/kbuild.mk index ade86c31..7355ed6f 100644 --- a/make/kbuild.mk +++ b/make/kbuild.mk @@ -176,7 +176,7 @@ MODSYNCLIST_DEFAULT := .config Module.symvers Makefile include scripts drivers \ arch/powerpc/include arch/powerpc/Makefile arch/powerpc/lib arch/powerpc/boot/dts \ arch/arm/include arch/arm/Makefile arch/arm/lib arch/arm/boot/dts -MODSYNCLIST := $(MODSYNCLIST_DEFAULT) $(MODSYNCLIST_EXTRA) +MODSYNCLIST := $(MODSYNCLIST_DEFAULT) $(MODSYNCLIST_EXTRA) $(K_MODSYNCLIST) # This file must be preserved for PPC module builds. MODSYNCKEEP := arch/powerpc/lib/crtsavres.o From c49df97f1e8da41f0a7eb9401219f7c3fac90079 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:38:00 +0000 Subject: [PATCH 235/244] Add lib directory. --- packages/base/any/kernels/3.2-lts/configs/x86_64-all/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/any/kernels/3.2-lts/configs/x86_64-all/.gitignore b/packages/base/any/kernels/3.2-lts/configs/x86_64-all/.gitignore index f03e13f1..0d80abb2 100644 --- a/packages/base/any/kernels/3.2-lts/configs/x86_64-all/.gitignore +++ b/packages/base/any/kernels/3.2-lts/configs/x86_64-all/.gitignore @@ -1,2 +1,3 @@ kernel-3.2* linux-* +lib From 722312722c6eb2426354fc74c74c96be9118a0ad Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:48:07 +0000 Subject: [PATCH 236/244] Initial configuration for the 4.14 kernel. --- .../4.14-lts/configs/x86_64-all/.gitignore | 3 + .../4.14-lts/configs/x86_64-all/Makefile | 37 + .../configs/x86_64-all/x86_64-all.config | 4357 +++++++++++++++++ packages/base/any/kernels/4.14-lts/kconfig.mk | 27 + .../base/any/kernels/4.14-lts/patches/series | 1 + 5 files changed, 4425 insertions(+) create mode 100644 packages/base/any/kernels/4.14-lts/configs/x86_64-all/.gitignore create mode 100644 packages/base/any/kernels/4.14-lts/configs/x86_64-all/Makefile create mode 100644 packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config create mode 100644 packages/base/any/kernels/4.14-lts/kconfig.mk create mode 100644 packages/base/any/kernels/4.14-lts/patches/series diff --git a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/.gitignore b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/.gitignore new file mode 100644 index 00000000..7e374176 --- /dev/null +++ b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/.gitignore @@ -0,0 +1,3 @@ +kernel-* +linux-* +lib diff --git a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/Makefile b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/Makefile new file mode 100644 index 00000000..c632aeee --- /dev/null +++ b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/Makefile @@ -0,0 +1,37 @@ +############################################################ +# +# +# Copyright 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +include $(ONL)/make/config.mk + +export ARCH := x86_64 +ifndef K_TARGET_DIR +K_TARGET_DIR := $(THIS_DIR) +endif + +include ../../kconfig.mk +K_CONFIG := x86_64-all.config +K_BUILD_TARGET := bzImage +K_COPY_SRC := arch/x86/boot/bzImage +ifndef K_COPY_DST +K_COPY_DST := kernel-4.14-lts-x86_64-all +endif + +include $(ONL)/make/kbuild.mk diff --git a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config new file mode 100644 index 00000000..98fc5c4a --- /dev/null +++ b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config @@ -0,0 +1,4357 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/x86_64 4.14.34 Kernel Configuration +# +CONFIG_64BIT=y +CONFIG_X86_64=y +CONFIG_X86=y +CONFIG_INSTRUCTION_DECODER=y +CONFIG_OUTPUT_FORMAT="elf64-x86-64" +CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig" +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_MMU=y +CONFIG_ARCH_MMAP_RND_BITS_MIN=28 +CONFIG_ARCH_MMAP_RND_BITS_MAX=32 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y +CONFIG_GENERIC_HWEIGHT=y +CONFIG_ARCH_MAY_HAVE_PC_FDC=y +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_ARCH_HAS_CPU_RELAX=y +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y +CONFIG_HAVE_SETUP_PER_CPU_AREA=y +CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y +CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y +CONFIG_ZONE_DMA32=y +CONFIG_AUDIT_ARCH=y +CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y +CONFIG_HAVE_INTEL_TXT=y +CONFIG_X86_64_SMP=y +CONFIG_ARCH_SUPPORTS_UPROBES=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_PGTABLE_LEVELS=4 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +CONFIG_IRQ_WORK=y +CONFIG_BUILDTIME_EXTABLE_SORT=y +CONFIG_THREAD_INFO_IN_TASK=y + +# +# General setup +# +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_CROSS_COMPILE="" +# CONFIG_COMPILE_TEST is not set +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_HAVE_KERNEL_GZIP=y +CONFIG_HAVE_KERNEL_BZIP2=y +CONFIG_HAVE_KERNEL_LZMA=y +CONFIG_HAVE_KERNEL_XZ=y +CONFIG_HAVE_KERNEL_LZO=y +CONFIG_HAVE_KERNEL_LZ4=y +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +# CONFIG_KERNEL_XZ is not set +# CONFIG_KERNEL_LZO is not set +# CONFIG_KERNEL_LZ4 is not set +CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +CONFIG_POSIX_MQUEUE=y +CONFIG_POSIX_MQUEUE_SYSCTL=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_FHANDLE=y +CONFIG_USELIB=y +CONFIG_AUDIT=y +CONFIG_HAVE_ARCH_AUDITSYSCALL=y +CONFIG_AUDITSYSCALL=y +CONFIG_AUDIT_WATCH=y +CONFIG_AUDIT_TREE=y + +# +# IRQ subsystem +# +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_PENDING_IRQ=y +CONFIG_GENERIC_IRQ_MIGRATION=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_MSI_IRQ_DOMAIN=y +# CONFIG_IRQ_DOMAIN_DEBUG is not set +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_SPARSE_IRQ=y +# CONFIG_GENERIC_IRQ_DEBUGFS is not set +CONFIG_CLOCKSOURCE_WATCHDOG=y +CONFIG_ARCH_CLOCKSOURCE_DATA=y +CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y +CONFIG_GENERIC_CMOS_UPDATE=y + +# +# Timers subsystem +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ_COMMON=y +# CONFIG_HZ_PERIODIC is not set +CONFIG_NO_HZ_IDLE=y +# CONFIG_NO_HZ_FULL is not set +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y + +# +# CPU/Task time and stats accounting +# +CONFIG_TICK_CPU_ACCOUNTING=y +# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set +# CONFIG_IRQ_TIME_ACCOUNTING is not set +CONFIG_BSD_PROCESS_ACCT=y +# CONFIG_BSD_PROCESS_ACCT_V3 is not set +CONFIG_TASKSTATS=y +CONFIG_TASK_DELAY_ACCT=y +CONFIG_TASK_XACCT=y +CONFIG_TASK_IO_ACCOUNTING=y + +# +# RCU Subsystem +# +CONFIG_TREE_RCU=y +# CONFIG_RCU_EXPERT is not set +CONFIG_SRCU=y +CONFIG_TREE_SRCU=y +# CONFIG_TASKS_RCU is not set +CONFIG_RCU_STALL_COMMON=y +CONFIG_RCU_NEED_SEGCBLIST=y +# CONFIG_BUILD_BIN2C is not set +# CONFIG_IKCONFIG is not set +CONFIG_LOG_BUF_SHIFT=18 +CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13 +CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y +CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y +CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y +CONFIG_ARCH_SUPPORTS_INT128=y +# CONFIG_NUMA_BALANCING is not set +CONFIG_CGROUPS=y +# CONFIG_MEMCG is not set +# CONFIG_BLK_CGROUP is not set +CONFIG_CGROUP_SCHED=y +CONFIG_FAIR_GROUP_SCHED=y +# CONFIG_CFS_BANDWIDTH is not set +# CONFIG_RT_GROUP_SCHED is not set +# CONFIG_CGROUP_PIDS is not set +# CONFIG_CGROUP_RDMA is not set +CONFIG_CGROUP_FREEZER=y +# CONFIG_CGROUP_HUGETLB is not set +CONFIG_CPUSETS=y +CONFIG_PROC_PID_CPUSET=y +# CONFIG_CGROUP_DEVICE is not set +CONFIG_CGROUP_CPUACCT=y +# CONFIG_CGROUP_PERF is not set +# CONFIG_CGROUP_DEBUG is not set +# CONFIG_SOCK_CGROUP_DATA is not set +# CONFIG_CHECKPOINT_RESTORE is not set +CONFIG_NAMESPACES=y +CONFIG_UTS_NS=y +CONFIG_IPC_NS=y +# CONFIG_USER_NS is not set +CONFIG_PID_NS=y +CONFIG_NET_NS=y +# CONFIG_SCHED_AUTOGROUP is not set +# CONFIG_SYSFS_DEPRECATED is not set +CONFIG_RELAY=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_RD_GZIP=y +CONFIG_RD_BZIP2=y +CONFIG_RD_LZMA=y +CONFIG_RD_XZ=y +CONFIG_RD_LZO=y +CONFIG_RD_LZ4=y +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +CONFIG_HAVE_UID16=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_HAVE_PCSPKR_PLATFORM=y +CONFIG_BPF=y +# CONFIG_EXPERT is not set +CONFIG_UID16=y +CONFIG_MULTIUSER=y +CONFIG_SGETMASK_SYSCALL=y +CONFIG_SYSFS_SYSCALL=y +# CONFIG_SYSCTL_SYSCALL is not set +CONFIG_POSIX_TIMERS=y +CONFIG_KALLSYMS=y +# CONFIG_KALLSYMS_ALL is not set +CONFIG_KALLSYMS_ABSOLUTE_PERCPU=y +CONFIG_KALLSYMS_BASE_RELATIVE=y +CONFIG_PRINTK=y +CONFIG_PRINTK_NMI=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_PCSPKR_PLATFORM=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_FUTEX_PI=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +# CONFIG_BPF_SYSCALL is not set +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_ADVISE_SYSCALLS=y +# CONFIG_USERFAULTFD is not set +CONFIG_PCI_QUIRKS=y +CONFIG_MEMBARRIER=y +# CONFIG_EMBEDDED is not set +CONFIG_HAVE_PERF_EVENTS=y +# CONFIG_PC104 is not set + +# +# Kernel Performance Events And Counters +# +CONFIG_PERF_EVENTS=y +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +# CONFIG_COMPAT_BRK is not set +# CONFIG_SLAB is not set +CONFIG_SLUB=y +CONFIG_SLAB_MERGE_DEFAULT=y +# CONFIG_SLAB_FREELIST_RANDOM is not set +# CONFIG_SLAB_FREELIST_HARDENED is not set +CONFIG_SLUB_CPU_PARTIAL=y +# CONFIG_SYSTEM_DATA_VERIFICATION is not set +CONFIG_PROFILING=y +CONFIG_TRACEPOINTS=y +CONFIG_CRASH_CORE=y +CONFIG_KEXEC_CORE=y +# CONFIG_OPROFILE is not set +CONFIG_HAVE_OPROFILE=y +CONFIG_OPROFILE_NMI_TIMER=y +CONFIG_KPROBES=y +CONFIG_JUMP_LABEL=y +# CONFIG_STATIC_KEYS_SELFTEST is not set +CONFIG_OPTPROBES=y +CONFIG_UPROBES=y +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_ARCH_USE_BUILTIN_BSWAP=y +CONFIG_KRETPROBES=y +CONFIG_HAVE_IOREMAP_PROT=y +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_KPROBES_ON_FTRACE=y +CONFIG_HAVE_NMI=y +CONFIG_HAVE_ARCH_TRACEHOOK=y +CONFIG_HAVE_DMA_CONTIGUOUS=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y +CONFIG_ARCH_HAS_SET_MEMORY=y +CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_CLK=y +CONFIG_HAVE_DMA_API_DEBUG=y +CONFIG_HAVE_HW_BREAKPOINT=y +CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y +CONFIG_HAVE_USER_RETURN_NOTIFIER=y +CONFIG_HAVE_PERF_EVENTS_NMI=y +CONFIG_HAVE_HARDLOCKUP_DETECTOR_PERF=y +CONFIG_HAVE_PERF_REGS=y +CONFIG_HAVE_PERF_USER_STACK_DUMP=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_RCU_TABLE_FREE=y +CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y +CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y +CONFIG_HAVE_CMPXCHG_LOCAL=y +CONFIG_HAVE_CMPXCHG_DOUBLE=y +CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y +CONFIG_ARCH_WANT_OLD_COMPAT_IPC=y +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_SECCOMP_FILTER=y +CONFIG_HAVE_GCC_PLUGINS=y +# CONFIG_GCC_PLUGINS is not set +CONFIG_HAVE_CC_STACKPROTECTOR=y +# CONFIG_CC_STACKPROTECTOR is not set +CONFIG_CC_STACKPROTECTOR_NONE=y +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +# CONFIG_CC_STACKPROTECTOR_STRONG is not set +CONFIG_THIN_ARCHIVES=y +CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES=y +CONFIG_HAVE_CONTEXT_TRACKING=y +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y +CONFIG_HAVE_ARCH_HUGE_VMAP=y +CONFIG_HAVE_ARCH_SOFT_DIRTY=y +CONFIG_HAVE_MOD_ARCH_SPECIFIC=y +CONFIG_MODULES_USE_ELF_RELA=y +CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK=y +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_HAVE_ARCH_MMAP_RND_BITS=y +CONFIG_HAVE_EXIT_THREAD=y +CONFIG_ARCH_MMAP_RND_BITS=28 +CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y +CONFIG_ARCH_MMAP_RND_COMPAT_BITS=8 +CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES=y +CONFIG_HAVE_COPY_THREAD_TLS=y +CONFIG_HAVE_STACK_VALIDATION=y +# CONFIG_HAVE_ARCH_HASH is not set +# CONFIG_ISA_BUS_API is not set +CONFIG_OLD_SIGSUSPEND3=y +CONFIG_COMPAT_OLD_SIGACTION=y +# CONFIG_CPU_NO_EFFICIENT_FFS is not set +CONFIG_HAVE_ARCH_VMAP_STACK=y +CONFIG_VMAP_STACK=y +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX is not set +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_STRICT_MODULE_RWX=y +CONFIG_ARCH_HAS_REFCOUNT=y +# CONFIG_REFCOUNT_FULL is not set + +# +# GCOV-based kernel profiling +# +# CONFIG_GCOV_KERNEL is not set +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y +# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +CONFIG_MODULE_FORCE_UNLOAD=y +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +# CONFIG_MODULE_SIG is not set +# CONFIG_MODULE_COMPRESS is not set +# CONFIG_TRIM_UNUSED_KSYMS is not set +CONFIG_MODULES_TREE_LOOKUP=y +CONFIG_BLOCK=y +CONFIG_BLK_SCSI_REQUEST=y +CONFIG_BLK_DEV_BSG=y +# CONFIG_BLK_DEV_BSGLIB is not set +# CONFIG_BLK_DEV_INTEGRITY is not set +# CONFIG_BLK_DEV_ZONED is not set +# CONFIG_BLK_CMDLINE_PARSER is not set +# CONFIG_BLK_WBT is not set +CONFIG_BLK_DEBUG_FS=y +# CONFIG_BLK_SED_OPAL is not set + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +# CONFIG_AIX_PARTITION is not set +CONFIG_OSF_PARTITION=y +CONFIG_AMIGA_PARTITION=y +# CONFIG_ATARI_PARTITION is not set +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +# CONFIG_LDM_PARTITION is not set +CONFIG_SGI_PARTITION=y +# CONFIG_ULTRIX_PARTITION is not set +CONFIG_SUN_PARTITION=y +CONFIG_KARMA_PARTITION=y +CONFIG_EFI_PARTITION=y +# CONFIG_SYSV68_PARTITION is not set +# CONFIG_CMDLINE_PARTITION is not set +CONFIG_BLOCK_COMPAT=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_MQ_VIRTIO=y + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_MQ_IOSCHED_DEADLINE=y +CONFIG_MQ_IOSCHED_KYBER=y +# CONFIG_IOSCHED_BFQ is not set +CONFIG_INLINE_SPIN_UNLOCK_IRQ=y +CONFIG_INLINE_READ_UNLOCK=y +CONFIG_INLINE_READ_UNLOCK_IRQ=y +CONFIG_INLINE_WRITE_UNLOCK=y +CONFIG_INLINE_WRITE_UNLOCK_IRQ=y +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y +CONFIG_QUEUED_SPINLOCKS=y +CONFIG_ARCH_USE_QUEUED_RWLOCKS=y +CONFIG_QUEUED_RWLOCKS=y +CONFIG_FREEZER=y + +# +# Processor type and features +# +CONFIG_ZONE_DMA=y +CONFIG_SMP=y +CONFIG_X86_FEATURE_NAMES=y +CONFIG_X86_FAST_FEATURE_TESTS=y +CONFIG_X86_MPPARSE=y +# CONFIG_GOLDFISH is not set +CONFIG_RETPOLINE=y +# CONFIG_INTEL_RDT is not set +CONFIG_X86_EXTENDED_PLATFORM=y +# CONFIG_X86_VSMP is not set +# CONFIG_X86_GOLDFISH is not set +# CONFIG_X86_INTEL_MID is not set +# CONFIG_X86_INTEL_LPSS is not set +# CONFIG_X86_AMD_PLATFORM_DEVICE is not set +CONFIG_IOSF_MBI=y +# CONFIG_IOSF_MBI_DEBUG is not set +CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y +CONFIG_SCHED_OMIT_FRAME_POINTER=y +# CONFIG_HYPERVISOR_GUEST is not set +CONFIG_NO_BOOTMEM=y +# CONFIG_MK8 is not set +# CONFIG_MPSC is not set +# CONFIG_MCORE2 is not set +# CONFIG_MATOM is not set +CONFIG_GENERIC_CPU=y +CONFIG_X86_INTERNODE_CACHE_SHIFT=6 +CONFIG_X86_L1_CACHE_SHIFT=6 +CONFIG_X86_TSC=y +CONFIG_X86_CMPXCHG64=y +CONFIG_X86_CMOV=y +CONFIG_X86_MINIMUM_CPU_FAMILY=64 +CONFIG_X86_DEBUGCTLMSR=y +CONFIG_CPU_SUP_INTEL=y +CONFIG_CPU_SUP_AMD=y +CONFIG_CPU_SUP_CENTAUR=y +CONFIG_HPET_TIMER=y +CONFIG_HPET_EMULATE_RTC=y +CONFIG_DMI=y +# CONFIG_GART_IOMMU is not set +CONFIG_CALGARY_IOMMU=y +CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT=y +CONFIG_SWIOTLB=y +CONFIG_IOMMU_HELPER=y +# CONFIG_MAXSMP is not set +CONFIG_NR_CPUS=64 +CONFIG_SCHED_SMT=y +CONFIG_SCHED_MC=y +CONFIG_SCHED_MC_PRIO=y +# CONFIG_PREEMPT_NONE is not set +CONFIG_PREEMPT_VOLUNTARY=y +# CONFIG_PREEMPT is not set +CONFIG_X86_LOCAL_APIC=y +CONFIG_X86_IO_APIC=y +CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y +CONFIG_X86_MCE=y +# CONFIG_X86_MCELOG_LEGACY is not set +CONFIG_X86_MCE_INTEL=y +CONFIG_X86_MCE_AMD=y +CONFIG_X86_MCE_THRESHOLD=y +# CONFIG_X86_MCE_INJECT is not set +CONFIG_X86_THERMAL_VECTOR=y + +# +# Performance monitoring +# +CONFIG_PERF_EVENTS_INTEL_UNCORE=y +CONFIG_PERF_EVENTS_INTEL_RAPL=y +CONFIG_PERF_EVENTS_INTEL_CSTATE=y +# CONFIG_PERF_EVENTS_AMD_POWER is not set +# CONFIG_VM86 is not set +CONFIG_X86_16BIT=y +CONFIG_X86_ESPFIX64=y +CONFIG_X86_VSYSCALL_EMULATION=y +# CONFIG_I8K is not set +CONFIG_MICROCODE=y +CONFIG_MICROCODE_INTEL=y +CONFIG_MICROCODE_AMD=y +CONFIG_MICROCODE_OLD_INTERFACE=y +CONFIG_X86_MSR=y +CONFIG_X86_CPUID=y +# CONFIG_X86_5LEVEL is not set +CONFIG_ARCH_PHYS_ADDR_T_64BIT=y +CONFIG_ARCH_DMA_ADDR_T_64BIT=y +CONFIG_X86_DIRECT_GBPAGES=y +CONFIG_ARCH_HAS_MEM_ENCRYPT=y +# CONFIG_AMD_MEM_ENCRYPT is not set +CONFIG_NUMA=y +CONFIG_AMD_NUMA=y +CONFIG_X86_64_ACPI_NUMA=y +CONFIG_NODES_SPAN_OTHER_NODES=y +# CONFIG_NUMA_EMU is not set +CONFIG_NODES_SHIFT=6 +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_SPARSEMEM_DEFAULT=y +CONFIG_ARCH_SELECT_MEMORY_MODEL=y +CONFIG_ARCH_PROC_KCORE_TEXT=y +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_SPARSEMEM_MANUAL=y +CONFIG_SPARSEMEM=y +CONFIG_NEED_MULTIPLE_NODES=y +CONFIG_HAVE_MEMORY_PRESENT=y +CONFIG_SPARSEMEM_EXTREME=y +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y +CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER=y +CONFIG_SPARSEMEM_VMEMMAP=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MEMBLOCK_NODE_MAP=y +CONFIG_HAVE_GENERIC_GUP=y +CONFIG_ARCH_DISCARD_MEMBLOCK=y +# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set +# CONFIG_MEMORY_HOTPLUG is not set +CONFIG_SPLIT_PTLOCK_CPUS=4 +CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y +CONFIG_COMPACTION=y +CONFIG_MIGRATION=y +CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION=y +CONFIG_PHYS_ADDR_T_64BIT=y +CONFIG_BOUNCE=y +CONFIG_VIRT_TO_BUS=y +CONFIG_MMU_NOTIFIER=y +# CONFIG_KSM is not set +CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y +# CONFIG_MEMORY_FAILURE is not set +# CONFIG_TRANSPARENT_HUGEPAGE is not set +CONFIG_ARCH_WANTS_THP_SWAP=y +# CONFIG_CLEANCACHE is not set +# CONFIG_FRONTSWAP is not set +# CONFIG_CMA is not set +# CONFIG_ZPOOL is not set +# CONFIG_ZBUD is not set +# CONFIG_ZSMALLOC is not set +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT=y +# CONFIG_IDLE_PAGE_TRACKING is not set +CONFIG_ARCH_HAS_ZONE_DEVICE=y +CONFIG_ARCH_USES_HIGH_VMA_FLAGS=y +CONFIG_ARCH_HAS_PKEYS=y +# CONFIG_PERCPU_STATS is not set +# CONFIG_X86_PMEM_LEGACY is not set +CONFIG_X86_CHECK_BIOS_CORRUPTION=y +CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK=y +CONFIG_X86_RESERVE_LOW=64 +CONFIG_MTRR=y +# CONFIG_MTRR_SANITIZER is not set +CONFIG_X86_PAT=y +CONFIG_ARCH_USES_PG_UNCACHED=y +CONFIG_ARCH_RANDOM=y +CONFIG_X86_SMAP=y +# CONFIG_X86_INTEL_MPX is not set +CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y +CONFIG_EFI=y +# CONFIG_EFI_STUB is not set +CONFIG_SECCOMP=y +# CONFIG_HZ_100 is not set +# CONFIG_HZ_250 is not set +# CONFIG_HZ_300 is not set +CONFIG_HZ_1000=y +CONFIG_HZ=1000 +CONFIG_SCHED_HRTICK=y +CONFIG_KEXEC=y +# CONFIG_KEXEC_FILE is not set +CONFIG_CRASH_DUMP=y +# CONFIG_KEXEC_JUMP is not set +CONFIG_PHYSICAL_START=0x1000000 +CONFIG_RELOCATABLE=y +CONFIG_RANDOMIZE_BASE=y +CONFIG_X86_NEED_RELOCS=y +CONFIG_PHYSICAL_ALIGN=0x200000 +CONFIG_RANDOMIZE_MEMORY=y +CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING=0x0 +CONFIG_HOTPLUG_CPU=y +# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set +# CONFIG_DEBUG_HOTPLUG_CPU0 is not set +# CONFIG_COMPAT_VDSO is not set +# CONFIG_LEGACY_VSYSCALL_NATIVE is not set +CONFIG_LEGACY_VSYSCALL_EMULATE=y +# CONFIG_LEGACY_VSYSCALL_NONE is not set +# CONFIG_CMDLINE_BOOL is not set +CONFIG_MODIFY_LDT_SYSCALL=y +CONFIG_HAVE_LIVEPATCH=y +CONFIG_ARCH_HAS_ADD_PAGES=y +CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y +CONFIG_USE_PERCPU_NUMA_NODE_ID=y + +# +# Power management and ACPI options +# +CONFIG_ARCH_HIBERNATION_HEADER=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +CONFIG_HIBERNATE_CALLBACKS=y +CONFIG_HIBERNATION=y +CONFIG_PM_STD_PARTITION="" +CONFIG_PM_SLEEP=y +CONFIG_PM_SLEEP_SMP=y +# CONFIG_PM_AUTOSLEEP is not set +# CONFIG_PM_WAKELOCKS is not set +CONFIG_PM=y +CONFIG_PM_DEBUG=y +# CONFIG_PM_ADVANCED_DEBUG is not set +# CONFIG_PM_TEST_SUSPEND is not set +CONFIG_PM_SLEEP_DEBUG=y +CONFIG_PM_TRACE=y +CONFIG_PM_TRACE_RTC=y +CONFIG_PM_CLK=y +# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set +CONFIG_ACPI=y +CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y +CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y +CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y +# CONFIG_ACPI_DEBUGGER is not set +CONFIG_ACPI_SLEEP=y +# CONFIG_ACPI_PROCFS_POWER is not set +CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y +# CONFIG_ACPI_EC_DEBUGFS is not set +CONFIG_ACPI_AC=y +CONFIG_ACPI_BATTERY=y +CONFIG_ACPI_BUTTON=y +CONFIG_ACPI_VIDEO=y +CONFIG_ACPI_FAN=y +CONFIG_ACPI_DOCK=y +CONFIG_ACPI_CPU_FREQ_PSS=y +CONFIG_ACPI_PROCESSOR_CSTATE=y +CONFIG_ACPI_PROCESSOR_IDLE=y +CONFIG_ACPI_CPPC_LIB=y +CONFIG_ACPI_PROCESSOR=y +CONFIG_ACPI_HOTPLUG_CPU=y +# CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set +CONFIG_ACPI_THERMAL=y +CONFIG_ACPI_NUMA=y +# CONFIG_ACPI_CUSTOM_DSDT is not set +CONFIG_ARCH_HAS_ACPI_TABLE_UPGRADE=y +CONFIG_ACPI_TABLE_UPGRADE=y +# CONFIG_ACPI_DEBUG is not set +# CONFIG_ACPI_PCI_SLOT is not set +CONFIG_X86_PM_TIMER=y +CONFIG_ACPI_CONTAINER=y +CONFIG_ACPI_HOTPLUG_IOAPIC=y +# CONFIG_ACPI_SBS is not set +# CONFIG_ACPI_HED is not set +# CONFIG_ACPI_CUSTOM_METHOD is not set +# CONFIG_ACPI_BGRT is not set +# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set +# CONFIG_ACPI_NFIT is not set +CONFIG_HAVE_ACPI_APEI=y +CONFIG_HAVE_ACPI_APEI_NMI=y +# CONFIG_ACPI_APEI is not set +# CONFIG_DPTF_POWER is not set +# CONFIG_ACPI_EXTLOG is not set +# CONFIG_PMIC_OPREGION is not set +# CONFIG_ACPI_CONFIGFS is not set +# CONFIG_SFI is not set + +# +# CPU Frequency scaling +# +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +CONFIG_CPU_FREQ_GOV_COMMON=y +# CONFIG_CPU_FREQ_STAT is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set +CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set + +# +# CPU frequency scaling drivers +# +CONFIG_X86_INTEL_PSTATE=y +# CONFIG_X86_PCC_CPUFREQ is not set +CONFIG_X86_ACPI_CPUFREQ=y +CONFIG_X86_ACPI_CPUFREQ_CPB=y +# CONFIG_X86_POWERNOW_K8 is not set +# CONFIG_X86_AMD_FREQ_SENSITIVITY is not set +# CONFIG_X86_SPEEDSTEP_CENTRINO is not set +# CONFIG_X86_P4_CLOCKMOD is not set + +# +# shared options +# +# CONFIG_X86_SPEEDSTEP_LIB is not set + +# +# CPU Idle +# +CONFIG_CPU_IDLE=y +# CONFIG_CPU_IDLE_GOV_LADDER is not set +CONFIG_CPU_IDLE_GOV_MENU=y +# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set +# CONFIG_INTEL_IDLE is not set + +# +# Bus options (PCI etc.) +# +CONFIG_PCI=y +CONFIG_PCI_DIRECT=y +CONFIG_PCI_MMCONFIG=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCIEPORTBUS=y +# CONFIG_HOTPLUG_PCI_PCIE is not set +CONFIG_PCIEAER=y +# CONFIG_PCIE_ECRC is not set +# CONFIG_PCIEAER_INJECT is not set +CONFIG_PCIEASPM=y +# CONFIG_PCIEASPM_DEBUG is not set +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +# CONFIG_PCIEASPM_PERFORMANCE is not set +CONFIG_PCIE_PME=y +# CONFIG_PCIE_DPC is not set +# CONFIG_PCIE_PTM is not set +CONFIG_PCI_BUS_ADDR_T_64BIT=y +CONFIG_PCI_MSI=y +CONFIG_PCI_MSI_IRQ_DOMAIN=y +# CONFIG_PCI_DEBUG is not set +# CONFIG_PCI_REALLOC_ENABLE_AUTO is not set +# CONFIG_PCI_STUB is not set +CONFIG_HT_IRQ=y +CONFIG_PCI_ATS=y +CONFIG_PCI_LOCKLESS_CONFIG=y +# CONFIG_PCI_IOV is not set +CONFIG_PCI_PRI=y +CONFIG_PCI_PASID=y +CONFIG_PCI_LABEL=y +CONFIG_HOTPLUG_PCI=y +# CONFIG_HOTPLUG_PCI_ACPI is not set +# CONFIG_HOTPLUG_PCI_CPCI is not set +# CONFIG_HOTPLUG_PCI_SHPC is not set + +# +# DesignWare PCI Core Support +# +# CONFIG_PCIE_DW_PLAT is not set + +# +# PCI host controller drivers +# +# CONFIG_VMD is not set + +# +# PCI Endpoint +# +# CONFIG_PCI_ENDPOINT is not set + +# +# PCI switch controller drivers +# +# CONFIG_PCI_SW_SWITCHTEC is not set +CONFIG_ISA_DMA_API=y +CONFIG_AMD_NB=y +CONFIG_PCCARD=y +CONFIG_PCMCIA=y +CONFIG_PCMCIA_LOAD_CIS=y +CONFIG_CARDBUS=y + +# +# PC-card bridges +# +CONFIG_YENTA=y +CONFIG_YENTA_O2=y +CONFIG_YENTA_RICOH=y +CONFIG_YENTA_TI=y +CONFIG_YENTA_ENE_TUNE=y +CONFIG_YENTA_TOSHIBA=y +# CONFIG_PD6729 is not set +# CONFIG_I82092 is not set +CONFIG_PCCARD_NONSTATIC=y +# CONFIG_RAPIDIO is not set +# CONFIG_X86_SYSFB is not set + +# +# Executable file formats / Emulations +# +CONFIG_BINFMT_ELF=y +CONFIG_COMPAT_BINFMT_ELF=y +CONFIG_ELFCORE=y +CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y +CONFIG_BINFMT_SCRIPT=y +# CONFIG_HAVE_AOUT is not set +CONFIG_BINFMT_MISC=y +CONFIG_COREDUMP=y +CONFIG_IA32_EMULATION=y +# CONFIG_IA32_AOUT is not set +# CONFIG_X86_X32 is not set +CONFIG_COMPAT_32=y +CONFIG_COMPAT=y +CONFIG_COMPAT_FOR_U64_ALIGNMENT=y +CONFIG_SYSVIPC_COMPAT=y +CONFIG_X86_DEV_DMA_OPS=y +CONFIG_NET=y +CONFIG_NET_INGRESS=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +CONFIG_UNIX=y +# CONFIG_UNIX_DIAG is not set +# CONFIG_TLS is not set +CONFIG_XFRM=y +CONFIG_XFRM_ALGO=y +CONFIG_XFRM_USER=y +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +# CONFIG_IP_FIB_TRIE_STATS is not set +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +CONFIG_IP_PNP_RARP=y +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE_DEMUX is not set +CONFIG_NET_IP_TUNNEL=y +CONFIG_IP_MROUTE=y +# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set +CONFIG_IP_PIMSM_V1=y +CONFIG_IP_PIMSM_V2=y +CONFIG_SYN_COOKIES=y +# CONFIG_NET_UDP_TUNNEL is not set +# CONFIG_NET_FOU is not set +# CONFIG_NET_FOU_IP_TUNNELS is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +CONFIG_INET_TUNNEL=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_DIAG is not set +CONFIG_TCP_CONG_ADVANCED=y +# CONFIG_TCP_CONG_BIC is not set +CONFIG_TCP_CONG_CUBIC=y +# CONFIG_TCP_CONG_WESTWOOD is not set +# CONFIG_TCP_CONG_HTCP is not set +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_NV is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_TCP_CONG_LP is not set +# CONFIG_TCP_CONG_VENO is not set +# CONFIG_TCP_CONG_YEAH is not set +# CONFIG_TCP_CONG_ILLINOIS is not set +# CONFIG_TCP_CONG_DCTCP is not set +# CONFIG_TCP_CONG_CDG is not set +# CONFIG_TCP_CONG_BBR is not set +CONFIG_DEFAULT_CUBIC=y +# CONFIG_DEFAULT_RENO is not set +CONFIG_DEFAULT_TCP_CONG="cubic" +CONFIG_TCP_MD5SIG=y +CONFIG_IPV6=y +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +CONFIG_INET6_AH=y +CONFIG_INET6_ESP=y +# CONFIG_INET6_ESP_OFFLOAD is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_IPV6_ILA is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_XFRM_MODE_TRANSPORT=y +CONFIG_INET6_XFRM_MODE_TUNNEL=y +CONFIG_INET6_XFRM_MODE_BEET=y +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +# CONFIG_IPV6_VTI is not set +CONFIG_IPV6_SIT=y +# CONFIG_IPV6_SIT_6RD is not set +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_FOU is not set +# CONFIG_IPV6_FOU_TUNNEL is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_IPV6_SEG6_LWTUNNEL is not set +# CONFIG_IPV6_SEG6_HMAC is not set +CONFIG_NETLABEL=y +CONFIG_NETWORK_SECMARK=y +CONFIG_NET_PTP_CLASSIFY=y +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set +CONFIG_NETFILTER=y +# CONFIG_NETFILTER_ADVANCED is not set + +# +# Core Netfilter Configuration +# +CONFIG_NETFILTER_INGRESS=y +CONFIG_NETFILTER_NETLINK=y +CONFIG_NETFILTER_NETLINK_LOG=y +CONFIG_NF_CONNTRACK=y +CONFIG_NF_LOG_COMMON=m +# CONFIG_NF_LOG_NETDEV is not set +CONFIG_NF_CONNTRACK_SECMARK=y +CONFIG_NF_CONNTRACK_PROCFS=y +CONFIG_NF_CONNTRACK_FTP=y +CONFIG_NF_CONNTRACK_IRC=y +# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set +CONFIG_NF_CONNTRACK_SIP=y +CONFIG_NF_CT_NETLINK=y +# CONFIG_NETFILTER_NETLINK_GLUE_CT is not set +CONFIG_NF_NAT=m +CONFIG_NF_NAT_NEEDED=y +# CONFIG_NF_NAT_AMANDA is not set +CONFIG_NF_NAT_FTP=m +CONFIG_NF_NAT_IRC=m +CONFIG_NF_NAT_SIP=m +# CONFIG_NF_NAT_TFTP is not set +# CONFIG_NF_NAT_REDIRECT is not set +# CONFIG_NF_TABLES is not set +CONFIG_NETFILTER_XTABLES=y + +# +# Xtables combined modules +# +CONFIG_NETFILTER_XT_MARK=m + +# +# Xtables targets +# +CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y +CONFIG_NETFILTER_XT_TARGET_LOG=m +CONFIG_NETFILTER_XT_NAT=m +# CONFIG_NETFILTER_XT_TARGET_NETMAP is not set +CONFIG_NETFILTER_XT_TARGET_NFLOG=y +# CONFIG_NETFILTER_XT_TARGET_REDIRECT is not set +CONFIG_NETFILTER_XT_TARGET_SECMARK=y +CONFIG_NETFILTER_XT_TARGET_TCPMSS=y + +# +# Xtables matches +# +CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m +CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y +CONFIG_NETFILTER_XT_MATCH_POLICY=y +CONFIG_NETFILTER_XT_MATCH_STATE=y +# CONFIG_IP_SET is not set +# CONFIG_IP_VS is not set + +# +# IP: Netfilter Configuration +# +CONFIG_NF_DEFRAG_IPV4=y +CONFIG_NF_CONNTRACK_IPV4=y +# CONFIG_NF_SOCKET_IPV4 is not set +# CONFIG_NF_DUP_IPV4 is not set +CONFIG_NF_LOG_ARP=m +CONFIG_NF_LOG_IPV4=m +CONFIG_NF_REJECT_IPV4=y +CONFIG_NF_NAT_IPV4=m +CONFIG_NF_NAT_MASQUERADE_IPV4=m +# CONFIG_NF_NAT_PPTP is not set +# CONFIG_NF_NAT_H323 is not set +CONFIG_IP_NF_IPTABLES=y +CONFIG_IP_NF_FILTER=y +CONFIG_IP_NF_TARGET_REJECT=y +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_TARGET_MASQUERADE=m +CONFIG_IP_NF_MANGLE=y +# CONFIG_IP_NF_RAW is not set + +# +# IPv6: Netfilter Configuration +# +CONFIG_NF_DEFRAG_IPV6=y +CONFIG_NF_CONNTRACK_IPV6=y +# CONFIG_NF_SOCKET_IPV6 is not set +# CONFIG_NF_DUP_IPV6 is not set +CONFIG_NF_REJECT_IPV6=y +CONFIG_NF_LOG_IPV6=m +CONFIG_IP6_NF_IPTABLES=y +CONFIG_IP6_NF_MATCH_IPV6HEADER=y +CONFIG_IP6_NF_FILTER=y +CONFIG_IP6_NF_TARGET_REJECT=y +CONFIG_IP6_NF_MANGLE=y +# CONFIG_IP6_NF_RAW is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_RDS is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_L2TP is not set +# CONFIG_BRIDGE is not set +CONFIG_HAVE_NET_DSA=y +# CONFIG_NET_DSA is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_PHONET is not set +# CONFIG_6LOWPAN is not set +# CONFIG_IEEE802154 is not set +CONFIG_NET_SCHED=y + +# +# Queueing/Scheduling +# +# CONFIG_NET_SCH_CBQ is not set +# CONFIG_NET_SCH_HTB is not set +# CONFIG_NET_SCH_HFSC is not set +# CONFIG_NET_SCH_PRIO is not set +# CONFIG_NET_SCH_MULTIQ is not set +# CONFIG_NET_SCH_RED is not set +# CONFIG_NET_SCH_SFB is not set +# CONFIG_NET_SCH_SFQ is not set +# CONFIG_NET_SCH_TEQL is not set +# CONFIG_NET_SCH_TBF is not set +# CONFIG_NET_SCH_GRED is not set +# CONFIG_NET_SCH_DSMARK is not set +# CONFIG_NET_SCH_NETEM is not set +# CONFIG_NET_SCH_DRR is not set +# CONFIG_NET_SCH_MQPRIO is not set +# CONFIG_NET_SCH_CHOKE is not set +# CONFIG_NET_SCH_QFQ is not set +# CONFIG_NET_SCH_CODEL is not set +# CONFIG_NET_SCH_FQ_CODEL is not set +# CONFIG_NET_SCH_FQ is not set +# CONFIG_NET_SCH_HHF is not set +# CONFIG_NET_SCH_PIE is not set +# CONFIG_NET_SCH_INGRESS is not set +# CONFIG_NET_SCH_PLUG is not set +# CONFIG_NET_SCH_DEFAULT is not set + +# +# Classification +# +CONFIG_NET_CLS=y +# CONFIG_NET_CLS_BASIC is not set +# CONFIG_NET_CLS_TCINDEX is not set +# CONFIG_NET_CLS_ROUTE4 is not set +# CONFIG_NET_CLS_FW is not set +# CONFIG_NET_CLS_U32 is not set +# CONFIG_NET_CLS_RSVP is not set +# CONFIG_NET_CLS_RSVP6 is not set +# CONFIG_NET_CLS_FLOW is not set +# CONFIG_NET_CLS_CGROUP is not set +# CONFIG_NET_CLS_BPF is not set +# CONFIG_NET_CLS_FLOWER is not set +# CONFIG_NET_CLS_MATCHALL is not set +CONFIG_NET_EMATCH=y +CONFIG_NET_EMATCH_STACK=32 +# CONFIG_NET_EMATCH_CMP is not set +# CONFIG_NET_EMATCH_NBYTE is not set +# CONFIG_NET_EMATCH_U32 is not set +# CONFIG_NET_EMATCH_META is not set +# CONFIG_NET_EMATCH_TEXT is not set +CONFIG_NET_CLS_ACT=y +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_SAMPLE is not set +# CONFIG_NET_ACT_IPT is not set +# CONFIG_NET_ACT_NAT is not set +# CONFIG_NET_ACT_PEDIT is not set +# CONFIG_NET_ACT_SIMP is not set +# CONFIG_NET_ACT_SKBEDIT is not set +# CONFIG_NET_ACT_CSUM is not set +# CONFIG_NET_ACT_VLAN is not set +# CONFIG_NET_ACT_BPF is not set +# CONFIG_NET_ACT_SKBMOD is not set +# CONFIG_NET_ACT_IFE is not set +# CONFIG_NET_ACT_TUNNEL_KEY is not set +CONFIG_NET_SCH_FIFO=y +# CONFIG_DCB is not set +CONFIG_DNS_RESOLVER=y +# CONFIG_BATMAN_ADV is not set +# CONFIG_OPENVSWITCH is not set +# CONFIG_VSOCKETS is not set +# CONFIG_NETLINK_DIAG is not set +# CONFIG_MPLS is not set +# CONFIG_NET_NSH is not set +# CONFIG_HSR is not set +# CONFIG_NET_SWITCHDEV is not set +# CONFIG_NET_L3_MASTER_DEV is not set +# CONFIG_NET_NCSI is not set +CONFIG_RPS=y +CONFIG_RFS_ACCEL=y +CONFIG_XPS=y +# CONFIG_CGROUP_NET_PRIO is not set +# CONFIG_CGROUP_NET_CLASSID is not set +CONFIG_NET_RX_BUSY_POLL=y +CONFIG_BQL=y +# CONFIG_BPF_JIT is not set +CONFIG_NET_FLOW_LIMIT=y + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_NET_TCPPROBE is not set +# CONFIG_NET_DROP_MONITOR is not set +CONFIG_HAMRADIO=y + +# +# Packet Radio protocols +# +# CONFIG_AX25 is not set +# CONFIG_CAN is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_AF_KCM is not set +# CONFIG_STREAM_PARSER is not set +CONFIG_FIB_RULES=y +CONFIG_WIRELESS=y +CONFIG_CFG80211=y +# CONFIG_NL80211_TESTMODE is not set +# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set +CONFIG_CFG80211_DEFAULT_PS=y +# CONFIG_CFG80211_DEBUGFS is not set +# CONFIG_CFG80211_INTERNAL_REGDB is not set +CONFIG_CFG80211_CRDA_SUPPORT=y +# CONFIG_CFG80211_WEXT is not set +# CONFIG_LIB80211 is not set +CONFIG_MAC80211=y +CONFIG_MAC80211_HAS_RC=y +CONFIG_MAC80211_RC_MINSTREL=y +CONFIG_MAC80211_RC_MINSTREL_HT=y +# CONFIG_MAC80211_RC_MINSTREL_VHT is not set +CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y +CONFIG_MAC80211_RC_DEFAULT="minstrel_ht" +# CONFIG_MAC80211_MESH is not set +CONFIG_MAC80211_LEDS=y +# CONFIG_MAC80211_DEBUGFS is not set +# CONFIG_MAC80211_MESSAGE_TRACING is not set +# CONFIG_MAC80211_DEBUG_MENU is not set +CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 +# CONFIG_WIMAX is not set +CONFIG_RFKILL=y +CONFIG_RFKILL_LEDS=y +CONFIG_RFKILL_INPUT=y +# CONFIG_NET_9P is not set +# CONFIG_CAIF is not set +# CONFIG_CEPH_LIB is not set +# CONFIG_NFC is not set +# CONFIG_PSAMPLE is not set +# CONFIG_NET_IFE is not set +# CONFIG_LWTUNNEL is not set +CONFIG_DST_CACHE=y +CONFIG_GRO_CELLS=y +# CONFIG_NET_DEVLINK is not set +CONFIG_MAY_USE_DEVLINK=y +CONFIG_HAVE_EBPF_JIT=y + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER=y +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_FW_LOADER_USER_HELPER_FALLBACK is not set +CONFIG_ALLOW_DEV_COREDUMP=y +# CONFIG_DEBUG_DRIVER is not set +CONFIG_DEBUG_DEVRES=y +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set +# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set +# CONFIG_SYS_HYPERVISOR is not set +# CONFIG_GENERIC_CPU_DEVICES is not set +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_CPU_VULNERABILITIES=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_DMA_SHARED_BUFFER=y +# CONFIG_DMA_FENCE_TRACE is not set + +# +# Bus devices +# +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +# CONFIG_MTD is not set +# CONFIG_OF is not set +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y +# CONFIG_PARPORT is not set +CONFIG_PNP=y +CONFIG_PNP_DEBUG_MESSAGES=y + +# +# Protocols +# +CONFIG_PNPACPI=y +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_NULL_BLK is not set +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set +# CONFIG_BLK_DEV_DAC960 is not set +# CONFIG_BLK_DEV_UMEM is not set +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 +CONFIG_BLK_DEV_CRYPTOLOOP=y +# CONFIG_BLK_DEV_DRBD is not set +# CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_SKD is not set +# CONFIG_BLK_DEV_SX8 is not set +# CONFIG_BLK_DEV_RAM is not set +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_VIRTIO_BLK=y +# CONFIG_VIRTIO_BLK_SCSI is not set +# CONFIG_BLK_DEV_RBD is not set +# CONFIG_BLK_DEV_RSXX is not set +# CONFIG_BLK_DEV_NVME is not set +# CONFIG_NVME_FC is not set + +# +# Misc devices +# +# CONFIG_SENSORS_LIS3LV02D is not set +# CONFIG_AD525X_DPOT is not set +# CONFIG_DUMMY_IRQ is not set +# CONFIG_IBM_ASM is not set +# CONFIG_PHANTOM is not set +# CONFIG_SGI_IOC4 is not set +# CONFIG_TIFM_CORE is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_HP_ILO is not set +# CONFIG_APDS9802ALS is not set +# CONFIG_ISL29003 is not set +# CONFIG_ISL29020 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_SENSORS_BH1770 is not set +# CONFIG_SENSORS_APDS990X is not set +# CONFIG_HMC6352 is not set +# CONFIG_DS1682 is not set +# CONFIG_USB_SWITCH_FSA9480 is not set +# CONFIG_SRAM is not set +# CONFIG_PCI_ENDPOINT_TEST is not set +# CONFIG_C2PORT is not set + +# +# EEPROM support +# +# CONFIG_EEPROM_AT24 is not set +# CONFIG_EEPROM_LEGACY is not set +# CONFIG_EEPROM_MAX6875 is not set +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_EEPROM_IDT_89HPESX is not set +# CONFIG_CB710_CORE is not set + +# +# Texas Instruments shared transport line discipline +# +# CONFIG_SENSORS_LIS3_I2C is not set + +# +# Altera FPGA firmware download module +# +# CONFIG_ALTERA_STAPL is not set +# CONFIG_INTEL_MEI is not set +# CONFIG_INTEL_MEI_ME is not set +# CONFIG_INTEL_MEI_TXE is not set +# CONFIG_VMWARE_VMCI is not set + +# +# Intel MIC Bus Driver +# +# CONFIG_INTEL_MIC_BUS is not set + +# +# SCIF Bus Driver +# +# CONFIG_SCIF_BUS is not set + +# +# VOP Bus Driver +# +# CONFIG_VOP_BUS is not set + +# +# Intel MIC Host Driver +# + +# +# Intel MIC Card Driver +# + +# +# SCIF Driver +# + +# +# Intel MIC Coprocessor State Management (COSM) Drivers +# + +# +# VOP Driver +# +# CONFIG_GENWQE is not set +# CONFIG_ECHO is not set +# CONFIG_CXL_BASE is not set +# CONFIG_CXL_AFU_DRIVER_OPS is not set +# CONFIG_CXL_LIB is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +CONFIG_SCSI_MOD=y +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +# CONFIG_SCSI_NETLINK is not set +# CONFIG_SCSI_MQ_DEFAULT is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +CONFIG_BLK_DEV_SR=y +CONFIG_BLK_DEV_SR_VENDOR=y +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set +CONFIG_SCSI_CONSTANTS=y +# CONFIG_SCSI_LOGGING is not set +# CONFIG_SCSI_SCAN_ASYNC is not set + +# +# SCSI Transports +# +CONFIG_SCSI_SPI_ATTRS=y +# CONFIG_SCSI_FC_ATTRS is not set +# CONFIG_SCSI_ISCSI_ATTRS is not set +# CONFIG_SCSI_SAS_ATTRS is not set +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set +# CONFIG_SCSI_DH is not set +# CONFIG_SCSI_OSD_INITIATOR is not set +CONFIG_ATA=y +# CONFIG_ATA_NONSTANDARD is not set +CONFIG_ATA_VERBOSE_ERROR=y +CONFIG_ATA_ACPI=y +# CONFIG_SATA_ZPODD is not set +CONFIG_SATA_PMP=y + +# +# Controllers with non-SFF native interface +# +CONFIG_SATA_AHCI=y +# CONFIG_SATA_AHCI_PLATFORM is not set +# CONFIG_SATA_INIC162X is not set +# CONFIG_SATA_ACARD_AHCI is not set +# CONFIG_SATA_SIL24 is not set +CONFIG_ATA_SFF=y + +# +# SFF controllers with custom DMA interface +# +# CONFIG_PDC_ADMA is not set +# CONFIG_SATA_QSTOR is not set +# CONFIG_SATA_SX4 is not set +CONFIG_ATA_BMDMA=y + +# +# SATA SFF controllers with BMDMA +# +CONFIG_ATA_PIIX=y +# CONFIG_SATA_DWC is not set +# CONFIG_SATA_MV is not set +# CONFIG_SATA_NV is not set +# CONFIG_SATA_PROMISE is not set +# CONFIG_SATA_SIL is not set +# CONFIG_SATA_SIS is not set +# CONFIG_SATA_SVW is not set +# CONFIG_SATA_ULI is not set +# CONFIG_SATA_VIA is not set +# CONFIG_SATA_VITESSE is not set + +# +# PATA SFF controllers with BMDMA +# +# CONFIG_PATA_ALI is not set +CONFIG_PATA_AMD=y +# CONFIG_PATA_ARTOP is not set +# CONFIG_PATA_ATIIXP is not set +# CONFIG_PATA_ATP867X is not set +# CONFIG_PATA_CMD64X is not set +# CONFIG_PATA_CYPRESS is not set +# CONFIG_PATA_EFAR is not set +# CONFIG_PATA_HPT366 is not set +# CONFIG_PATA_HPT37X is not set +# CONFIG_PATA_HPT3X2N is not set +# CONFIG_PATA_HPT3X3 is not set +# CONFIG_PATA_IT8213 is not set +# CONFIG_PATA_IT821X is not set +# CONFIG_PATA_JMICRON is not set +# CONFIG_PATA_MARVELL is not set +# CONFIG_PATA_NETCELL is not set +# CONFIG_PATA_NINJA32 is not set +# CONFIG_PATA_NS87415 is not set +CONFIG_PATA_OLDPIIX=y +# CONFIG_PATA_OPTIDMA is not set +# CONFIG_PATA_PDC2027X is not set +# CONFIG_PATA_PDC_OLD is not set +# CONFIG_PATA_RADISYS is not set +# CONFIG_PATA_RDC is not set +CONFIG_PATA_SCH=y +# CONFIG_PATA_SERVERWORKS is not set +# CONFIG_PATA_SIL680 is not set +# CONFIG_PATA_SIS is not set +# CONFIG_PATA_TOSHIBA is not set +# CONFIG_PATA_TRIFLEX is not set +# CONFIG_PATA_VIA is not set +# CONFIG_PATA_WINBOND is not set + +# +# PIO-only SFF controllers +# +# CONFIG_PATA_CMD640_PCI is not set +# CONFIG_PATA_MPIIX is not set +# CONFIG_PATA_NS87410 is not set +# CONFIG_PATA_OPTI is not set +# CONFIG_PATA_PCMCIA is not set +# CONFIG_PATA_RZ1000 is not set + +# +# Generic fallback / legacy drivers +# +# CONFIG_PATA_ACPI is not set +# CONFIG_ATA_GENERIC is not set +# CONFIG_PATA_LEGACY is not set +CONFIG_MD=y +CONFIG_BLK_DEV_MD=y +CONFIG_MD_AUTODETECT=y +# CONFIG_MD_LINEAR is not set +# CONFIG_MD_RAID0 is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID10 is not set +# CONFIG_MD_RAID456 is not set +# CONFIG_MD_MULTIPATH is not set +# CONFIG_MD_FAULTY is not set +# CONFIG_BCACHE is not set +CONFIG_BLK_DEV_DM_BUILTIN=y +CONFIG_BLK_DEV_DM=y +# CONFIG_DM_MQ_DEFAULT is not set +# CONFIG_DM_DEBUG is not set +# CONFIG_DM_CRYPT is not set +# CONFIG_DM_SNAPSHOT is not set +# CONFIG_DM_THIN_PROVISIONING is not set +# CONFIG_DM_CACHE is not set +# CONFIG_DM_ERA is not set +CONFIG_DM_MIRROR=y +# CONFIG_DM_LOG_USERSPACE is not set +# CONFIG_DM_RAID is not set +CONFIG_DM_ZERO=y +# CONFIG_DM_MULTIPATH is not set +# CONFIG_DM_DELAY is not set +# CONFIG_DM_UEVENT is not set +# CONFIG_DM_FLAKEY is not set +# CONFIG_DM_VERITY is not set +# CONFIG_DM_SWITCH is not set +# CONFIG_DM_LOG_WRITES is not set +# CONFIG_DM_INTEGRITY is not set +# CONFIG_TARGET_CORE is not set +# CONFIG_FUSION is not set + +# +# IEEE 1394 (FireWire) support +# +# CONFIG_FIREWIRE is not set +# CONFIG_FIREWIRE_NOSY is not set +CONFIG_MACINTOSH_DRIVERS=y +CONFIG_MAC_EMUMOUSEBTN=y +CONFIG_NETDEVICES=y +CONFIG_MII=y +CONFIG_NET_CORE=y +# CONFIG_BONDING is not set +# CONFIG_DUMMY is not set +# CONFIG_EQUALIZER is not set +# CONFIG_NET_FC is not set +# CONFIG_IFB is not set +# CONFIG_NET_TEAM is not set +# CONFIG_MACVLAN is not set +# CONFIG_VXLAN is not set +# CONFIG_MACSEC is not set +CONFIG_NETCONSOLE=y +CONFIG_NETPOLL=y +CONFIG_NET_POLL_CONTROLLER=y +CONFIG_TUN=y +# CONFIG_TUN_VNET_CROSS_LE is not set +CONFIG_VETH=y +CONFIG_VIRTIO_NET=y +# CONFIG_NLMON is not set +# CONFIG_ARCNET is not set + +# +# CAIF transport drivers +# + +# +# Distributed Switch Architecture drivers +# +CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_3COM=y +# CONFIG_PCMCIA_3C574 is not set +# CONFIG_PCMCIA_3C589 is not set +# CONFIG_VORTEX is not set +# CONFIG_TYPHOON is not set +CONFIG_NET_VENDOR_ADAPTEC=y +# CONFIG_ADAPTEC_STARFIRE is not set +CONFIG_NET_VENDOR_AGERE=y +# CONFIG_ET131X is not set +CONFIG_NET_VENDOR_ALACRITECH=y +# CONFIG_SLICOSS is not set +CONFIG_NET_VENDOR_ALTEON=y +# CONFIG_ACENIC is not set +# CONFIG_ALTERA_TSE is not set +CONFIG_NET_VENDOR_AMAZON=y +# CONFIG_ENA_ETHERNET is not set +CONFIG_NET_VENDOR_AMD=y +# CONFIG_AMD8111_ETH is not set +# CONFIG_PCNET32 is not set +# CONFIG_PCMCIA_NMCLAN is not set +# CONFIG_AMD_XGBE is not set +# CONFIG_AMD_XGBE_HAVE_ECC is not set +CONFIG_NET_VENDOR_AQUANTIA=y +# CONFIG_AQTION is not set +CONFIG_NET_VENDOR_ARC=y +CONFIG_NET_VENDOR_ATHEROS=y +# CONFIG_ATL2 is not set +# CONFIG_ATL1 is not set +# CONFIG_ATL1E is not set +# CONFIG_ATL1C is not set +# CONFIG_ALX is not set +# CONFIG_NET_VENDOR_AURORA is not set +CONFIG_NET_CADENCE=y +# CONFIG_MACB is not set +CONFIG_NET_VENDOR_BROADCOM=y +# CONFIG_B44 is not set +# CONFIG_BNX2 is not set +# CONFIG_CNIC is not set +CONFIG_TIGON3=y +CONFIG_TIGON3_HWMON=y +# CONFIG_BNX2X is not set +# CONFIG_BNXT is not set +CONFIG_NET_VENDOR_BROCADE=y +# CONFIG_BNA is not set +CONFIG_NET_VENDOR_CAVIUM=y +# CONFIG_THUNDER_NIC_PF is not set +# CONFIG_THUNDER_NIC_VF is not set +# CONFIG_THUNDER_NIC_BGX is not set +# CONFIG_THUNDER_NIC_RGX is not set +# CONFIG_LIQUIDIO is not set +# CONFIG_LIQUIDIO_VF is not set +CONFIG_NET_VENDOR_CHELSIO=y +# CONFIG_CHELSIO_T1 is not set +# CONFIG_CHELSIO_T3 is not set +# CONFIG_CHELSIO_T4 is not set +# CONFIG_CHELSIO_T4VF is not set +CONFIG_NET_VENDOR_CISCO=y +# CONFIG_ENIC is not set +# CONFIG_CX_ECAT is not set +# CONFIG_DNET is not set +CONFIG_NET_VENDOR_DEC=y +CONFIG_NET_TULIP=y +# CONFIG_DE2104X is not set +# CONFIG_TULIP is not set +# CONFIG_DE4X5 is not set +# CONFIG_WINBOND_840 is not set +# CONFIG_DM9102 is not set +# CONFIG_ULI526X is not set +# CONFIG_PCMCIA_XIRCOM is not set +CONFIG_NET_VENDOR_DLINK=y +# CONFIG_DL2K is not set +# CONFIG_SUNDANCE is not set +CONFIG_NET_VENDOR_EMULEX=y +# CONFIG_BE2NET is not set +CONFIG_NET_VENDOR_EZCHIP=y +CONFIG_NET_VENDOR_EXAR=y +# CONFIG_S2IO is not set +# CONFIG_VXGE is not set +CONFIG_NET_VENDOR_FUJITSU=y +# CONFIG_PCMCIA_FMVJ18X is not set +CONFIG_NET_VENDOR_HP=y +# CONFIG_HP100 is not set +CONFIG_NET_VENDOR_HUAWEI=y +# CONFIG_HINIC is not set +CONFIG_NET_VENDOR_INTEL=y +CONFIG_E100=y +CONFIG_E1000=y +CONFIG_E1000E=y +CONFIG_E1000E_HWTS=y +# CONFIG_IGB is not set +# CONFIG_IGBVF is not set +# CONFIG_IXGB is not set +# CONFIG_IXGBE is not set +# CONFIG_IXGBEVF is not set +# CONFIG_I40E is not set +# CONFIG_I40EVF is not set +# CONFIG_FM10K is not set +CONFIG_NET_VENDOR_I825XX=y +# CONFIG_JME is not set +CONFIG_NET_VENDOR_MARVELL=y +# CONFIG_MVMDIO is not set +# CONFIG_SKGE is not set +CONFIG_SKY2=y +# CONFIG_SKY2_DEBUG is not set +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MLX4_EN is not set +# CONFIG_MLX4_CORE is not set +# CONFIG_MLX5_CORE is not set +# CONFIG_MLXSW_CORE is not set +# CONFIG_MLXFW is not set +CONFIG_NET_VENDOR_MICREL=y +# CONFIG_KS8842 is not set +# CONFIG_KS8851_MLL is not set +# CONFIG_KSZ884X_PCI is not set +CONFIG_NET_VENDOR_MYRI=y +# CONFIG_MYRI10GE is not set +# CONFIG_FEALNX is not set +CONFIG_NET_VENDOR_NATSEMI=y +# CONFIG_NATSEMI is not set +# CONFIG_NS83820 is not set +CONFIG_NET_VENDOR_NETRONOME=y +# CONFIG_NFP is not set +CONFIG_NET_VENDOR_8390=y +# CONFIG_PCMCIA_AXNET is not set +# CONFIG_NE2K_PCI is not set +# CONFIG_PCMCIA_PCNET is not set +CONFIG_NET_VENDOR_NVIDIA=y +CONFIG_FORCEDETH=y +CONFIG_NET_VENDOR_OKI=y +# CONFIG_ETHOC is not set +CONFIG_NET_PACKET_ENGINE=y +# CONFIG_HAMACHI is not set +# CONFIG_YELLOWFIN is not set +CONFIG_NET_VENDOR_QLOGIC=y +# CONFIG_QLA3XXX is not set +# CONFIG_QLCNIC is not set +# CONFIG_QLGE is not set +# CONFIG_NETXEN_NIC is not set +# CONFIG_QED is not set +CONFIG_NET_VENDOR_QUALCOMM=y +# CONFIG_QCOM_EMAC is not set +# CONFIG_RMNET is not set +CONFIG_NET_VENDOR_REALTEK=y +# CONFIG_8139CP is not set +CONFIG_8139TOO=y +CONFIG_8139TOO_PIO=y +# CONFIG_8139TOO_TUNE_TWISTER is not set +# CONFIG_8139TOO_8129 is not set +# CONFIG_8139_OLD_RX_RESET is not set +CONFIG_R8169=y +CONFIG_NET_VENDOR_RENESAS=y +CONFIG_NET_VENDOR_RDC=y +# CONFIG_R6040 is not set +CONFIG_NET_VENDOR_ROCKER=y +CONFIG_NET_VENDOR_SAMSUNG=y +# CONFIG_SXGBE_ETH is not set +CONFIG_NET_VENDOR_SEEQ=y +CONFIG_NET_VENDOR_SILAN=y +# CONFIG_SC92031 is not set +CONFIG_NET_VENDOR_SIS=y +# CONFIG_SIS900 is not set +# CONFIG_SIS190 is not set +CONFIG_NET_VENDOR_SOLARFLARE=y +# CONFIG_SFC is not set +# CONFIG_SFC_FALCON is not set +CONFIG_NET_VENDOR_SMSC=y +# CONFIG_PCMCIA_SMC91C92 is not set +# CONFIG_EPIC100 is not set +# CONFIG_SMSC911X is not set +# CONFIG_SMSC9420 is not set +CONFIG_NET_VENDOR_STMICRO=y +# CONFIG_STMMAC_ETH is not set +CONFIG_NET_VENDOR_SUN=y +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNGEM is not set +# CONFIG_CASSINI is not set +# CONFIG_NIU is not set +CONFIG_NET_VENDOR_TEHUTI=y +# CONFIG_TEHUTI is not set +CONFIG_NET_VENDOR_TI=y +# CONFIG_TI_CPSW_ALE is not set +# CONFIG_TLAN is not set +CONFIG_NET_VENDOR_VIA=y +# CONFIG_VIA_RHINE is not set +# CONFIG_VIA_VELOCITY is not set +CONFIG_NET_VENDOR_WIZNET=y +# CONFIG_WIZNET_W5100 is not set +# CONFIG_WIZNET_W5300 is not set +CONFIG_NET_VENDOR_XIRCOM=y +# CONFIG_PCMCIA_XIRC2PS is not set +CONFIG_NET_VENDOR_SYNOPSYS=y +# CONFIG_DWC_XLGMAC is not set +CONFIG_FDDI=y +# CONFIG_DEFXX is not set +# CONFIG_SKFP is not set +# CONFIG_HIPPI is not set +# CONFIG_NET_SB1000 is not set +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_BUS=y +# CONFIG_MDIO_BITBANG is not set +# CONFIG_MDIO_THUNDER is not set +CONFIG_PHYLIB=y +# CONFIG_LED_TRIGGER_PHY is not set + +# +# MII PHY device drivers +# +# CONFIG_AMD_PHY is not set +# CONFIG_AQUANTIA_PHY is not set +# CONFIG_AT803X_PHY is not set +# CONFIG_BCM7XXX_PHY is not set +# CONFIG_BCM87XX_PHY is not set +# CONFIG_BROADCOM_PHY is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_CORTINA_PHY is not set +# CONFIG_DAVICOM_PHY is not set +# CONFIG_DP83848_PHY is not set +# CONFIG_DP83867_PHY is not set +# CONFIG_FIXED_PHY is not set +# CONFIG_ICPLUS_PHY is not set +# CONFIG_INTEL_XWAY_PHY is not set +# CONFIG_LSI_ET1011C_PHY is not set +# CONFIG_LXT_PHY is not set +# CONFIG_MARVELL_PHY is not set +# CONFIG_MARVELL_10G_PHY is not set +# CONFIG_MICREL_PHY is not set +# CONFIG_MICROCHIP_PHY is not set +# CONFIG_MICROSEMI_PHY is not set +# CONFIG_NATIONAL_PHY is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_REALTEK_PHY is not set +# CONFIG_ROCKCHIP_PHY is not set +# CONFIG_SMSC_PHY is not set +# CONFIG_STE10XP is not set +# CONFIG_TERANETICS_PHY is not set +# CONFIG_VITESSE_PHY is not set +# CONFIG_XILINX_GMII2RGMII is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +CONFIG_USB_NET_DRIVERS=y +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_RTL8152 is not set +# CONFIG_USB_LAN78XX is not set +# CONFIG_USB_USBNET is not set +# CONFIG_USB_HSO is not set +# CONFIG_USB_IPHETH is not set +CONFIG_WLAN=y +CONFIG_WLAN_VENDOR_ADMTEK=y +# CONFIG_ADM8211 is not set +CONFIG_WLAN_VENDOR_ATH=y +# CONFIG_ATH_DEBUG is not set +# CONFIG_ATH5K is not set +# CONFIG_ATH5K_PCI is not set +# CONFIG_ATH9K is not set +# CONFIG_ATH9K_HTC is not set +# CONFIG_CARL9170 is not set +# CONFIG_ATH6KL is not set +# CONFIG_AR5523 is not set +# CONFIG_WIL6210 is not set +# CONFIG_ATH10K is not set +# CONFIG_WCN36XX is not set +CONFIG_WLAN_VENDOR_ATMEL=y +# CONFIG_ATMEL is not set +# CONFIG_AT76C50X_USB is not set +CONFIG_WLAN_VENDOR_BROADCOM=y +# CONFIG_B43 is not set +# CONFIG_B43LEGACY is not set +# CONFIG_BRCMSMAC is not set +# CONFIG_BRCMFMAC is not set +CONFIG_WLAN_VENDOR_CISCO=y +# CONFIG_AIRO is not set +# CONFIG_AIRO_CS is not set +CONFIG_WLAN_VENDOR_INTEL=y +# CONFIG_IPW2100 is not set +# CONFIG_IPW2200 is not set +# CONFIG_IWL4965 is not set +# CONFIG_IWL3945 is not set +# CONFIG_IWLWIFI is not set +CONFIG_WLAN_VENDOR_INTERSIL=y +# CONFIG_HOSTAP is not set +# CONFIG_HERMES is not set +# CONFIG_P54_COMMON is not set +# CONFIG_PRISM54 is not set +CONFIG_WLAN_VENDOR_MARVELL=y +# CONFIG_LIBERTAS is not set +# CONFIG_LIBERTAS_THINFIRM is not set +# CONFIG_MWIFIEX is not set +# CONFIG_MWL8K is not set +CONFIG_WLAN_VENDOR_MEDIATEK=y +# CONFIG_MT7601U is not set +CONFIG_WLAN_VENDOR_RALINK=y +# CONFIG_RT2X00 is not set +CONFIG_WLAN_VENDOR_REALTEK=y +# CONFIG_RTL8180 is not set +# CONFIG_RTL8187 is not set +CONFIG_RTL_CARDS=y +# CONFIG_RTL8192CE is not set +# CONFIG_RTL8192SE is not set +# CONFIG_RTL8192DE is not set +# CONFIG_RTL8723AE is not set +# CONFIG_RTL8723BE is not set +# CONFIG_RTL8188EE is not set +# CONFIG_RTL8192EE is not set +# CONFIG_RTL8821AE is not set +# CONFIG_RTL8192CU is not set +# CONFIG_RTL8XXXU is not set +CONFIG_WLAN_VENDOR_RSI=y +# CONFIG_RSI_91X is not set +CONFIG_WLAN_VENDOR_ST=y +# CONFIG_CW1200 is not set +CONFIG_WLAN_VENDOR_TI=y +# CONFIG_WL1251 is not set +# CONFIG_WL12XX is not set +# CONFIG_WL18XX is not set +# CONFIG_WLCORE is not set +CONFIG_WLAN_VENDOR_ZYDAS=y +# CONFIG_USB_ZD1201 is not set +# CONFIG_ZD1211RW is not set +CONFIG_WLAN_VENDOR_QUANTENNA=y +# CONFIG_QTNFMAC_PEARL_PCIE is not set +# CONFIG_PCMCIA_RAYCS is not set +# CONFIG_PCMCIA_WL3501 is not set +# CONFIG_MAC80211_HWSIM is not set +# CONFIG_USB_NET_RNDIS_WLAN is not set + +# +# Enable WiMAX (Networking options) to see the WiMAX drivers +# +# CONFIG_WAN is not set +# CONFIG_VMXNET3 is not set +# CONFIG_FUJITSU_ES is not set +# CONFIG_ISDN is not set +# CONFIG_NVM is not set + +# +# Input device support +# +CONFIG_INPUT=y +CONFIG_INPUT_LEDS=y +CONFIG_INPUT_FF_MEMLESS=y +CONFIG_INPUT_POLLDEV=y +CONFIG_INPUT_SPARSEKMAP=y +# CONFIG_INPUT_MATRIXKMAP is not set + +# +# Userland interfaces +# +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +# CONFIG_KEYBOARD_ADP5588 is not set +# CONFIG_KEYBOARD_ADP5589 is not set +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_QT1070 is not set +# CONFIG_KEYBOARD_QT2160 is not set +# CONFIG_KEYBOARD_DLINK_DIR685 is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_TCA6416 is not set +# CONFIG_KEYBOARD_TCA8418 is not set +# CONFIG_KEYBOARD_LM8323 is not set +# CONFIG_KEYBOARD_LM8333 is not set +# CONFIG_KEYBOARD_MAX7359 is not set +# CONFIG_KEYBOARD_MCS is not set +# CONFIG_KEYBOARD_MPR121 is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_OPENCORES is not set +# CONFIG_KEYBOARD_SAMSUNG is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set +# CONFIG_KEYBOARD_XTKBD is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_BYD=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS=y +CONFIG_MOUSE_PS2_CYPRESS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_ELANTECH is not set +# CONFIG_MOUSE_PS2_SENTELIC is not set +# CONFIG_MOUSE_PS2_TOUCHKIT is not set +CONFIG_MOUSE_PS2_FOCALTECH=y +CONFIG_MOUSE_PS2_SMBUS=y +# CONFIG_MOUSE_SERIAL is not set +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_CYAPA is not set +# CONFIG_MOUSE_ELAN_I2C is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_SYNAPTICS_I2C is not set +# CONFIG_MOUSE_SYNAPTICS_USB is not set +CONFIG_INPUT_JOYSTICK=y +# CONFIG_JOYSTICK_ANALOG is not set +# CONFIG_JOYSTICK_A3D is not set +# CONFIG_JOYSTICK_ADI is not set +# CONFIG_JOYSTICK_COBRA is not set +# CONFIG_JOYSTICK_GF2K is not set +# CONFIG_JOYSTICK_GRIP is not set +# CONFIG_JOYSTICK_GRIP_MP is not set +# CONFIG_JOYSTICK_GUILLEMOT is not set +# CONFIG_JOYSTICK_INTERACT is not set +# CONFIG_JOYSTICK_SIDEWINDER is not set +# CONFIG_JOYSTICK_TMDC is not set +# CONFIG_JOYSTICK_IFORCE is not set +# CONFIG_JOYSTICK_WARRIOR is not set +# CONFIG_JOYSTICK_MAGELLAN is not set +# CONFIG_JOYSTICK_SPACEORB is not set +# CONFIG_JOYSTICK_SPACEBALL is not set +# CONFIG_JOYSTICK_STINGER is not set +# CONFIG_JOYSTICK_TWIDJOY is not set +# CONFIG_JOYSTICK_ZHENHUA is not set +# CONFIG_JOYSTICK_AS5011 is not set +# CONFIG_JOYSTICK_JOYDUMP is not set +# CONFIG_JOYSTICK_XPAD is not set +CONFIG_INPUT_TABLET=y +# CONFIG_TABLET_USB_ACECAD is not set +# CONFIG_TABLET_USB_AIPTEK is not set +# CONFIG_TABLET_USB_GTCO is not set +# CONFIG_TABLET_USB_HANWANG is not set +# CONFIG_TABLET_USB_KBTAB is not set +# CONFIG_TABLET_USB_PEGASUS is not set +# CONFIG_TABLET_SERIAL_WACOM4 is not set +CONFIG_INPUT_TOUCHSCREEN=y +CONFIG_TOUCHSCREEN_PROPERTIES=y +# CONFIG_TOUCHSCREEN_AD7879 is not set +# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set +# CONFIG_TOUCHSCREEN_BU21013 is not set +# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set +# CONFIG_TOUCHSCREEN_CYTTSP4_CORE is not set +# CONFIG_TOUCHSCREEN_DYNAPRO is not set +# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set +# CONFIG_TOUCHSCREEN_EETI is not set +# CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set +# CONFIG_TOUCHSCREEN_FUJITSU is not set +# CONFIG_TOUCHSCREEN_ILI210X is not set +# CONFIG_TOUCHSCREEN_GUNZE is not set +# CONFIG_TOUCHSCREEN_EKTF2127 is not set +# CONFIG_TOUCHSCREEN_ELAN is not set +# CONFIG_TOUCHSCREEN_ELO is not set +# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set +# CONFIG_TOUCHSCREEN_WACOM_I2C is not set +# CONFIG_TOUCHSCREEN_MAX11801 is not set +# CONFIG_TOUCHSCREEN_MCS5000 is not set +# CONFIG_TOUCHSCREEN_MMS114 is not set +# CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set +# CONFIG_TOUCHSCREEN_MTOUCH is not set +# CONFIG_TOUCHSCREEN_INEXIO is not set +# CONFIG_TOUCHSCREEN_MK712 is not set +# CONFIG_TOUCHSCREEN_PENMOUNT is not set +# CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set +# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set +# CONFIG_TOUCHSCREEN_TOUCHWIN is not set +# CONFIG_TOUCHSCREEN_PIXCIR is not set +# CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set +# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set +# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set +# CONFIG_TOUCHSCREEN_TSC_SERIO is not set +# CONFIG_TOUCHSCREEN_TSC2004 is not set +# CONFIG_TOUCHSCREEN_TSC2007 is not set +# CONFIG_TOUCHSCREEN_SILEAD is not set +# CONFIG_TOUCHSCREEN_ST1232 is not set +# CONFIG_TOUCHSCREEN_STMFTS is not set +# CONFIG_TOUCHSCREEN_SX8654 is not set +# CONFIG_TOUCHSCREEN_TPS6507X is not set +# CONFIG_TOUCHSCREEN_ZET6223 is not set +# CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set +CONFIG_INPUT_MISC=y +# CONFIG_INPUT_AD714X is not set +# CONFIG_INPUT_BMA150 is not set +# CONFIG_INPUT_E3X0_BUTTON is not set +# CONFIG_INPUT_PCSPKR is not set +# CONFIG_INPUT_MMA8450 is not set +# CONFIG_INPUT_APANEL is not set +# CONFIG_INPUT_ATLAS_BTNS is not set +# CONFIG_INPUT_ATI_REMOTE2 is not set +# CONFIG_INPUT_KEYSPAN_REMOTE is not set +# CONFIG_INPUT_KXTJ9 is not set +# CONFIG_INPUT_POWERMATE is not set +# CONFIG_INPUT_YEALINK is not set +# CONFIG_INPUT_CM109 is not set +# CONFIG_INPUT_UINPUT is not set +# CONFIG_INPUT_PCF8574 is not set +# CONFIG_INPUT_ADXL34X is not set +# CONFIG_INPUT_IMS_PCU is not set +# CONFIG_INPUT_CMA3000 is not set +# CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set +# CONFIG_INPUT_DRV2665_HAPTICS is not set +# CONFIG_INPUT_DRV2667_HAPTICS is not set +# CONFIG_RMI4_CORE is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y +CONFIG_SERIO_I8042=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_PCIPS2 is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_SERIO_ALTERA_PS2 is not set +# CONFIG_SERIO_PS2MULT is not set +# CONFIG_SERIO_ARC_PS2 is not set +# CONFIG_USERIO is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_TTY=y +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_VT_CONSOLE_SLEEP=y +CONFIG_HW_CONSOLE=y +CONFIG_VT_HW_CONSOLE_BINDING=y +CONFIG_UNIX98_PTYS=y +# CONFIG_LEGACY_PTYS is not set +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_ROCKETPORT is not set +# CONFIG_CYCLADES is not set +# CONFIG_MOXA_INTELLIO is not set +# CONFIG_MOXA_SMARTIO is not set +# CONFIG_SYNCLINK is not set +# CONFIG_SYNCLINKMP is not set +# CONFIG_SYNCLINK_GT is not set +# CONFIG_NOZOMI is not set +# CONFIG_ISI is not set +# CONFIG_N_HDLC is not set +# CONFIG_N_GSM is not set +# CONFIG_TRACE_SINK is not set +CONFIG_DEVMEM=y +# CONFIG_DEVKMEM is not set + +# +# Serial drivers +# +CONFIG_SERIAL_EARLYCON=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_DEPRECATED_OPTIONS=y +CONFIG_SERIAL_8250_PNP=y +# CONFIG_SERIAL_8250_FINTEK is not set +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_DMA=y +CONFIG_SERIAL_8250_PCI=y +CONFIG_SERIAL_8250_EXAR=y +# CONFIG_SERIAL_8250_CS is not set +CONFIG_SERIAL_8250_NR_UARTS=32 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +CONFIG_SERIAL_8250_DETECT_IRQ=y +CONFIG_SERIAL_8250_RSA=y +# CONFIG_SERIAL_8250_FSL is not set +# CONFIG_SERIAL_8250_DW is not set +# CONFIG_SERIAL_8250_RT288X is not set +CONFIG_SERIAL_8250_LPSS=y +CONFIG_SERIAL_8250_MID=y +# CONFIG_SERIAL_8250_MOXA is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_UARTLITE is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +# CONFIG_SERIAL_JSM is not set +# CONFIG_SERIAL_SCCNXP is not set +# CONFIG_SERIAL_SC16IS7XX is not set +# CONFIG_SERIAL_ALTERA_JTAGUART is not set +# CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_ARC is not set +# CONFIG_SERIAL_RP2 is not set +# CONFIG_SERIAL_FSL_LPUART is not set +# CONFIG_SERIAL_DEV_BUS is not set +CONFIG_HVC_DRIVER=y +CONFIG_VIRTIO_CONSOLE=y +# CONFIG_IPMI_HANDLER is not set +CONFIG_HW_RANDOM=y +# CONFIG_HW_RANDOM_TIMERIOMEM is not set +# CONFIG_HW_RANDOM_INTEL is not set +# CONFIG_HW_RANDOM_AMD is not set +CONFIG_HW_RANDOM_VIA=y +# CONFIG_HW_RANDOM_VIRTIO is not set +CONFIG_NVRAM=y +# CONFIG_R3964 is not set +# CONFIG_APPLICOM is not set + +# +# PCMCIA character devices +# +# CONFIG_SYNCLINK_CS is not set +# CONFIG_CARDMAN_4000 is not set +# CONFIG_CARDMAN_4040 is not set +# CONFIG_SCR24X is not set +# CONFIG_IPWIRELESS is not set +# CONFIG_MWAVE is not set +# CONFIG_RAW_DRIVER is not set +CONFIG_HPET=y +# CONFIG_HPET_MMAP is not set +# CONFIG_HANGCHECK_TIMER is not set +# CONFIG_TCG_TPM is not set +# CONFIG_TELCLOCK is not set +CONFIG_DEVPORT=y +# CONFIG_XILLYBUS is not set + +# +# I2C support +# +CONFIG_I2C=y +CONFIG_ACPI_I2C_OPREGION=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_MUX=y + +# +# Multiplexer I2C Chip support +# +# CONFIG_I2C_MUX_LTC4306 is not set +CONFIG_I2C_MUX_PCA9541=y +# CONFIG_I2C_MUX_REG is not set +# CONFIG_I2C_MUX_MLXCPLD is not set +CONFIG_I2C_HELPER_AUTO=y +CONFIG_I2C_SMBUS=y +CONFIG_I2C_ALGOBIT=y + +# +# I2C Hardware Bus support +# + +# +# PC SMBus host controller drivers +# +# CONFIG_I2C_ALI1535 is not set +# CONFIG_I2C_ALI1563 is not set +# CONFIG_I2C_ALI15X3 is not set +# CONFIG_I2C_AMD756 is not set +# CONFIG_I2C_AMD8111 is not set +CONFIG_I2C_I801=y +CONFIG_I2C_ISCH=m +CONFIG_I2C_ISMT=m +CONFIG_I2C_PIIX4=m +# CONFIG_I2C_NFORCE2 is not set +# CONFIG_I2C_SIS5595 is not set +# CONFIG_I2C_SIS630 is not set +# CONFIG_I2C_SIS96X is not set +# CONFIG_I2C_VIA is not set +# CONFIG_I2C_VIAPRO is not set + +# +# ACPI drivers +# +# CONFIG_I2C_SCMI is not set + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_DESIGNWARE_PLATFORM is not set +# CONFIG_I2C_DESIGNWARE_PCI is not set +# CONFIG_I2C_EMEV2 is not set +# CONFIG_I2C_OCORES is not set +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_PXA_PCI is not set +# CONFIG_I2C_SIMTEC is not set +# CONFIG_I2C_XILINX is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_DIOLAN_U2C is not set +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_ROBOTFUZZ_OSIF is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_MLXCPLD is not set +# CONFIG_I2C_STUB is not set +# CONFIG_I2C_SLAVE is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_SPI is not set +# CONFIG_SPMI is not set +# CONFIG_HSI is not set +CONFIG_PPS=y +# CONFIG_PPS_DEBUG is not set + +# +# PPS clients support +# +# CONFIG_PPS_CLIENT_KTIMER is not set +# CONFIG_PPS_CLIENT_LDISC is not set +# CONFIG_PPS_CLIENT_GPIO is not set + +# +# PPS generators support +# + +# +# PTP clock support +# +CONFIG_PTP_1588_CLOCK=y + +# +# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. +# +# CONFIG_GPIOLIB is not set +# CONFIG_W1 is not set +# CONFIG_POWER_AVS is not set +# CONFIG_POWER_RESET is not set +CONFIG_POWER_SUPPLY=y +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_PDA_POWER is not set +# CONFIG_TEST_POWER is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2781 is not set +# CONFIG_BATTERY_DS2782 is not set +# CONFIG_BATTERY_SBS is not set +# CONFIG_CHARGER_SBS is not set +# CONFIG_BATTERY_BQ27XXX is not set +# CONFIG_BATTERY_MAX17040 is not set +# CONFIG_BATTERY_MAX17042 is not set +# CONFIG_CHARGER_MAX8903 is not set +# CONFIG_CHARGER_LP8727 is not set +# CONFIG_CHARGER_BQ2415X is not set +# CONFIG_CHARGER_SMB347 is not set +# CONFIG_BATTERY_GAUGE_LTC2941 is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_HWMON_DEBUG_CHIP is not set + +# +# Native drivers +# +# CONFIG_SENSORS_ABITUGURU is not set +# CONFIG_SENSORS_ABITUGURU3 is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7410 is not set +# CONFIG_SENSORS_ADT7411 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7475 is not set +# CONFIG_SENSORS_ASC7621 is not set +# CONFIG_SENSORS_K8TEMP is not set +# CONFIG_SENSORS_K10TEMP is not set +# CONFIG_SENSORS_FAM15H_POWER is not set +# CONFIG_SENSORS_APPLESMC is not set +# CONFIG_SENSORS_ASB100 is not set +# CONFIG_SENSORS_ASPEED is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS620 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_DELL_SMM is not set +# CONFIG_SENSORS_I5K_AMB is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_FSCHMD is not set +# CONFIG_SENSORS_FTSTEUTATES is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_G760A is not set +# CONFIG_SENSORS_G762 is not set +# CONFIG_SENSORS_HIH6130 is not set +# CONFIG_SENSORS_I5500 is not set +# CONFIG_SENSORS_CORETEMP is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_JC42 is not set +# CONFIG_SENSORS_POWR1220 is not set +# CONFIG_SENSORS_LINEAGE is not set +# CONFIG_SENSORS_LTC2945 is not set +# CONFIG_SENSORS_LTC2990 is not set +# CONFIG_SENSORS_LTC4151 is not set +# CONFIG_SENSORS_LTC4215 is not set +# CONFIG_SENSORS_LTC4222 is not set +# CONFIG_SENSORS_LTC4245 is not set +# CONFIG_SENSORS_LTC4260 is not set +# CONFIG_SENSORS_LTC4261 is not set +# CONFIG_SENSORS_MAX16065 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX1668 is not set +# CONFIG_SENSORS_MAX197 is not set +# CONFIG_SENSORS_MAX6639 is not set +# CONFIG_SENSORS_MAX6642 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_MAX6697 is not set +# CONFIG_SENSORS_MAX31790 is not set +# CONFIG_SENSORS_MCP3021 is not set +# CONFIG_SENSORS_TC654 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM73 is not set +# CONFIG_SENSORS_LM75 is not set +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +# CONFIG_SENSORS_LM95234 is not set +# CONFIG_SENSORS_LM95241 is not set +# CONFIG_SENSORS_LM95245 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_NTC_THERMISTOR is not set +# CONFIG_SENSORS_NCT6683 is not set +# CONFIG_SENSORS_NCT6775 is not set +# CONFIG_SENSORS_NCT7802 is not set +# CONFIG_SENSORS_NCT7904 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_PMBUS is not set +# CONFIG_SENSORS_SHT21 is not set +# CONFIG_SENSORS_SHT3x is not set +# CONFIG_SENSORS_SHTC1 is not set +# CONFIG_SENSORS_SIS5595 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_EMC1403 is not set +# CONFIG_SENSORS_EMC2103 is not set +# CONFIG_SENSORS_EMC6W201 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +# CONFIG_SENSORS_SCH56XX_COMMON is not set +# CONFIG_SENSORS_SCH5627 is not set +# CONFIG_SENSORS_SCH5636 is not set +# CONFIG_SENSORS_STTS751 is not set +# CONFIG_SENSORS_SMM665 is not set +# CONFIG_SENSORS_ADC128D818 is not set +# CONFIG_SENSORS_ADS1015 is not set +# CONFIG_SENSORS_ADS7828 is not set +# CONFIG_SENSORS_AMC6821 is not set +# CONFIG_SENSORS_INA209 is not set +# CONFIG_SENSORS_INA2XX is not set +# CONFIG_SENSORS_INA3221 is not set +# CONFIG_SENSORS_TC74 is not set +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_TMP102 is not set +# CONFIG_SENSORS_TMP103 is not set +# CONFIG_SENSORS_TMP108 is not set +# CONFIG_SENSORS_TMP401 is not set +# CONFIG_SENSORS_TMP421 is not set +# CONFIG_SENSORS_VIA_CPUTEMP is not set +# CONFIG_SENSORS_VIA686A is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_VT8231 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83795 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +# CONFIG_SENSORS_XGENE is not set + +# +# ACPI drivers +# +# CONFIG_SENSORS_ACPI_POWER is not set +# CONFIG_SENSORS_ATK0110 is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_WRITABLE_TRIPS=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set +# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set +# CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set +# CONFIG_THERMAL_GOV_FAIR_SHARE is not set +CONFIG_THERMAL_GOV_STEP_WISE=y +# CONFIG_THERMAL_GOV_BANG_BANG is not set +CONFIG_THERMAL_GOV_USER_SPACE=y +# CONFIG_THERMAL_GOV_POWER_ALLOCATOR is not set +# CONFIG_THERMAL_EMULATION is not set +# CONFIG_INTEL_POWERCLAMP is not set +CONFIG_X86_PKG_TEMP_THERMAL=m +# CONFIG_INTEL_SOC_DTS_THERMAL is not set + +# +# ACPI INT340X thermal drivers +# +# CONFIG_INT340X_THERMAL is not set +# CONFIG_INTEL_PCH_THERMAL is not set +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_CORE is not set +# CONFIG_WATCHDOG_NOWAYOUT is not set +CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y +# CONFIG_WATCHDOG_SYSFS is not set + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +# CONFIG_WDAT_WDT is not set +# CONFIG_XILINX_WATCHDOG is not set +# CONFIG_ZIIRAVE_WATCHDOG is not set +# CONFIG_CADENCE_WATCHDOG is not set +# CONFIG_DW_WATCHDOG is not set +# CONFIG_MAX63XX_WATCHDOG is not set +# CONFIG_ACQUIRE_WDT is not set +# CONFIG_ADVANTECH_WDT is not set +# CONFIG_ALIM1535_WDT is not set +# CONFIG_ALIM7101_WDT is not set +# CONFIG_F71808E_WDT is not set +# CONFIG_SP5100_TCO is not set +# CONFIG_SBC_FITPC2_WATCHDOG is not set +# CONFIG_EUROTECH_WDT is not set +# CONFIG_IB700_WDT is not set +# CONFIG_IBMASR is not set +# CONFIG_WAFER_WDT is not set +# CONFIG_I6300ESB_WDT is not set +# CONFIG_IE6XX_WDT is not set +# CONFIG_ITCO_WDT is not set +# CONFIG_IT8712F_WDT is not set +# CONFIG_IT87_WDT is not set +# CONFIG_HP_WATCHDOG is not set +# CONFIG_SC1200_WDT is not set +# CONFIG_PC87413_WDT is not set +# CONFIG_NV_TCO is not set +# CONFIG_60XX_WDT is not set +# CONFIG_CPU5_WDT is not set +# CONFIG_SMSC_SCH311X_WDT is not set +# CONFIG_SMSC37B787_WDT is not set +# CONFIG_VIA_WDT is not set +# CONFIG_W83627HF_WDT is not set +# CONFIG_W83877F_WDT is not set +# CONFIG_W83977F_WDT is not set +# CONFIG_MACHZ_WDT is not set +# CONFIG_SBC_EPX_C3_WATCHDOG is not set +# CONFIG_NI903X_WDT is not set +# CONFIG_NIC7018_WDT is not set + +# +# PCI-based Watchdog Cards +# +# CONFIG_PCIPCWATCHDOG is not set +# CONFIG_WDTPCI is not set + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set + +# +# Watchdog Pretimeout Governors +# +# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set +CONFIG_BCMA_POSSIBLE=y +# CONFIG_BCMA is not set + +# +# Multifunction device drivers +# +CONFIG_MFD_CORE=m +# CONFIG_MFD_AS3711 is not set +# CONFIG_PMIC_ADP5520 is not set +# CONFIG_MFD_BCM590XX is not set +# CONFIG_MFD_BD9571MWV is not set +# CONFIG_MFD_AXP20X_I2C is not set +# CONFIG_MFD_CROS_EC is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_DA9052_I2C is not set +# CONFIG_MFD_DA9055 is not set +# CONFIG_MFD_DA9062 is not set +# CONFIG_MFD_DA9063 is not set +# CONFIG_MFD_DA9150 is not set +# CONFIG_MFD_DLN2 is not set +# CONFIG_MFD_MC13XXX_I2C is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set +# CONFIG_LPC_ICH is not set +CONFIG_LPC_SCH=m +# CONFIG_INTEL_SOC_PMIC_CHTWC is not set +# CONFIG_MFD_INTEL_LPSS_ACPI is not set +# CONFIG_MFD_INTEL_LPSS_PCI is not set +# CONFIG_MFD_JANZ_CMODIO is not set +# CONFIG_MFD_KEMPLD is not set +# CONFIG_MFD_88PM800 is not set +# CONFIG_MFD_88PM805 is not set +# CONFIG_MFD_88PM860X is not set +# CONFIG_MFD_MAX14577 is not set +# CONFIG_MFD_MAX77693 is not set +# CONFIG_MFD_MAX77843 is not set +# CONFIG_MFD_MAX8907 is not set +# CONFIG_MFD_MAX8925 is not set +# CONFIG_MFD_MAX8997 is not set +# CONFIG_MFD_MAX8998 is not set +# CONFIG_MFD_MT6397 is not set +# CONFIG_MFD_MENF21BMC is not set +# CONFIG_MFD_VIPERBOARD is not set +# CONFIG_MFD_RETU is not set +# CONFIG_MFD_PCF50633 is not set +# CONFIG_MFD_RDC321X is not set +# CONFIG_MFD_RTSX_PCI is not set +# CONFIG_MFD_RT5033 is not set +# CONFIG_MFD_RTSX_USB is not set +# CONFIG_MFD_RC5T583 is not set +# CONFIG_MFD_SEC_CORE is not set +# CONFIG_MFD_SI476X_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_SKY81452 is not set +# CONFIG_MFD_SMSC is not set +# CONFIG_ABX500_CORE is not set +# CONFIG_MFD_SYSCON is not set +# CONFIG_MFD_TI_AM335X_TSCADC is not set +# CONFIG_MFD_LP3943 is not set +# CONFIG_MFD_LP8788 is not set +# CONFIG_MFD_TI_LMU is not set +# CONFIG_MFD_PALMAS is not set +# CONFIG_TPS6105X is not set +# CONFIG_TPS6507X is not set +# CONFIG_MFD_TPS65086 is not set +# CONFIG_MFD_TPS65090 is not set +# CONFIG_MFD_TPS65217 is not set +# CONFIG_MFD_TPS68470 is not set +# CONFIG_MFD_TI_LP873X is not set +# CONFIG_MFD_TPS65218 is not set +# CONFIG_MFD_TPS6586X is not set +# CONFIG_MFD_TPS65912_I2C is not set +# CONFIG_MFD_TPS80031 is not set +# CONFIG_TWL4030_CORE is not set +# CONFIG_TWL6040_CORE is not set +# CONFIG_MFD_WL1273_CORE is not set +# CONFIG_MFD_LM3533 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_VX855 is not set +# CONFIG_MFD_ARIZONA_I2C is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM831X_I2C is not set +# CONFIG_MFD_WM8350_I2C is not set +# CONFIG_MFD_WM8994 is not set +# CONFIG_REGULATOR is not set +CONFIG_RC_CORE=y +CONFIG_RC_MAP=y +CONFIG_RC_DECODERS=y +# CONFIG_LIRC is not set +CONFIG_IR_NEC_DECODER=y +CONFIG_IR_RC5_DECODER=y +CONFIG_IR_RC6_DECODER=y +CONFIG_IR_JVC_DECODER=y +CONFIG_IR_SONY_DECODER=y +CONFIG_IR_SANYO_DECODER=y +CONFIG_IR_SHARP_DECODER=y +CONFIG_IR_MCE_KBD_DECODER=y +CONFIG_IR_XMP_DECODER=y +# CONFIG_RC_DEVICES is not set +# CONFIG_MEDIA_SUPPORT is not set + +# +# Graphics support +# +CONFIG_AGP=y +CONFIG_AGP_AMD64=y +CONFIG_AGP_INTEL=y +# CONFIG_AGP_SIS is not set +# CONFIG_AGP_VIA is not set +CONFIG_INTEL_GTT=y +CONFIG_VGA_ARB=y +CONFIG_VGA_ARB_MAX_GPUS=16 +# CONFIG_VGA_SWITCHEROO is not set +CONFIG_DRM=y +CONFIG_DRM_MIPI_DSI=y +# CONFIG_DRM_DP_AUX_CHARDEV is not set +# CONFIG_DRM_DEBUG_MM is not set +# CONFIG_DRM_DEBUG_MM_SELFTEST is not set +CONFIG_DRM_KMS_HELPER=y +CONFIG_DRM_KMS_FB_HELPER=y +CONFIG_DRM_FBDEV_EMULATION=y +CONFIG_DRM_FBDEV_OVERALLOC=100 +# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set + +# +# I2C encoder or helper chips +# +# CONFIG_DRM_I2C_CH7006 is not set +# CONFIG_DRM_I2C_SIL164 is not set +# CONFIG_DRM_I2C_NXP_TDA998X is not set +# CONFIG_DRM_RADEON is not set +# CONFIG_DRM_AMDGPU is not set + +# +# ACP (Audio CoProcessor) Configuration +# +# CONFIG_DRM_NOUVEAU is not set +CONFIG_DRM_I915=y +# CONFIG_DRM_I915_ALPHA_SUPPORT is not set +CONFIG_DRM_I915_CAPTURE_ERROR=y +CONFIG_DRM_I915_COMPRESS_ERROR=y +CONFIG_DRM_I915_USERPTR=y +# CONFIG_DRM_I915_GVT is not set +# CONFIG_DRM_VGEM is not set +# CONFIG_DRM_VMWGFX is not set +# CONFIG_DRM_GMA500 is not set +# CONFIG_DRM_UDL is not set +# CONFIG_DRM_AST is not set +# CONFIG_DRM_MGAG200 is not set +# CONFIG_DRM_CIRRUS_QEMU is not set +# CONFIG_DRM_QXL is not set +# CONFIG_DRM_BOCHS is not set +# CONFIG_DRM_VIRTIO_GPU is not set +CONFIG_DRM_PANEL=y + +# +# Display Panels +# +CONFIG_DRM_BRIDGE=y +CONFIG_DRM_PANEL_BRIDGE=y + +# +# Display Interface Bridges +# +# CONFIG_DRM_ANALOGIX_ANX78XX is not set +# CONFIG_DRM_HISI_HIBMC is not set +# CONFIG_DRM_TINYDRM is not set +# CONFIG_DRM_LEGACY is not set +# CONFIG_DRM_LIB_RANDOM is not set + +# +# Frame buffer Devices +# +CONFIG_FB=y +# CONFIG_FIRMWARE_EDID is not set +CONFIG_FB_CMDLINE=y +CONFIG_FB_NOTIFY=y +# CONFIG_FB_DDC is not set +# CONFIG_FB_BOOT_VESA_SUPPORT is not set +CONFIG_FB_CFB_FILLRECT=y +CONFIG_FB_CFB_COPYAREA=y +CONFIG_FB_CFB_IMAGEBLIT=y +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set +CONFIG_FB_SYS_FILLRECT=y +CONFIG_FB_SYS_COPYAREA=y +CONFIG_FB_SYS_IMAGEBLIT=y +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set +# CONFIG_FB_FOREIGN_ENDIAN is not set +CONFIG_FB_SYS_FOPS=y +CONFIG_FB_DEFERRED_IO=y +# CONFIG_FB_SVGALIB is not set +# CONFIG_FB_MACMODES is not set +# CONFIG_FB_BACKLIGHT is not set +CONFIG_FB_MODE_HELPERS=y +CONFIG_FB_TILEBLITTING=y + +# +# Frame buffer hardware drivers +# +# CONFIG_FB_CIRRUS is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set +# CONFIG_FB_ARC is not set +# CONFIG_FB_ASILIANT is not set +# CONFIG_FB_IMSTT is not set +# CONFIG_FB_VGA16 is not set +# CONFIG_FB_UVESA is not set +# CONFIG_FB_VESA is not set +CONFIG_FB_EFI=y +# CONFIG_FB_N411 is not set +# CONFIG_FB_HGA is not set +# CONFIG_FB_OPENCORES is not set +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_NVIDIA is not set +# CONFIG_FB_RIVA is not set +# CONFIG_FB_I740 is not set +# CONFIG_FB_LE80578 is not set +# CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON is not set +# CONFIG_FB_ATY128 is not set +# CONFIG_FB_ATY is not set +# CONFIG_FB_S3 is not set +# CONFIG_FB_SAVAGE is not set +# CONFIG_FB_SIS is not set +# CONFIG_FB_NEOMAGIC is not set +# CONFIG_FB_KYRO is not set +# CONFIG_FB_3DFX is not set +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VT8623 is not set +# CONFIG_FB_TRIDENT is not set +# CONFIG_FB_ARK is not set +# CONFIG_FB_PM3 is not set +# CONFIG_FB_CARMINE is not set +# CONFIG_FB_SMSCUFX is not set +# CONFIG_FB_UDL is not set +# CONFIG_FB_IBM_GXT4500 is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_BROADSHEET is not set +# CONFIG_FB_AUO_K190X is not set +# CONFIG_FB_SIMPLE is not set +# CONFIG_FB_SM712 is not set +CONFIG_BACKLIGHT_LCD_SUPPORT=y +# CONFIG_LCD_CLASS_DEVICE is not set +CONFIG_BACKLIGHT_CLASS_DEVICE=y +CONFIG_BACKLIGHT_GENERIC=y +# CONFIG_BACKLIGHT_APPLE is not set +# CONFIG_BACKLIGHT_PM8941_WLED is not set +# CONFIG_BACKLIGHT_SAHARA is not set +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set +# CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_LV5207LP is not set +# CONFIG_BACKLIGHT_BD6107 is not set +# CONFIG_BACKLIGHT_ARCXCNN is not set +# CONFIG_VGASTATE is not set +CONFIG_HDMI=y + +# +# Console display driver support +# +CONFIG_VGA_CONSOLE=y +CONFIG_VGACON_SOFT_SCROLLBACK=y +CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64 +# CONFIG_VGACON_SOFT_SCROLLBACK_PERSISTENT_ENABLE_BY_DEFAULT is not set +CONFIG_DUMMY_CONSOLE=y +CONFIG_DUMMY_CONSOLE_COLUMNS=80 +CONFIG_DUMMY_CONSOLE_ROWS=25 +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y +# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set +CONFIG_LOGO=y +# CONFIG_LOGO_LINUX_MONO is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +CONFIG_LOGO_LINUX_CLUT224=y +CONFIG_SOUND=y +# CONFIG_SOUND_OSS_CORE is not set +CONFIG_SND=y +CONFIG_SND_TIMER=y +CONFIG_SND_PCM=y +CONFIG_SND_HWDEP=y +CONFIG_SND_SEQ_DEVICE=y +CONFIG_SND_JACK=y +CONFIG_SND_JACK_INPUT_DEV=y +# CONFIG_SND_OSSEMUL is not set +CONFIG_SND_PCM_TIMER=y +CONFIG_SND_HRTIMER=y +# CONFIG_SND_DYNAMIC_MINORS is not set +CONFIG_SND_SUPPORT_OLD_API=y +CONFIG_SND_PROC_FS=y +CONFIG_SND_VERBOSE_PROCFS=y +# CONFIG_SND_VERBOSE_PRINTK is not set +# CONFIG_SND_DEBUG is not set +CONFIG_SND_VMASTER=y +CONFIG_SND_DMA_SGBUF=y +CONFIG_SND_SEQUENCER=y +CONFIG_SND_SEQ_DUMMY=y +CONFIG_SND_SEQ_HRTIMER_DEFAULT=y +# CONFIG_SND_SEQ_MIDI is not set +# CONFIG_SND_OPL3_LIB_SEQ is not set +# CONFIG_SND_OPL4_LIB_SEQ is not set +CONFIG_SND_DRIVERS=y +# CONFIG_SND_PCSP is not set +# CONFIG_SND_DUMMY is not set +# CONFIG_SND_ALOOP is not set +# CONFIG_SND_VIRMIDI is not set +# CONFIG_SND_MTPAV is not set +# CONFIG_SND_SERIAL_U16550 is not set +# CONFIG_SND_MPU401 is not set +CONFIG_SND_PCI=y +# CONFIG_SND_AD1889 is not set +# CONFIG_SND_ALS300 is not set +# CONFIG_SND_ALS4000 is not set +# CONFIG_SND_ALI5451 is not set +# CONFIG_SND_ASIHPI is not set +# CONFIG_SND_ATIIXP is not set +# CONFIG_SND_ATIIXP_MODEM is not set +# CONFIG_SND_AU8810 is not set +# CONFIG_SND_AU8820 is not set +# CONFIG_SND_AU8830 is not set +# CONFIG_SND_AW2 is not set +# CONFIG_SND_AZT3328 is not set +# CONFIG_SND_BT87X is not set +# CONFIG_SND_CA0106 is not set +# CONFIG_SND_CMIPCI is not set +# CONFIG_SND_OXYGEN is not set +# CONFIG_SND_CS4281 is not set +# CONFIG_SND_CS46XX is not set +# CONFIG_SND_CTXFI is not set +# CONFIG_SND_DARLA20 is not set +# CONFIG_SND_GINA20 is not set +# CONFIG_SND_LAYLA20 is not set +# CONFIG_SND_DARLA24 is not set +# CONFIG_SND_GINA24 is not set +# CONFIG_SND_LAYLA24 is not set +# CONFIG_SND_MONA is not set +# CONFIG_SND_MIA is not set +# CONFIG_SND_ECHO3G is not set +# CONFIG_SND_INDIGO is not set +# CONFIG_SND_INDIGOIO is not set +# CONFIG_SND_INDIGODJ is not set +# CONFIG_SND_INDIGOIOX is not set +# CONFIG_SND_INDIGODJX is not set +# CONFIG_SND_EMU10K1 is not set +# CONFIG_SND_EMU10K1_SEQ is not set +# CONFIG_SND_EMU10K1X is not set +# CONFIG_SND_ENS1370 is not set +# CONFIG_SND_ENS1371 is not set +# CONFIG_SND_ES1938 is not set +# CONFIG_SND_ES1968 is not set +# CONFIG_SND_FM801 is not set +# CONFIG_SND_HDSP is not set +# CONFIG_SND_HDSPM is not set +# CONFIG_SND_ICE1712 is not set +# CONFIG_SND_ICE1724 is not set +# CONFIG_SND_INTEL8X0 is not set +# CONFIG_SND_INTEL8X0M is not set +# CONFIG_SND_KORG1212 is not set +# CONFIG_SND_LOLA is not set +# CONFIG_SND_LX6464ES is not set +# CONFIG_SND_MAESTRO3 is not set +# CONFIG_SND_MIXART is not set +# CONFIG_SND_NM256 is not set +# CONFIG_SND_PCXHR is not set +# CONFIG_SND_RIPTIDE is not set +# CONFIG_SND_RME32 is not set +# CONFIG_SND_RME96 is not set +# CONFIG_SND_RME9652 is not set +# CONFIG_SND_SE6X is not set +# CONFIG_SND_SONICVIBES is not set +# CONFIG_SND_TRIDENT is not set +# CONFIG_SND_VIA82XX is not set +# CONFIG_SND_VIA82XX_MODEM is not set +# CONFIG_SND_VIRTUOSO is not set +# CONFIG_SND_VX222 is not set +# CONFIG_SND_YMFPCI is not set + +# +# HD-Audio +# +CONFIG_SND_HDA=y +CONFIG_SND_HDA_INTEL=y +CONFIG_SND_HDA_HWDEP=y +# CONFIG_SND_HDA_RECONFIG is not set +# CONFIG_SND_HDA_INPUT_BEEP is not set +# CONFIG_SND_HDA_PATCH_LOADER is not set +# CONFIG_SND_HDA_CODEC_REALTEK is not set +# CONFIG_SND_HDA_CODEC_ANALOG is not set +# CONFIG_SND_HDA_CODEC_SIGMATEL is not set +# CONFIG_SND_HDA_CODEC_VIA is not set +# CONFIG_SND_HDA_CODEC_HDMI is not set +# CONFIG_SND_HDA_CODEC_CIRRUS is not set +# CONFIG_SND_HDA_CODEC_CONEXANT is not set +# CONFIG_SND_HDA_CODEC_CA0110 is not set +# CONFIG_SND_HDA_CODEC_CA0132 is not set +# CONFIG_SND_HDA_CODEC_CMEDIA is not set +# CONFIG_SND_HDA_CODEC_SI3054 is not set +# CONFIG_SND_HDA_GENERIC is not set +CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0 +CONFIG_SND_HDA_CORE=y +CONFIG_SND_HDA_I915=y +CONFIG_SND_HDA_PREALLOC_SIZE=64 +CONFIG_SND_USB=y +# CONFIG_SND_USB_AUDIO is not set +# CONFIG_SND_USB_UA101 is not set +# CONFIG_SND_USB_USX2Y is not set +# CONFIG_SND_USB_CAIAQ is not set +# CONFIG_SND_USB_US122L is not set +# CONFIG_SND_USB_6FIRE is not set +# CONFIG_SND_USB_HIFACE is not set +# CONFIG_SND_BCD2000 is not set +# CONFIG_SND_USB_POD is not set +# CONFIG_SND_USB_PODHD is not set +# CONFIG_SND_USB_TONEPORT is not set +# CONFIG_SND_USB_VARIAX is not set +CONFIG_SND_PCMCIA=y +# CONFIG_SND_VXPOCKET is not set +# CONFIG_SND_PDAUDIOCF is not set +# CONFIG_SND_SOC is not set +CONFIG_SND_X86=y +# CONFIG_HDMI_LPE_AUDIO is not set + +# +# HID support +# +CONFIG_HID=y +# CONFIG_HID_BATTERY_STRENGTH is not set +CONFIG_HIDRAW=y +# CONFIG_UHID is not set +CONFIG_HID_GENERIC=y + +# +# Special HID drivers +# +CONFIG_HID_A4TECH=y +# CONFIG_HID_ACCUTOUCH is not set +# CONFIG_HID_ACRUX is not set +CONFIG_HID_APPLE=y +# CONFIG_HID_APPLEIR is not set +# CONFIG_HID_ASUS is not set +# CONFIG_HID_AUREAL is not set +CONFIG_HID_BELKIN=y +# CONFIG_HID_BETOP_FF is not set +CONFIG_HID_CHERRY=y +CONFIG_HID_CHICONY=y +# CONFIG_HID_CORSAIR is not set +# CONFIG_HID_PRODIKEYS is not set +# CONFIG_HID_CMEDIA is not set +CONFIG_HID_CYPRESS=y +# CONFIG_HID_DRAGONRISE is not set +# CONFIG_HID_EMS_FF is not set +# CONFIG_HID_ELECOM is not set +# CONFIG_HID_ELO is not set +CONFIG_HID_EZKEY=y +# CONFIG_HID_GEMBIRD is not set +# CONFIG_HID_GFRM is not set +# CONFIG_HID_HOLTEK is not set +# CONFIG_HID_GT683R is not set +# CONFIG_HID_KEYTOUCH is not set +# CONFIG_HID_KYE is not set +# CONFIG_HID_UCLOGIC is not set +# CONFIG_HID_WALTOP is not set +CONFIG_HID_GYRATION=y +# CONFIG_HID_ICADE is not set +CONFIG_HID_ITE=y +# CONFIG_HID_TWINHAN is not set +CONFIG_HID_KENSINGTON=y +# CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LED is not set +# CONFIG_HID_LENOVO is not set +CONFIG_HID_LOGITECH=y +# CONFIG_HID_LOGITECH_DJ is not set +# CONFIG_HID_LOGITECH_HIDPP is not set +CONFIG_LOGITECH_FF=y +# CONFIG_LOGIRUMBLEPAD2_FF is not set +# CONFIG_LOGIG940_FF is not set +CONFIG_LOGIWHEELS_FF=y +# CONFIG_HID_MAGICMOUSE is not set +# CONFIG_HID_MAYFLASH is not set +CONFIG_HID_MICROSOFT=y +CONFIG_HID_MONTEREY=y +# CONFIG_HID_MULTITOUCH is not set +# CONFIG_HID_NTI is not set +CONFIG_HID_NTRIG=y +# CONFIG_HID_ORTEK is not set +CONFIG_HID_PANTHERLORD=y +CONFIG_PANTHERLORD_FF=y +# CONFIG_HID_PENMOUNT is not set +CONFIG_HID_PETALYNX=y +# CONFIG_HID_PICOLCD is not set +# CONFIG_HID_PLANTRONICS is not set +# CONFIG_HID_PRIMAX is not set +# CONFIG_HID_RETRODE is not set +# CONFIG_HID_ROCCAT is not set +# CONFIG_HID_SAITEK is not set +CONFIG_HID_SAMSUNG=y +CONFIG_HID_SONY=y +# CONFIG_SONY_FF is not set +# CONFIG_HID_SPEEDLINK is not set +# CONFIG_HID_STEELSERIES is not set +CONFIG_HID_SUNPLUS=y +# CONFIG_HID_RMI is not set +# CONFIG_HID_GREENASIA is not set +# CONFIG_HID_SMARTJOYPLUS is not set +# CONFIG_HID_TIVO is not set +CONFIG_HID_TOPSEED=y +# CONFIG_HID_THINGM is not set +# CONFIG_HID_THRUSTMASTER is not set +# CONFIG_HID_UDRAW_PS3 is not set +# CONFIG_HID_WACOM is not set +# CONFIG_HID_WIIMOTE is not set +# CONFIG_HID_XINMO is not set +# CONFIG_HID_ZEROPLUS is not set +# CONFIG_HID_ZYDACRON is not set +# CONFIG_HID_SENSOR_HUB is not set +# CONFIG_HID_ALPS is not set + +# +# USB HID support +# +CONFIG_USB_HID=y +CONFIG_HID_PID=y +CONFIG_USB_HIDDEV=y + +# +# I2C HID support +# +# CONFIG_I2C_HID is not set + +# +# Intel ISH HID support +# +# CONFIG_INTEL_ISH_HID is not set +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_COMMON=y +CONFIG_USB_ARCH_HAS_HCD=y +CONFIG_USB=y +CONFIG_USB_PCI=y +CONFIG_USB_ANNOUNCE_NEW_DEVICES=y + +# +# Miscellaneous USB options +# +CONFIG_USB_DEFAULT_PERSIST=y +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_OTG_WHITELIST is not set +# CONFIG_USB_LEDS_TRIGGER_USBPORT is not set +CONFIG_USB_MON=y +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_XHCI_HCD is not set +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_EHCI_ROOT_HUB_TT is not set +CONFIG_USB_EHCI_TT_NEWSCHED=y +CONFIG_USB_EHCI_PCI=y +# CONFIG_USB_EHCI_HCD_PLATFORM is not set +# CONFIG_USB_OXU210HP_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_ISP1362_HCD is not set +# CONFIG_USB_FOTG210_HCD is not set +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_HCD_PCI=y +# CONFIG_USB_OHCI_HCD_PLATFORM is not set +CONFIG_USB_UHCI_HCD=y +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HCD_TEST_MODE is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +CONFIG_USB_PRINTER=y +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may +# + +# +# also be needed; see USB_STORAGE Help for more info +# +CONFIG_USB_STORAGE=y +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_REALTEK is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +# CONFIG_USB_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_STORAGE_ENE_UB6250 is not set +# CONFIG_USB_UAS is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set +# CONFIG_USBIP_CORE is not set +# CONFIG_USB_MUSB_HDRC is not set +# CONFIG_USB_DWC3 is not set +# CONFIG_USB_DWC2 is not set +# CONFIG_USB_CHIPIDEA is not set +# CONFIG_USB_ISP1760 is not set + +# +# USB port drivers +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_SISUSBVGA is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_EHSET_TEST_FIXTURE is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_YUREX is not set +# CONFIG_USB_EZUSB_FX2 is not set +# CONFIG_USB_HUB_USB251XB is not set +# CONFIG_USB_HSIC_USB3503 is not set +# CONFIG_USB_HSIC_USB4604 is not set +# CONFIG_USB_LINK_LAYER_TEST is not set +# CONFIG_USB_CHAOSKEY is not set + +# +# USB Physical Layer drivers +# +# CONFIG_USB_PHY is not set +# CONFIG_NOP_USB_XCEIV is not set +# CONFIG_USB_ISP1301 is not set +# CONFIG_USB_GADGET is not set + +# +# USB Power Delivery and Type-C drivers +# +# CONFIG_TYPEC_UCSI is not set +# CONFIG_USB_LED_TRIG is not set +# CONFIG_USB_ULPI_BUS is not set +# CONFIG_UWB is not set +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y +# CONFIG_LEDS_CLASS_FLASH is not set +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set + +# +# LED drivers +# +# CONFIG_LEDS_LM3530 is not set +# CONFIG_LEDS_LM3642 is not set +# CONFIG_LEDS_PCA9532 is not set +# CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_LP5521 is not set +# CONFIG_LEDS_LP5523 is not set +# CONFIG_LEDS_LP5562 is not set +# CONFIG_LEDS_LP8501 is not set +# CONFIG_LEDS_LP8860 is not set +# CONFIG_LEDS_CLEVO_MAIL is not set +# CONFIG_LEDS_PCA955X is not set +# CONFIG_LEDS_PCA963X is not set +# CONFIG_LEDS_BD2802 is not set +# CONFIG_LEDS_INTEL_SS4200 is not set +# CONFIG_LEDS_TCA6507 is not set +# CONFIG_LEDS_TLC591XX is not set +# CONFIG_LEDS_LM355x is not set + +# +# LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM) +# +# CONFIG_LEDS_BLINKM is not set +# CONFIG_LEDS_MLXCPLD is not set +# CONFIG_LEDS_USER is not set +# CONFIG_LEDS_NIC78BX is not set + +# +# LED Triggers +# +CONFIG_LEDS_TRIGGERS=y +# CONFIG_LEDS_TRIGGER_TIMER is not set +# CONFIG_LEDS_TRIGGER_ONESHOT is not set +# CONFIG_LEDS_TRIGGER_DISK is not set +# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +# CONFIG_LEDS_TRIGGER_CPU is not set +# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set + +# +# iptables trigger is under Netfilter config (LED target) +# +# CONFIG_LEDS_TRIGGER_TRANSIENT is not set +# CONFIG_LEDS_TRIGGER_CAMERA is not set +# CONFIG_LEDS_TRIGGER_PANIC is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_INFINIBAND is not set +CONFIG_EDAC_ATOMIC_SCRUB=y +CONFIG_EDAC_SUPPORT=y +CONFIG_EDAC=y +CONFIG_EDAC_LEGACY_SYSFS=y +# CONFIG_EDAC_DEBUG is not set +CONFIG_EDAC_DECODE_MCE=y +# CONFIG_EDAC_AMD64 is not set +# CONFIG_EDAC_E752X is not set +# CONFIG_EDAC_I82975X is not set +# CONFIG_EDAC_I3000 is not set +# CONFIG_EDAC_I3200 is not set +# CONFIG_EDAC_IE31200 is not set +# CONFIG_EDAC_X38 is not set +# CONFIG_EDAC_I5400 is not set +# CONFIG_EDAC_I7CORE is not set +# CONFIG_EDAC_I5000 is not set +# CONFIG_EDAC_I5100 is not set +# CONFIG_EDAC_I7300 is not set +# CONFIG_EDAC_SBRIDGE is not set +# CONFIG_EDAC_SKX is not set +# CONFIG_EDAC_PND2 is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_MC146818_LIB=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_HCTOSYS is not set +CONFIG_RTC_SYSTOHC=y +CONFIG_RTC_SYSTOHC_DEVICE="rtc0" +# CONFIG_RTC_DEBUG is not set +CONFIG_RTC_NVMEM=y + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_ABB5ZES3 is not set +# CONFIG_RTC_DRV_ABX80X is not set +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_ISL12022 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8523 is not set +# CONFIG_RTC_DRV_PCF85063 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_BQ32K is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8010 is not set +# CONFIG_RTC_DRV_RX8581 is not set +# CONFIG_RTC_DRV_RX8025 is not set +# CONFIG_RTC_DRV_EM3027 is not set +# CONFIG_RTC_DRV_RV8803 is not set + +# +# SPI RTC drivers +# +CONFIG_RTC_I2C_AND_SPI=y + +# +# SPI and I2C RTC drivers +# +# CONFIG_RTC_DRV_DS3232 is not set +# CONFIG_RTC_DRV_PCF2127 is not set +# CONFIG_RTC_DRV_RV3029C2 is not set + +# +# Platform RTC drivers +# +CONFIG_RTC_DRV_CMOS=y +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1685_FAMILY is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_DS2404 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_MSM6242 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_RP5C01 is not set +# CONFIG_RTC_DRV_V3020 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_FTRTC010 is not set + +# +# HID Sensor RTC drivers +# +# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set +CONFIG_DMADEVICES=y +# CONFIG_DMADEVICES_DEBUG is not set + +# +# DMA Devices +# +CONFIG_DMA_ENGINE=y +CONFIG_DMA_VIRTUAL_CHANNELS=y +CONFIG_DMA_ACPI=y +# CONFIG_ALTERA_MSGDMA is not set +# CONFIG_INTEL_IDMA64 is not set +# CONFIG_INTEL_IOATDMA is not set +# CONFIG_QCOM_HIDMA_MGMT is not set +# CONFIG_QCOM_HIDMA is not set +CONFIG_DW_DMAC_CORE=y +# CONFIG_DW_DMAC is not set +# CONFIG_DW_DMAC_PCI is not set +CONFIG_HSU_DMA=y + +# +# DMA Clients +# +# CONFIG_ASYNC_TX_DMA is not set +# CONFIG_DMATEST is not set + +# +# DMABUF options +# +CONFIG_SYNC_FILE=y +# CONFIG_SW_SYNC is not set +# CONFIG_AUXDISPLAY is not set +# CONFIG_UIO is not set +# CONFIG_VFIO is not set +CONFIG_VIRT_DRIVERS=y +CONFIG_VIRTIO=y + +# +# Virtio drivers +# +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_PCI_LEGACY=y +# CONFIG_VIRTIO_BALLOON is not set +# CONFIG_VIRTIO_INPUT is not set +# CONFIG_VIRTIO_MMIO is not set + +# +# Microsoft Hyper-V guest support +# +# CONFIG_HYPERV_TSCPAGE is not set +# CONFIG_STAGING is not set +CONFIG_X86_PLATFORM_DEVICES=y +# CONFIG_ACERHDF is not set +# CONFIG_ASUS_LAPTOP is not set +# CONFIG_DELL_LAPTOP is not set +# CONFIG_DELL_SMO8800 is not set +# CONFIG_DELL_RBTN is not set +# CONFIG_FUJITSU_LAPTOP is not set +# CONFIG_FUJITSU_TABLET is not set +# CONFIG_AMILO_RFKILL is not set +# CONFIG_HP_ACCEL is not set +# CONFIG_HP_WIRELESS is not set +# CONFIG_MSI_LAPTOP is not set +# CONFIG_PANASONIC_LAPTOP is not set +# CONFIG_COMPAL_LAPTOP is not set +# CONFIG_SONY_LAPTOP is not set +# CONFIG_IDEAPAD_LAPTOP is not set +# CONFIG_THINKPAD_ACPI is not set +# CONFIG_SENSORS_HDAPS is not set +# CONFIG_INTEL_MENLOW is not set +CONFIG_EEEPC_LAPTOP=y +# CONFIG_ASUS_WIRELESS is not set +# CONFIG_ACPI_WMI is not set +# CONFIG_TOPSTAR_LAPTOP is not set +# CONFIG_TOSHIBA_BT_RFKILL is not set +# CONFIG_TOSHIBA_HAPS is not set +# CONFIG_ACPI_CMPC is not set +# CONFIG_INTEL_CHT_INT33FE is not set +# CONFIG_INTEL_HID_EVENT is not set +# CONFIG_INTEL_VBTN is not set +# CONFIG_INTEL_IPS is not set +# CONFIG_INTEL_PMC_CORE is not set +# CONFIG_IBM_RTL is not set +# CONFIG_SAMSUNG_LAPTOP is not set +# CONFIG_INTEL_OAKTRAIL is not set +# CONFIG_SAMSUNG_Q10 is not set +# CONFIG_APPLE_GMUX is not set +# CONFIG_INTEL_RST is not set +# CONFIG_INTEL_SMARTCONNECT is not set +# CONFIG_PVPANIC is not set +# CONFIG_INTEL_PMC_IPC is not set +# CONFIG_SURFACE_PRO3_BUTTON is not set +# CONFIG_INTEL_PUNIT_IPC is not set +# CONFIG_MLX_PLATFORM is not set +# CONFIG_MLX_CPLD_PLATFORM is not set +# CONFIG_INTEL_TURBO_MAX_3 is not set +CONFIG_PMC_ATOM=y +# CONFIG_CHROME_PLATFORMS is not set +CONFIG_CLKDEV_LOOKUP=y +CONFIG_HAVE_CLK_PREPARE=y +CONFIG_COMMON_CLK=y + +# +# Common Clock Framework +# +# CONFIG_COMMON_CLK_SI5351 is not set +# CONFIG_COMMON_CLK_CDCE706 is not set +# CONFIG_COMMON_CLK_CS2000_CP is not set +# CONFIG_COMMON_CLK_NXP is not set +# CONFIG_COMMON_CLK_PXA is not set +# CONFIG_COMMON_CLK_PIC32 is not set +# CONFIG_HWSPINLOCK is not set + +# +# Clock Source drivers +# +CONFIG_CLKEVT_I8253=y +CONFIG_I8253_LOCK=y +CONFIG_CLKBLD_I8253=y +# CONFIG_ATMEL_PIT is not set +# CONFIG_SH_TIMER_CMT is not set +# CONFIG_SH_TIMER_MTU2 is not set +# CONFIG_SH_TIMER_TMU is not set +# CONFIG_EM_TIMER_STI is not set +CONFIG_MAILBOX=y +CONFIG_PCC=y +# CONFIG_ALTERA_MBOX is not set +CONFIG_IOMMU_API=y +CONFIG_IOMMU_SUPPORT=y + +# +# Generic IOMMU Pagetable Support +# +CONFIG_IOMMU_IOVA=y +CONFIG_AMD_IOMMU=y +# CONFIG_AMD_IOMMU_V2 is not set +CONFIG_DMAR_TABLE=y +CONFIG_INTEL_IOMMU=y +# CONFIG_INTEL_IOMMU_SVM is not set +# CONFIG_INTEL_IOMMU_DEFAULT_ON is not set +CONFIG_INTEL_IOMMU_FLOPPY_WA=y +# CONFIG_IRQ_REMAP is not set + +# +# Remoteproc drivers +# +# CONFIG_REMOTEPROC is not set + +# +# Rpmsg drivers +# +# CONFIG_RPMSG_QCOM_GLINK_RPM is not set + +# +# SOC (System On Chip) specific Drivers +# + +# +# Amlogic SoC drivers +# + +# +# Broadcom SoC drivers +# + +# +# i.MX SoC drivers +# + +# +# Qualcomm SoC drivers +# +# CONFIG_SUNXI_SRAM is not set +# CONFIG_SOC_TI is not set +# CONFIG_PM_DEVFREQ is not set +# CONFIG_EXTCON is not set +# CONFIG_MEMORY is not set +# CONFIG_IIO is not set +# CONFIG_NTB is not set +# CONFIG_VME_BUS is not set +# CONFIG_PWM is not set +CONFIG_ARM_GIC_MAX_NR=1 +# CONFIG_IPACK_BUS is not set +# CONFIG_RESET_CONTROLLER is not set +# CONFIG_FMC is not set + +# +# PHY Subsystem +# +# CONFIG_GENERIC_PHY is not set +# CONFIG_BCM_KONA_USB2_PHY is not set +# CONFIG_PHY_PXA_28NM_HSIC is not set +# CONFIG_PHY_PXA_28NM_USB2 is not set +# CONFIG_POWERCAP is not set +# CONFIG_MCB is not set + +# +# Performance monitor support +# +CONFIG_RAS=y +# CONFIG_THUNDERBOLT is not set + +# +# Android +# +# CONFIG_ANDROID is not set +# CONFIG_LIBNVDIMM is not set +CONFIG_DAX=y +CONFIG_NVMEM=y +# CONFIG_STM is not set +# CONFIG_INTEL_TH is not set +# CONFIG_FPGA is not set + +# +# FSI support +# +# CONFIG_FSI is not set + +# +# Firmware Drivers +# +# CONFIG_EDD is not set +CONFIG_FIRMWARE_MEMMAP=y +# CONFIG_DELL_RBU is not set +# CONFIG_DCDBAS is not set +CONFIG_DMIID=y +# CONFIG_DMI_SYSFS is not set +CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y +# CONFIG_ISCSI_IBFT_FIND is not set +# CONFIG_FW_CFG_SYSFS is not set +# CONFIG_GOOGLE_FIRMWARE is not set + +# +# EFI (Extensible Firmware Interface) Support +# +CONFIG_EFI_VARS=y +CONFIG_EFI_ESRT=y +CONFIG_EFI_RUNTIME_MAP=y +# CONFIG_EFI_FAKE_MEMMAP is not set +CONFIG_EFI_RUNTIME_WRAPPERS=y +# CONFIG_EFI_BOOTLOADER_CONTROL is not set +# CONFIG_EFI_CAPSULE_LOADER is not set +# CONFIG_EFI_TEST is not set +# CONFIG_EFI_DEV_PATH_PARSER is not set + +# +# Tegra firmware driver +# + +# +# File systems +# +CONFIG_DCACHE_WORD_ACCESS=y +# CONFIG_EXT2_FS is not set +# CONFIG_EXT3_FS is not set +CONFIG_EXT4_FS=y +CONFIG_EXT4_USE_FOR_EXT2=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +# CONFIG_EXT4_ENCRYPTION is not set +# CONFIG_EXT4_DEBUG is not set +CONFIG_JBD2=y +# CONFIG_JBD2_DEBUG is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_XFS_FS is not set +# CONFIG_GFS2_FS is not set +# CONFIG_BTRFS_FS is not set +# CONFIG_NILFS2_FS is not set +# CONFIG_F2FS_FS is not set +# CONFIG_FS_DAX is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_EXPORTFS=y +# CONFIG_EXPORTFS_BLOCK_OPS is not set +CONFIG_FILE_LOCKING=y +CONFIG_MANDATORY_FILE_LOCKING=y +# CONFIG_FS_ENCRYPTION is not set +CONFIG_FSNOTIFY=y +CONFIG_DNOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_FANOTIFY is not set +CONFIG_QUOTA=y +CONFIG_QUOTA_NETLINK_INTERFACE=y +# CONFIG_PRINT_QUOTA_WARNING is not set +# CONFIG_QUOTA_DEBUG is not set +CONFIG_QUOTA_TREE=y +# CONFIG_QFMT_V1 is not set +CONFIG_QFMT_V2=y +CONFIG_QUOTACTL=y +CONFIG_QUOTACTL_COMPAT=y +CONFIG_AUTOFS4_FS=y +# CONFIG_FUSE_FS is not set +CONFIG_OVERLAY_FS=y +CONFIG_OVERLAY_FS_REDIRECT_DIR=y +CONFIG_OVERLAY_FS_INDEX=y + +# +# Caches +# +# CONFIG_FSCACHE is not set + +# +# CD-ROM/DVD Filesystems +# +CONFIG_ISO9660_FS=y +CONFIG_JOLIET=y +CONFIG_ZISOFS=y +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +# CONFIG_FAT_DEFAULT_UTF8 is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y +CONFIG_PROC_VMCORE=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +# CONFIG_PROC_CHILDREN is not set +CONFIG_KERNFS=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TMPFS_XATTR=y +CONFIG_HUGETLBFS=y +CONFIG_HUGETLB_PAGE=y +# CONFIG_CONFIGFS_FS is not set +CONFIG_EFIVAR_FS=m +CONFIG_MISC_FILESYSTEMS=y +# CONFIG_ORANGEFS_FS is not set +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +CONFIG_ECRYPT_FS=y +# CONFIG_ECRYPT_FS_MESSAGING is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +# CONFIG_CRAMFS is not set +CONFIG_SQUASHFS=y +CONFIG_SQUASHFS_FILE_CACHE=y +# CONFIG_SQUASHFS_FILE_DIRECT is not set +CONFIG_SQUASHFS_DECOMP_SINGLE=y +# CONFIG_SQUASHFS_DECOMP_MULTI is not set +# CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU is not set +CONFIG_SQUASHFS_XATTR=y +CONFIG_SQUASHFS_ZLIB=y +CONFIG_SQUASHFS_LZ4=y +CONFIG_SQUASHFS_LZO=y +CONFIG_SQUASHFS_XZ=y +CONFIG_SQUASHFS_ZSTD=y +CONFIG_SQUASHFS_4K_DEVBLK_SIZE=y +# CONFIG_SQUASHFS_EMBEDDED is not set +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_QNX6FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_PSTORE is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +CONFIG_NFS_V2=y +CONFIG_NFS_V3=y +CONFIG_NFS_V3_ACL=y +CONFIG_NFS_V4=y +# CONFIG_NFS_SWAP is not set +# CONFIG_NFS_V4_1 is not set +CONFIG_ROOT_NFS=y +# CONFIG_NFS_USE_LEGACY_DNS is not set +CONFIG_NFS_USE_KERNEL_DNS=y +# CONFIG_NFSD is not set +CONFIG_GRACE_PERIOD=y +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_NFS_ACL_SUPPORT=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +CONFIG_SUNRPC_GSS=y +# CONFIG_SUNRPC_DEBUG is not set +# CONFIG_CEPH_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +# CONFIG_NLS_MAC_ROMAN is not set +# CONFIG_NLS_MAC_CELTIC is not set +# CONFIG_NLS_MAC_CENTEURO is not set +# CONFIG_NLS_MAC_CROATIAN is not set +# CONFIG_NLS_MAC_CYRILLIC is not set +# CONFIG_NLS_MAC_GAELIC is not set +# CONFIG_NLS_MAC_GREEK is not set +# CONFIG_NLS_MAC_ICELAND is not set +# CONFIG_NLS_MAC_INUIT is not set +# CONFIG_NLS_MAC_ROMANIAN is not set +# CONFIG_NLS_MAC_TURKISH is not set +CONFIG_NLS_UTF8=y + +# +# Kernel hacking +# +CONFIG_TRACE_IRQFLAGS_SUPPORT=y + +# +# printk and dmesg options +# +CONFIG_PRINTK_TIME=y +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 +CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 +# CONFIG_BOOT_PRINTK_DELAY is not set +# CONFIG_DYNAMIC_DEBUG is not set + +# +# Compile-time checks and compiler options +# +# CONFIG_DEBUG_INFO is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=2048 +# CONFIG_STRIP_ASM_SYMS is not set +# CONFIG_READABLE_ASM is not set +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_PAGE_OWNER is not set +CONFIG_DEBUG_FS=y +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_SECTION_MISMATCH is not set +CONFIG_SECTION_MISMATCH_WARN_ONLY=y +CONFIG_STACK_VALIDATION=y +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set +CONFIG_MAGIC_SYSRQ=y +CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1 +CONFIG_MAGIC_SYSRQ_SERIAL=y +CONFIG_DEBUG_KERNEL=y + +# +# Memory Debugging +# +# CONFIG_PAGE_EXTENSION is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_PAGE_POISONING is not set +# CONFIG_DEBUG_PAGE_REF is not set +# CONFIG_DEBUG_RODATA_TEST is not set +# CONFIG_DEBUG_OBJECTS is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_HAVE_DEBUG_KMEMLEAK=y +# CONFIG_DEBUG_KMEMLEAK is not set +CONFIG_DEBUG_STACK_USAGE=y +# CONFIG_DEBUG_VM is not set +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +# CONFIG_DEBUG_VIRTUAL is not set +CONFIG_DEBUG_MEMORY_INIT=y +# CONFIG_DEBUG_PER_CPU_MAPS is not set +CONFIG_HAVE_DEBUG_STACKOVERFLOW=y +CONFIG_DEBUG_STACKOVERFLOW=y +CONFIG_HAVE_ARCH_KASAN=y +# CONFIG_KASAN is not set +CONFIG_ARCH_HAS_KCOV=y +# CONFIG_KCOV is not set +# CONFIG_DEBUG_SHIRQ is not set + +# +# Debug Lockups and Hangs +# +# CONFIG_SOFTLOCKUP_DETECTOR is not set +CONFIG_HARDLOCKUP_CHECK_TIMESTAMP=y +# CONFIG_HARDLOCKUP_DETECTOR is not set +# CONFIG_DETECT_HUNG_TASK is not set +# CONFIG_WQ_WATCHDOG is not set +# CONFIG_PANIC_ON_OOPS is not set +CONFIG_PANIC_ON_OOPS_VALUE=0 +CONFIG_PANIC_TIMEOUT=0 +# CONFIG_SCHED_DEBUG is not set +CONFIG_SCHED_INFO=y +CONFIG_SCHEDSTATS=y +# CONFIG_SCHED_STACK_END_CHECK is not set +# CONFIG_DEBUG_TIMEKEEPING is not set + +# +# Lock Debugging (spinlocks, mutexes, etc...) +# +# CONFIG_DEBUG_RT_MUTEXES is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_MUTEXES is not set +# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set +# CONFIG_DEBUG_LOCK_ALLOC is not set +# CONFIG_PROVE_LOCKING is not set +# CONFIG_LOCK_STAT is not set +# CONFIG_DEBUG_ATOMIC_SLEEP is not set +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set +# CONFIG_LOCK_TORTURE_TEST is not set +# CONFIG_WW_MUTEX_SELFTEST is not set +CONFIG_STACKTRACE=y +# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set +# CONFIG_DEBUG_KOBJECT is not set +CONFIG_DEBUG_BUGVERBOSE=y +# CONFIG_DEBUG_LIST is not set +# CONFIG_DEBUG_PI_LIST is not set +# CONFIG_DEBUG_SG is not set +# CONFIG_DEBUG_NOTIFIERS is not set +# CONFIG_DEBUG_CREDENTIALS is not set + +# +# RCU Debugging +# +# CONFIG_PROVE_RCU is not set +# CONFIG_TORTURE_TEST is not set +# CONFIG_RCU_PERF_TEST is not set +# CONFIG_RCU_TORTURE_TEST is not set +CONFIG_RCU_CPU_STALL_TIMEOUT=21 +CONFIG_RCU_TRACE=y +# CONFIG_RCU_EQS_DEBUG is not set +# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_NOTIFIER_ERROR_INJECTION is not set +# CONFIG_FAULT_INJECTION is not set +# CONFIG_LATENCYTOP is not set +CONFIG_USER_STACKTRACE_SUPPORT=y +CONFIG_NOP_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y +CONFIG_HAVE_FENTRY=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_TRACE_CLOCK=y +CONFIG_RING_BUFFER=y +CONFIG_EVENT_TRACING=y +CONFIG_CONTEXT_SWITCH_TRACER=y +CONFIG_TRACING=y +CONFIG_GENERIC_TRACER=y +CONFIG_TRACING_SUPPORT=y +CONFIG_FTRACE=y +# CONFIG_FUNCTION_TRACER is not set +# CONFIG_IRQSOFF_TRACER is not set +# CONFIG_SCHED_TRACER is not set +# CONFIG_HWLAT_TRACER is not set +# CONFIG_FTRACE_SYSCALLS is not set +# CONFIG_TRACER_SNAPSHOT is not set +CONFIG_BRANCH_PROFILE_NONE=y +# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set +# CONFIG_PROFILE_ALL_BRANCHES is not set +# CONFIG_STACK_TRACER is not set +CONFIG_BLK_DEV_IO_TRACE=y +CONFIG_KPROBE_EVENTS=y +CONFIG_UPROBE_EVENTS=y +CONFIG_PROBE_EVENTS=y +# CONFIG_FTRACE_STARTUP_TEST is not set +# CONFIG_MMIOTRACE is not set +# CONFIG_HIST_TRIGGERS is not set +# CONFIG_TRACEPOINT_BENCHMARK is not set +# CONFIG_RING_BUFFER_BENCHMARK is not set +# CONFIG_RING_BUFFER_STARTUP_TEST is not set +# CONFIG_TRACE_EVAL_MAP_FILE is not set +CONFIG_PROVIDE_OHCI1394_DMA_INIT=y +# CONFIG_DMA_API_DEBUG is not set + +# +# Runtime Testing +# +# CONFIG_LKDTM is not set +# CONFIG_TEST_LIST_SORT is not set +# CONFIG_TEST_SORT is not set +# CONFIG_KPROBES_SANITY_TEST is not set +# CONFIG_BACKTRACE_SELF_TEST is not set +# CONFIG_RBTREE_TEST is not set +# CONFIG_INTERVAL_TREE_TEST is not set +# CONFIG_PERCPU_TEST is not set +# CONFIG_ATOMIC64_SELFTEST is not set +# CONFIG_TEST_HEXDUMP is not set +# CONFIG_TEST_STRING_HELPERS is not set +# CONFIG_TEST_KSTRTOX is not set +# CONFIG_TEST_PRINTF is not set +# CONFIG_TEST_BITMAP is not set +# CONFIG_TEST_UUID is not set +# CONFIG_TEST_RHASHTABLE is not set +# CONFIG_TEST_HASH is not set +# CONFIG_TEST_LKM is not set +# CONFIG_TEST_USER_COPY is not set +# CONFIG_TEST_BPF is not set +# CONFIG_TEST_FIRMWARE is not set +# CONFIG_TEST_SYSCTL is not set +# CONFIG_TEST_UDELAY is not set +# CONFIG_TEST_STATIC_KEYS is not set +# CONFIG_TEST_KMOD is not set +# CONFIG_MEMTEST is not set +# CONFIG_BUG_ON_DATA_CORRUPTION is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_KGDB is not set +CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y +# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set +# CONFIG_UBSAN is not set +CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y +# CONFIG_STRICT_DEVMEM is not set +CONFIG_EARLY_PRINTK_USB=y +CONFIG_X86_VERBOSE_BOOTUP=y +CONFIG_EARLY_PRINTK=y +CONFIG_EARLY_PRINTK_DBGP=y +# CONFIG_EARLY_PRINTK_EFI is not set +# CONFIG_EARLY_PRINTK_USB_XDBC is not set +# CONFIG_X86_PTDUMP_CORE is not set +# CONFIG_X86_PTDUMP is not set +# CONFIG_EFI_PGT_DUMP is not set +# CONFIG_DEBUG_WX is not set +CONFIG_DOUBLEFAULT=y +# CONFIG_DEBUG_TLBFLUSH is not set +# CONFIG_IOMMU_STRESS is not set +CONFIG_HAVE_MMIOTRACE_SUPPORT=y +# CONFIG_X86_DECODER_SELFTEST is not set +CONFIG_IO_DELAY_TYPE_0X80=0 +CONFIG_IO_DELAY_TYPE_0XED=1 +CONFIG_IO_DELAY_TYPE_UDELAY=2 +CONFIG_IO_DELAY_TYPE_NONE=3 +CONFIG_IO_DELAY_0X80=y +# CONFIG_IO_DELAY_0XED is not set +# CONFIG_IO_DELAY_UDELAY is not set +# CONFIG_IO_DELAY_NONE is not set +CONFIG_DEFAULT_IO_DELAY_TYPE=0 +CONFIG_DEBUG_BOOT_PARAMS=y +# CONFIG_CPA_DEBUG is not set +CONFIG_OPTIMIZE_INLINING=y +# CONFIG_DEBUG_ENTRY is not set +# CONFIG_DEBUG_NMI_SELFTEST is not set +CONFIG_X86_DEBUG_FPU=y +# CONFIG_PUNIT_ATOM_DEBUG is not set +CONFIG_UNWINDER_ORC=y +# CONFIG_UNWINDER_FRAME_POINTER is not set + +# +# Security options +# +CONFIG_KEYS=y +CONFIG_KEYS_COMPAT=y +# CONFIG_PERSISTENT_KEYRINGS is not set +# CONFIG_BIG_KEYS is not set +# CONFIG_ENCRYPTED_KEYS is not set +# CONFIG_KEY_DH_OPERATIONS is not set +# CONFIG_SECURITY_DMESG_RESTRICT is not set +CONFIG_SECURITY=y +# CONFIG_SECURITY_WRITABLE_HOOKS is not set +# CONFIG_SECURITYFS is not set +CONFIG_SECURITY_NETWORK=y +CONFIG_PAGE_TABLE_ISOLATION=y +# CONFIG_SECURITY_NETWORK_XFRM is not set +# CONFIG_SECURITY_PATH is not set +# CONFIG_INTEL_TXT is not set +CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y +# CONFIG_HARDENED_USERCOPY is not set +# CONFIG_FORTIFY_SOURCE is not set +# CONFIG_STATIC_USERMODEHELPER is not set +# CONFIG_SECURITY_SELINUX is not set +# CONFIG_SECURITY_SMACK is not set +# CONFIG_SECURITY_TOMOYO is not set +# CONFIG_SECURITY_APPARMOR is not set +# CONFIG_SECURITY_LOADPIN is not set +# CONFIG_SECURITY_YAMA is not set +CONFIG_INTEGRITY=y +# CONFIG_INTEGRITY_SIGNATURE is not set +CONFIG_INTEGRITY_AUDIT=y +# CONFIG_IMA is not set +# CONFIG_EVM is not set +CONFIG_DEFAULT_SECURITY_DAC=y +CONFIG_DEFAULT_SECURITY="" +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_RNG_DEFAULT=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_ACOMP2=y +# CONFIG_CRYPTO_RSA is not set +# CONFIG_CRYPTO_DH is not set +# CONFIG_CRYPTO_ECDH is not set +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_USER is not set +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y +CONFIG_CRYPTO_GF128MUL=y +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +# CONFIG_CRYPTO_PCRYPT is not set +CONFIG_CRYPTO_WORKQUEUE=y +# CONFIG_CRYPTO_CRYPTD is not set +# CONFIG_CRYPTO_MCRYPTD is not set +CONFIG_CRYPTO_AUTHENC=y +# CONFIG_CRYPTO_TEST is not set +CONFIG_CRYPTO_ENGINE=m + +# +# Authenticated Encryption with Associated Data +# +CONFIG_CRYPTO_CCM=y +CONFIG_CRYPTO_GCM=y +# CONFIG_CRYPTO_CHACHA20POLY1305 is not set +CONFIG_CRYPTO_SEQIV=y +CONFIG_CRYPTO_ECHAINIV=y + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +CONFIG_CRYPTO_CTR=y +# CONFIG_CRYPTO_CTS is not set +CONFIG_CRYPTO_ECB=y +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set +# CONFIG_CRYPTO_KEYWRAP is not set + +# +# Hash modes +# +CONFIG_CRYPTO_CMAC=y +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set +# CONFIG_CRYPTO_VMAC is not set + +# +# Digest +# +CONFIG_CRYPTO_CRC32C=y +# CONFIG_CRYPTO_CRC32C_INTEL is not set +# CONFIG_CRYPTO_CRC32 is not set +# CONFIG_CRYPTO_CRC32_PCLMUL is not set +# CONFIG_CRYPTO_CRCT10DIF is not set +CONFIG_CRYPTO_GHASH=y +# CONFIG_CRYPTO_POLY1305 is not set +# CONFIG_CRYPTO_POLY1305_X86_64 is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA1_SSSE3 is not set +# CONFIG_CRYPTO_SHA256_SSSE3 is not set +# CONFIG_CRYPTO_SHA512_SSSE3 is not set +# CONFIG_CRYPTO_SHA1_MB is not set +# CONFIG_CRYPTO_SHA256_MB is not set +# CONFIG_CRYPTO_SHA512_MB is not set +CONFIG_CRYPTO_SHA256=y +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_SHA3 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set +# CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL is not set + +# +# Ciphers +# +CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_AES_TI is not set +# CONFIG_CRYPTO_AES_X86_64 is not set +# CONFIG_CRYPTO_AES_NI_INTEL is not set +# CONFIG_CRYPTO_ANUBIS is not set +CONFIG_CRYPTO_ARC4=y +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_BLOWFISH_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAMELLIA_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64 is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST5_AVX_X86_64 is not set +# CONFIG_CRYPTO_CAST6 is not set +# CONFIG_CRYPTO_CAST6_AVX_X86_64 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_DES3_EDE_X86_64 is not set +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SALSA20_X86_64 is not set +# CONFIG_CRYPTO_CHACHA20 is not set +# CONFIG_CRYPTO_CHACHA20_X86_64 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_SERPENT_SSE2_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX_X86_64 is not set +# CONFIG_CRYPTO_SERPENT_AVX2_X86_64 is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set +# CONFIG_CRYPTO_TWOFISH_X86_64 is not set +# CONFIG_CRYPTO_TWOFISH_X86_64_3WAY is not set +# CONFIG_CRYPTO_TWOFISH_AVX_X86_64 is not set + +# +# Compression +# +# CONFIG_CRYPTO_DEFLATE is not set +# CONFIG_CRYPTO_LZO is not set +# CONFIG_CRYPTO_842 is not set +# CONFIG_CRYPTO_LZ4 is not set +# CONFIG_CRYPTO_LZ4HC is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_CRYPTO_DRBG_MENU=y +CONFIG_CRYPTO_DRBG_HMAC=y +# CONFIG_CRYPTO_DRBG_HASH is not set +# CONFIG_CRYPTO_DRBG_CTR is not set +CONFIG_CRYPTO_DRBG=y +CONFIG_CRYPTO_JITTERENTROPY=y +# CONFIG_CRYPTO_USER_API_HASH is not set +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set +# CONFIG_CRYPTO_USER_API_RNG is not set +# CONFIG_CRYPTO_USER_API_AEAD is not set +CONFIG_CRYPTO_HW=y +# CONFIG_CRYPTO_DEV_PADLOCK is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API_DESC is not set +# CONFIG_CRYPTO_DEV_CCP is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCC is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXX is not set +# CONFIG_CRYPTO_DEV_QAT_C62X is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCCVF is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXXVF is not set +# CONFIG_CRYPTO_DEV_QAT_C62XVF is not set +# CONFIG_CRYPTO_DEV_NITROX_CNN55XX is not set +CONFIG_CRYPTO_DEV_VIRTIO=m +# CONFIG_ASYMMETRIC_KEY_TYPE is not set + +# +# Certificates for signature checking +# +# CONFIG_SYSTEM_BLACKLIST_KEYRING is not set +CONFIG_HAVE_KVM=y +CONFIG_VIRTUALIZATION=y +# CONFIG_KVM is not set +# CONFIG_VHOST_NET is not set +# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set +CONFIG_BINARY_PRINTF=y + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_HAVE_ARCH_BITREVERSE is not set +CONFIG_RATIONAL=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_NET_UTILS=y +CONFIG_GENERIC_FIND_FIRST_BIT=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_IOMAP=y +CONFIG_GENERIC_IO=y +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y +CONFIG_ARCH_HAS_FAST_MULTIPLIER=y +CONFIG_CRC_CCITT=y +CONFIG_CRC16=y +# CONFIG_CRC_T10DIF is not set +# CONFIG_CRC_ITU_T is not set +CONFIG_CRC32=y +# CONFIG_CRC32_SELFTEST is not set +CONFIG_CRC32_SLICEBY8=y +# CONFIG_CRC32_SLICEBY4 is not set +# CONFIG_CRC32_SARWATE is not set +# CONFIG_CRC32_BIT is not set +# CONFIG_CRC4 is not set +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +# CONFIG_CRC8 is not set +CONFIG_XXHASH=y +# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set +# CONFIG_RANDOM32_SELFTEST is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_ZSTD_DECOMPRESS=y +CONFIG_XZ_DEC=y +CONFIG_XZ_DEC_X86=y +CONFIG_XZ_DEC_POWERPC=y +CONFIG_XZ_DEC_IA64=y +CONFIG_XZ_DEC_ARM=y +CONFIG_XZ_DEC_ARMTHUMB=y +CONFIG_XZ_DEC_SPARC=y +CONFIG_XZ_DEC_BCJ=y +# CONFIG_XZ_DEC_TEST is not set +CONFIG_DECOMPRESS_GZIP=y +CONFIG_DECOMPRESS_BZIP2=y +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DECOMPRESS_XZ=y +CONFIG_DECOMPRESS_LZO=y +CONFIG_DECOMPRESS_LZ4=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_INTERVAL_TREE=y +CONFIG_ASSOCIATIVE_ARRAY=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAS_DMA=y +# CONFIG_DMA_NOOP_OPS is not set +# CONFIG_DMA_VIRT_OPS is not set +CONFIG_CHECK_SIGNATURE=y +CONFIG_CPU_RMAP=y +CONFIG_DQL=y +CONFIG_GLOB=y +# CONFIG_GLOB_SELFTEST is not set +CONFIG_NLATTR=y +# CONFIG_CORDIC is not set +# CONFIG_DDR is not set +# CONFIG_IRQ_POLL is not set +CONFIG_OID_REGISTRY=y +CONFIG_UCS2_STRING=y +CONFIG_FONT_SUPPORT=y +# CONFIG_FONTS is not set +CONFIG_FONT_8x8=y +CONFIG_FONT_8x16=y +# CONFIG_SG_SPLIT is not set +CONFIG_SG_POOL=y +CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_ARCH_HAS_PMEM_API=y +CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE=y +CONFIG_SBITMAP=y +# CONFIG_STRING_SELFTEST is not set diff --git a/packages/base/any/kernels/4.14-lts/kconfig.mk b/packages/base/any/kernels/4.14-lts/kconfig.mk new file mode 100644 index 00000000..07ad594b --- /dev/null +++ b/packages/base/any/kernels/4.14-lts/kconfig.mk @@ -0,0 +1,27 @@ +############################################################ +# +# +# Copyright 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +K_MAJOR_VERSION := 4 +K_PATCH_LEVEL := 14 +K_SUB_LEVEL := 34 +K_SUFFIX := +K_PATCH_DIR := $(THIS_DIR)/patches +K_MODSYNCLIST := tools/objtool diff --git a/packages/base/any/kernels/4.14-lts/patches/series b/packages/base/any/kernels/4.14-lts/patches/series new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/packages/base/any/kernels/4.14-lts/patches/series @@ -0,0 +1 @@ + From 6ca7b8f423f6b86c28666a8b4a9fced0409eb91f Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:49:03 +0000 Subject: [PATCH 237/244] Add 4.14 --- .../src/lib/platform-config-defaults-x86-64.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml index 28c29814..544bc2f8 100644 --- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml +++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml @@ -31,6 +31,11 @@ default: =: kernel-4.9-lts-x86_64-all package: onl-kernel-4.9-lts-x86-64-all:amd64 + + kernel-4.14: &kernel-4-14 + =: kernel-4.14-lts-x86_64-all + package: onl-kernel-4.14-lts-x86-64-all:amd64 + # pick one of the above kernels kernel: <<: *kernel-3-16 From 2d7288bfb8d36d3d3a09bb0302c704fad6751373 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:49:15 +0000 Subject: [PATCH 238/244] Add 4.14 --- packages/base/amd64/upgrade/builds/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/base/amd64/upgrade/builds/Makefile b/packages/base/amd64/upgrade/builds/Makefile index 3a7d529c..04e6d11b 100644 --- a/packages/base/amd64/upgrade/builds/Makefile +++ b/packages/base/amd64/upgrade/builds/Makefile @@ -2,7 +2,8 @@ include $(ONL)/make/config.amd64.mk # All amd64 kernels KERNELS := $(shell $(ONLPM) --find-file onl-kernel-3.16-lts-x86-64-all:amd64 kernel-3.16-lts-x86_64-all) \ - $(shell $(ONLPM) --find-file onl-kernel-4.9-lts-x86-64-all:amd64 kernel-4.9-lts-x86_64-all) + $(shell $(ONLPM) --find-file onl-kernel-4.9-lts-x86-64-all:amd64 kernel-4.9-lts-x86_64-all) \ + $(shell $(ONLPM) --find-file onl-kernel-4.14-lts-x86-64-all:amd64 kernel-4.14-lts-x86_64-all) # Loader initrd From 8aeac1707c1254c6c65b2f92a7d845fd6d1b6129 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:49:28 +0000 Subject: [PATCH 239/244] Kernel 4.14 for amd64. --- .../kernel-4.14-lts-x86-64-all/Makefile | 1 + .../kernel-4.14-lts-x86-64-all/PKG.yml | 30 +++++++++++++++++++ .../builds/.gitignore | 3 ++ .../builds/Makefile | 21 +++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/Makefile create mode 100644 packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/PKG.yml create mode 100644 packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/.gitignore create mode 100644 packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile diff --git a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/Makefile b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/PKG.yml b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/PKG.yml new file mode 100644 index 00000000..1c27486e --- /dev/null +++ b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/PKG.yml @@ -0,0 +1,30 @@ +variables: + basename: onl-kernel-4.14-lts-x86-64-all + +common: + arch: amd64 + version: 1.0.0 + copyright: Copyright 2013, 2014, 2015 Big Switch Networks + maintainer: support@bigswitch.com + support: opennetworklinux@googlegroups.com + +packages: + - name: $basename + version: 1.0.0 + summary: Open Network Linux 4.14 LTS Kernel for X86_64 Platforms. + symlinks: True + + files: + builds/kernel-4.14* : $$PKG_INSTALL/ + builds/linux-*mbuild : $$PKG_INSTALL/mbuilds + + changelog: Change changes changes., + + - name: $basename-modules + version: 1.0.0 + summary: Open Network Linux 4.14 LTS Kernel Modules for X86_64 Platforms + + files: + builds/lib: /lib + + changelog: Change changes changes., diff --git a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/.gitignore b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/.gitignore new file mode 100644 index 00000000..73d2c193 --- /dev/null +++ b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/.gitignore @@ -0,0 +1,3 @@ +linux-* +kernel-* +lib diff --git a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile new file mode 100644 index 00000000..67135d02 --- /dev/null +++ b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile @@ -0,0 +1,21 @@ +# -*- Makefile -*- +############################################################ +# +# +# Copyright 2013, 2014 BigSwitch Networks, Inc. +# +# +# +# +############################################################ +THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +include $(ONL)/make/config.mk + +kernel: + rm -rf lib + $(MAKE) -C $(ONL)/packages/base/any/kernels/4.14-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL) + ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-4.14.*-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common + +clean: + rm -rf linux-4.14* kernel-4.14* lib From 9359bf8c4f65bfbc33a0c3147820b4e35b184f57 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 16:49:53 +0000 Subject: [PATCH 240/244] Move the KVM platform to kernel 4.14. --- .../platform-config/r0/src/lib/x86-64-kvm-x86-64-r0.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/platform-config/r0/src/lib/x86-64-kvm-x86-64-r0.yml b/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/platform-config/r0/src/lib/x86-64-kvm-x86-64-r0.yml index fc7e9db7..83b4e611 100644 --- a/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/platform-config/r0/src/lib/x86-64-kvm-x86-64-r0.yml +++ b/packages/platforms/kvm/x86-64/x86-64-kvm-x86-64/platform-config/r0/src/lib/x86-64-kvm-x86-64-r0.yml @@ -18,7 +18,7 @@ x86-64-kvm-x86-64-r0: --stop=1 kernel: - <<: *kernel-3-16 + <<: *kernel-4-14 args: >- nopat From 5da18631b465308b45d2183bba1d5e222bed2906 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 17:52:53 +0000 Subject: [PATCH 241/244] Install libelf-dev if missing. The builder container needs to be updated. --- .../amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile index 67135d02..39ef6de5 100644 --- a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile +++ b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile @@ -14,6 +14,7 @@ include $(ONL)/make/config.mk kernel: rm -rf lib + dpkg -l libelf-dev > /dev/null 2>1 || sudo apt-get install libelf-dev # Fixme -- add to builder $(MAKE) -C $(ONL)/packages/base/any/kernels/4.14-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL) ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-4.14.*-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common From c8a697ffb20b1f9be583b3153ef49afce415f747 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 13:18:39 -0700 Subject: [PATCH 242/244] Add 4.14 modules. --- builds/any/rootfs/jessie/common/amd64-base-packages.yml | 1 + builds/any/rootfs/stretch/common/amd64-base-packages.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/builds/any/rootfs/jessie/common/amd64-base-packages.yml b/builds/any/rootfs/jessie/common/amd64-base-packages.yml index 8b3ed88b..19731052 100644 --- a/builds/any/rootfs/jessie/common/amd64-base-packages.yml +++ b/builds/any/rootfs/jessie/common/amd64-base-packages.yml @@ -12,5 +12,6 @@ - sx-kernel - onl-kernel-3.16-lts-x86-64-all-modules - onl-kernel-4.9-lts-x86-64-all-modules +- onl-kernel-4.14-lts-x86-64-all-modules - efibootmgr - gdisk diff --git a/builds/any/rootfs/stretch/common/amd64-base-packages.yml b/builds/any/rootfs/stretch/common/amd64-base-packages.yml index 33b95236..1b521e23 100644 --- a/builds/any/rootfs/stretch/common/amd64-base-packages.yml +++ b/builds/any/rootfs/stretch/common/amd64-base-packages.yml @@ -10,5 +10,6 @@ - onl-upgrade - hw-management - onl-kernel-4.9-lts-x86-64-all-modules +- onl-kernel-4.14-lts-x86-64-all-modules - efibootmgr - gdisk From c50b4bf705d27b0b35821ddc6427b62822114c44 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Apr 2018 17:03:13 -0700 Subject: [PATCH 243/244] Add verbose option. --- tools/autobuild/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/autobuild/build.sh b/tools/autobuild/build.sh index a3b6aff0..f33fab3c 100755 --- a/tools/autobuild/build.sh +++ b/tools/autobuild/build.sh @@ -9,7 +9,7 @@ ONL="$(realpath $(dirname $AUTOBUILD_SCRIPT)/../../)" # Default build branch BUILD_BRANCH=master -while getopts ":b:s:d:u:p:vc789r:" opt; do +while getopts ":b:s:d:u:p:vVc789r:" opt; do case $opt in 7) ONLB_OPTIONS=--7 @@ -38,6 +38,9 @@ while getopts ":b:s:d:u:p:vc789r:" opt; do v) set -x ;; + V) + export VERBOSE=1 + ;; r) export BUILDROOTMIRROR=$OPTARG ;; From da924d50c0c7d060fd1a8e8c01f003a65271028c Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 19 Apr 2018 01:50:05 +0000 Subject: [PATCH 244/244] Fix redirect. --- .../amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile index 39ef6de5..6d9fb290 100644 --- a/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile +++ b/packages/base/amd64/kernels/kernel-4.14-lts-x86-64-all/builds/Makefile @@ -14,7 +14,7 @@ include $(ONL)/make/config.mk kernel: rm -rf lib - dpkg -l libelf-dev > /dev/null 2>1 || sudo apt-get install libelf-dev # Fixme -- add to builder + dpkg -l libelf-dev > /dev/null 2>&1 || sudo apt-get install libelf-dev $(MAKE) -C $(ONL)/packages/base/any/kernels/4.14-lts/configs/x86_64-all K_TARGET_DIR=$(THIS_DIR) $(ONL_MAKE_PARALLEL) ARCH=x86_64 $(ONL)/tools/scripts/kmodbuild.sh linux-4.14.*-mbuild "$(wildcard $(ONL)/packages/base/any/kernels/modules/*)" onl/onl/common